@codingame/monaco-vscode-api 1.69.19 → 1.69.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/api.js +2 -2
- package/dist/async.js +196 -0
- package/dist/configuration.d.ts +3 -2
- package/dist/configuration.js +338 -7
- package/dist/dialogs.js +1 -1
- package/dist/extHost.js +8 -28
- package/dist/files.js +113 -4
- package/dist/keybindings.js +7 -7
- package/dist/languageConfiguration.js +3 -3
- package/dist/languageService.js +3 -2
- package/dist/languages.js +3 -3
- package/dist/layout.js +1 -1
- package/dist/missing-services.js +9 -1469
- package/dist/modelEditor.js +2 -2
- package/dist/monaco.js +2 -2
- package/dist/notifications.js +4 -3
- package/dist/polyfill.js +99 -2
- package/dist/services.js +2 -2
- package/dist/services2.js +7 -9
- package/dist/snippets.js +7 -7
- package/dist/textmate.js +3 -3
- package/dist/theme.js +6 -5
- package/dist/tokenClassification.js +3 -3
- package/dist/tokenClassificationRegistry.js +1 -1
- package/dist/tools.js +822 -4
- package/dist/types.js +1 -1
- package/dist/workbenchThemeService.js +1 -1
- package/dist/workspace.js +1 -98
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -33,15 +33,15 @@ Services.install({
|
|
|
33
33
|
Also, monaco-editor use `standalone` versions or the vscode services, which are much simpler.
|
|
34
34
|
|
|
35
35
|
You may want to provide your custom implementations of them, especially for: `textModelService`, `codeEditorService` and `notificationService`. To do so, you can provide them as the third parameter while creating your first editor.
|
|
36
|
-
This library allows you to use a more convenient way using `
|
|
36
|
+
This library allows you to use a more convenient way using `StandaloneServices.initialize`.
|
|
37
37
|
Also, monaco-editor doesn't provide good type for them, so this library does it.
|
|
38
38
|
|
|
39
39
|
Example:
|
|
40
40
|
```typescript
|
|
41
|
-
import {
|
|
41
|
+
import { StandaloneServices, INotificationService } from 'vscode/services'
|
|
42
42
|
|
|
43
43
|
class MyCustomNotificationService implements INotificationService { ... }
|
|
44
|
-
|
|
44
|
+
StandaloneServices.initialize({
|
|
45
45
|
get [INotificationService.toString()] () {
|
|
46
46
|
return new MyCustomNotificationService(...)
|
|
47
47
|
}
|
|
@@ -63,7 +63,7 @@ Additionally, this library exposes 10 modules that include the vscode version of
|
|
|
63
63
|
|
|
64
64
|
Usage:
|
|
65
65
|
```typescript
|
|
66
|
-
import {
|
|
66
|
+
import { StandaloneServices } from 'vscode/services'
|
|
67
67
|
import getModelEditorServiceOverride from 'vscode/service-override/modelEditor'
|
|
68
68
|
import getMessageServiceOverride from 'vscode/service-override/messages'
|
|
69
69
|
import getConfigurationServiceOverride, { updateUserConfiguration, configurationRegistry } from 'vscode/service-override/configuration'
|
package/dist/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './polyfill.js';
|
|
2
|
-
import { B as Breakpoint$1, C as CallHierarchyIncomingCall$1, a as CallHierarchyItem$1, b as CallHierarchyOutgoingCall$1, c as
|
|
3
|
-
import { C as CancellationTokenSource$1, F as FileType$1, a as FilePermission$1, S as Services } from './services2.js';
|
|
2
|
+
import { B as Breakpoint$1, C as CallHierarchyIncomingCall$1, a as CallHierarchyItem$1, b as CallHierarchyOutgoingCall$1, c as CancellationTokenSource$1, d as CodeAction$1, e as CodeActionKind$1, f as CodeActionTriggerKind$1, g as CodeLens$1, h as Color$1, i as ColorInformation$1, j as ColorPresentation$1, k as CommentMode$1, l as CommentThreadCollapsibleState$1, m as CompletionItem$1, n as CompletionItemKind$1, o as CompletionItemTag$1, p as CompletionList$1, q as CompletionTriggerKind$1, r as ConfigurationTarget$1, s as CustomExecution$1, D as DebugAdapterExecutable$1, t as DebugAdapterInlineImplementation$1, u as DebugAdapterNamedPipeServer$1, v as DebugAdapterServer$1, w as DebugConsoleMode$1, x as DecorationRangeBehavior$1, y as Diagnostic$1, z as DiagnosticRelatedInformation$1, A as DiagnosticSeverity$1, E as DiagnosticTag$1, F as Disposable$1, G as DocumentHighlight$1, H as DocumentHighlightKind$1, I as DocumentLink$1, J as DocumentSymbol$1, K as EndOfLine$1, L as EnvironmentVariableMutatorType$1, M as EvaluatableExpression$1, N as InlineValueText$1, O as InlineValueVariableLookup$1, P as InlineValueEvaluatableExpression$1, Q as ExtensionKind$1, R as ExtensionMode$1, S as FileChangeType$1, T as FileDecoration$1, U as FileSystemError$1, V as FoldingRange$1, W as FoldingRangeKind$1, X as FunctionBreakpoint$1, Y as Hover$1, Z as Location$1, _ as MarkdownString$1, $ as ParameterInformation$1, a0 as Position$1, a1 as ProcessExecution$1, a2 as ProgressLocation$1, a3 as QuickInputButtons$1, a4 as Range$1, a5 as RelativePattern$1, a6 as Selection$2, a7 as SelectionRange$1, a8 as SemanticTokens$1, a9 as SemanticTokensBuilder$1, aa as SemanticTokensEdit$1, ab as SemanticTokensEdits$1, ac as SemanticTokensLegend$1, ad as ShellExecution$1, ae as ShellQuoting$1, af as SignatureHelp$1, ag as SignatureHelpTriggerKind$1, ah as SignatureInformation$1, ai as SnippetString$1, aj as SourceBreakpoint$1, ak as StatusBarAlignment$1, al as SymbolInformation$1, am as SymbolKind$1, an as SymbolTag$1, ao as Task$1, ap as TaskGroup$1, aq as TaskPanelKind$1, ar as TaskRevealKind$1, as as TaskScope$1, at as TerminalLink$1, au as TerminalLocation$1, av as TerminalProfile$1, aw as TextDocumentSaveReason$1, ax as TextEdit$1, ay as TextEditorLineNumbersStyle$1, az as TextEditorRevealType$1, aA as TextEditorSelectionChangeKind$1, aB as TextDocumentChangeReason$1, aC as ThemeColor$1, aD as ThemeIcon$1, aE as TreeItem$1, aF as TreeItemCollapsibleState$1, aG as TypeHierarchyItem$1, aH as UIKind$1, aI as ViewColumn$1, aJ as WorkspaceEdit$1, aK as InlayHint$1, aL as InlayHintLabelPart$1, aM as InlayHintKind$1, aN as NotebookRange$1, aO as NotebookCellKind$1, aP as NotebookCellData$1, aQ as NotebookData$1, aR as NotebookCellStatusBarAlignment$1, aS as NotebookCellOutput$1, aT as NotebookCellOutputItem$1, aU as NotebookCellStatusBarItem$1, aV as NotebookControllerAffinity$1, aW as LinkedEditingRanges$1, aX as TestRunRequest$1, aY as TestMessage$1, aZ as TestTag$1, a_ as TestRunProfileKind$1, a$ as LanguageStatusSeverity$1, b0 as QuickPickItemKind$1, b1 as TextDiffTabInput, b2 as CustomEditorTabInput, b3 as NotebookEditorTabInput, b4 as NotebookDiffEditorTabInput, b5 as WebviewEditorTabInput, b6 as TerminalEditorTabInput, b7 as InputBoxValidationSeverity$1, b8 as InlineSuggestionList, b9 as InlineCompletionTriggerKind$1, ba as InlineSuggestion, bb as DocumentDropEdit$1, bc as NotebookEditorRevealType$1, bd as getExtHostServices, be as DEFAULT_EXTENSION, bf as LanguageSelector } from './extHost.js';
|
|
4
3
|
import { E as Emitter } from './workspace.js';
|
|
4
|
+
import { F as FileType$1, a as FilePermission$1, S as Services } from './services2.js';
|
|
5
5
|
import { score } from 'monaco-editor/esm/vs/editor/common/languageSelector.js';
|
|
6
6
|
import { u as unsupported$1 } from './missing-services.js';
|
|
7
7
|
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
package/dist/async.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { E as Emitter } from './workspace.js';
|
|
2
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
3
|
+
import { extUri } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
4
|
+
import { CancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
5
|
+
function raceCancellationError(promise, token) {
|
|
6
|
+
return ( new Promise((resolve, reject) => {
|
|
7
|
+
const ref = token.onCancellationRequested(() => {
|
|
8
|
+
ref.dispose();
|
|
9
|
+
reject(( new CancellationError()));
|
|
10
|
+
});
|
|
11
|
+
promise.then(resolve, reject).finally(() => ref.dispose());
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
class Sequencer {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.current = Promise.resolve(null);
|
|
17
|
+
}
|
|
18
|
+
queue(promiseTask) {
|
|
19
|
+
return this.current = this.current.then(() => promiseTask(), () => promiseTask());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class Barrier {
|
|
23
|
+
constructor() {
|
|
24
|
+
this._isOpen = false;
|
|
25
|
+
this._promise = ( new Promise((c, e) => {
|
|
26
|
+
this._completePromise = c;
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
isOpen() {
|
|
30
|
+
return this._isOpen;
|
|
31
|
+
}
|
|
32
|
+
open() {
|
|
33
|
+
this._isOpen = true;
|
|
34
|
+
this._completePromise(true);
|
|
35
|
+
}
|
|
36
|
+
wait() {
|
|
37
|
+
return this._promise;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class Limiter {
|
|
41
|
+
constructor(maxDegreeOfParalellism) {
|
|
42
|
+
this._size = 0;
|
|
43
|
+
this.maxDegreeOfParalellism = maxDegreeOfParalellism;
|
|
44
|
+
this.outstandingPromises = [];
|
|
45
|
+
this.runningPromises = 0;
|
|
46
|
+
this._onDrained = ( new Emitter());
|
|
47
|
+
}
|
|
48
|
+
get onDrained() {
|
|
49
|
+
return this._onDrained.event;
|
|
50
|
+
}
|
|
51
|
+
get size() {
|
|
52
|
+
return this._size;
|
|
53
|
+
}
|
|
54
|
+
queue(factory) {
|
|
55
|
+
this._size++;
|
|
56
|
+
return ( new Promise((c, e) => {
|
|
57
|
+
this.outstandingPromises.push({ factory, c, e });
|
|
58
|
+
this.consume();
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
consume() {
|
|
62
|
+
while (this.outstandingPromises.length && this.runningPromises < this.maxDegreeOfParalellism) {
|
|
63
|
+
const iLimitedTask = this.outstandingPromises.shift();
|
|
64
|
+
this.runningPromises++;
|
|
65
|
+
const promise = iLimitedTask.factory();
|
|
66
|
+
promise.then(iLimitedTask.c, iLimitedTask.e);
|
|
67
|
+
promise.then(() => this.consumed(), () => this.consumed());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
consumed() {
|
|
71
|
+
this._size--;
|
|
72
|
+
this.runningPromises--;
|
|
73
|
+
if (this.outstandingPromises.length > 0) {
|
|
74
|
+
this.consume();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this._onDrained.fire();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
dispose() {
|
|
81
|
+
this._onDrained.dispose();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class Queue extends Limiter {
|
|
85
|
+
constructor() {
|
|
86
|
+
super(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class ResourceQueue {
|
|
90
|
+
constructor() {
|
|
91
|
+
this.queues = ( new Map());
|
|
92
|
+
this.drainers = ( new Set());
|
|
93
|
+
}
|
|
94
|
+
async whenDrained() {
|
|
95
|
+
if (this.isDrained()) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const promise = ( new DeferredPromise());
|
|
99
|
+
this.drainers.add(promise);
|
|
100
|
+
return promise.p;
|
|
101
|
+
}
|
|
102
|
+
isDrained() {
|
|
103
|
+
for (const [, queue] of this.queues) {
|
|
104
|
+
if (queue.size > 0) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
queueFor(resource, extUri$1 = extUri) {
|
|
111
|
+
const key = extUri$1.getComparisonKey(resource);
|
|
112
|
+
let queue = this.queues.get(key);
|
|
113
|
+
if (!queue) {
|
|
114
|
+
queue = ( new Queue());
|
|
115
|
+
Event.once(queue.onDrained)(() => {
|
|
116
|
+
queue?.dispose();
|
|
117
|
+
this.queues.delete(key);
|
|
118
|
+
this.onDidQueueDrain();
|
|
119
|
+
});
|
|
120
|
+
this.queues.set(key, queue);
|
|
121
|
+
}
|
|
122
|
+
return queue;
|
|
123
|
+
}
|
|
124
|
+
onDidQueueDrain() {
|
|
125
|
+
if (!this.isDrained()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.releaseDrainers();
|
|
129
|
+
}
|
|
130
|
+
releaseDrainers() {
|
|
131
|
+
for (const drainer of this.drainers) {
|
|
132
|
+
drainer.complete();
|
|
133
|
+
}
|
|
134
|
+
this.drainers.clear();
|
|
135
|
+
}
|
|
136
|
+
dispose() {
|
|
137
|
+
for (const [, queue] of this.queues) {
|
|
138
|
+
queue.dispose();
|
|
139
|
+
}
|
|
140
|
+
this.queues.clear();
|
|
141
|
+
this.releaseDrainers();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
class IntervalCounter {
|
|
145
|
+
constructor(interval, nowFn = () => Date.now()) {
|
|
146
|
+
this.interval = interval;
|
|
147
|
+
this.nowFn = nowFn;
|
|
148
|
+
this.lastIncrementTime = 0;
|
|
149
|
+
this.value = 0;
|
|
150
|
+
}
|
|
151
|
+
increment() {
|
|
152
|
+
const now = this.nowFn();
|
|
153
|
+
if (now - this.lastIncrementTime > this.interval) {
|
|
154
|
+
this.lastIncrementTime = now;
|
|
155
|
+
this.value = 0;
|
|
156
|
+
}
|
|
157
|
+
this.value++;
|
|
158
|
+
return this.value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
class DeferredPromise {
|
|
162
|
+
constructor() {
|
|
163
|
+
this.rejected = false;
|
|
164
|
+
this.resolved = false;
|
|
165
|
+
this.p = ( new Promise((c, e) => {
|
|
166
|
+
this.completeCallback = c;
|
|
167
|
+
this.errorCallback = e;
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
get isRejected() {
|
|
171
|
+
return this.rejected;
|
|
172
|
+
}
|
|
173
|
+
get isResolved() {
|
|
174
|
+
return this.resolved;
|
|
175
|
+
}
|
|
176
|
+
get isSettled() {
|
|
177
|
+
return this.rejected || this.resolved;
|
|
178
|
+
}
|
|
179
|
+
complete(value) {
|
|
180
|
+
return ( new Promise(resolve => {
|
|
181
|
+
this.completeCallback(value);
|
|
182
|
+
this.resolved = true;
|
|
183
|
+
resolve();
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
error(err) {
|
|
187
|
+
return ( new Promise(resolve => {
|
|
188
|
+
this.errorCallback(err);
|
|
189
|
+
this.rejected = true;
|
|
190
|
+
resolve();
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
cancel() {
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
export { Barrier as B, IntervalCounter as I, ResourceQueue as R, Sequencer as S, raceCancellationError as r };
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as monaco from 'monaco-editor';
|
|
2
1
|
import * as vscode from 'vscode';
|
|
2
|
+
import * as monaco from 'monaco-editor';
|
|
3
3
|
|
|
4
4
|
interface IDisposable {
|
|
5
5
|
dispose(): void;
|
|
@@ -483,7 +483,8 @@ interface IColorCustomizations {
|
|
|
483
483
|
|
|
484
484
|
declare function updateUserConfiguration(configurationJson: string): Promise<void>;
|
|
485
485
|
declare function getUserConfiguration(): Promise<string>;
|
|
486
|
+
declare function onUserConfigurationChange(callback: () => void): vscode.Disposable;
|
|
486
487
|
declare const configurationRegistry: IConfigurationRegistry;
|
|
487
488
|
declare function getServiceOverride(): IEditorOverrideServices;
|
|
488
489
|
|
|
489
|
-
export { ConfigurationScope, IColorCustomizations, IConfigurationDefaults, IConfigurationNode, IThemeScopedColorCustomizations, configurationRegistry, getServiceOverride as default, getUserConfiguration, updateUserConfiguration };
|
|
490
|
+
export { ConfigurationScope, IColorCustomizations, IConfigurationDefaults, IConfigurationNode, IThemeScopedColorCustomizations, configurationRegistry, getServiceOverride as default, getUserConfiguration, onUserConfigurationChange, updateUserConfiguration };
|
package/dist/configuration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as Emitter, _ as __decorate, a as __param } from './workspace.js';
|
|
2
|
-
import { U as UserSettings } from './polyfill.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { U as UserSettings, p as parseTree, f as findNodeAtLocation, c as createScanner } from './polyfill.js';
|
|
3
|
+
import { b as IPolicyService, N as NullPolicyService } from './missing-services.js';
|
|
4
|
+
import { i as isEmptyObject } from './types.js';
|
|
5
5
|
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
6
6
|
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
7
7
|
import { Extensions, machineOverridableSettings, windowSettings, resourceSettings, allSettings, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, OVERRIDE_PROPERTY_REGEX, overrideIdentifiersFromKey, applicationSettings, machineSettings } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
@@ -15,11 +15,11 @@ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
|
15
15
|
import { isArray } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
16
16
|
import { extUriBiasedIgnorePathCase } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
17
17
|
import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
18
|
-
import {
|
|
19
|
-
export {
|
|
18
|
+
import { bg as Position$2, bh as keyFromOverrideIdentifiers, bi as configurationDefaultsSchemaId } from './extHost.js';
|
|
19
|
+
export { bj as ConfigurationScope } from './extHost.js';
|
|
20
20
|
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
21
21
|
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
22
|
-
import {
|
|
22
|
+
import { r as IUserDataProfilesService, c as IFileService, l as IWorkbenchEnvironmentService } from './services2.js';
|
|
23
23
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
24
24
|
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
25
25
|
import { IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
|
|
@@ -192,6 +192,328 @@ PolicyConfiguration = ( (__decorate([
|
|
|
192
192
|
( (__param(1, IPolicyService))),
|
|
193
193
|
( (__param(2, ILogService)))
|
|
194
194
|
], PolicyConfiguration)));
|
|
195
|
+
function format(documentText, range, options) {
|
|
196
|
+
let initialIndentLevel;
|
|
197
|
+
let formatText;
|
|
198
|
+
let formatTextStart;
|
|
199
|
+
let rangeStart;
|
|
200
|
+
let rangeEnd;
|
|
201
|
+
if (range) {
|
|
202
|
+
rangeStart = range.offset;
|
|
203
|
+
rangeEnd = rangeStart + range.length;
|
|
204
|
+
formatTextStart = rangeStart;
|
|
205
|
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
206
|
+
formatTextStart--;
|
|
207
|
+
}
|
|
208
|
+
let endOffset = rangeEnd;
|
|
209
|
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
210
|
+
endOffset++;
|
|
211
|
+
}
|
|
212
|
+
formatText = documentText.substring(formatTextStart, endOffset);
|
|
213
|
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
formatText = documentText;
|
|
217
|
+
initialIndentLevel = 0;
|
|
218
|
+
formatTextStart = 0;
|
|
219
|
+
rangeStart = 0;
|
|
220
|
+
rangeEnd = documentText.length;
|
|
221
|
+
}
|
|
222
|
+
const eol = getEOL(options, documentText);
|
|
223
|
+
let lineBreak = false;
|
|
224
|
+
let indentLevel = 0;
|
|
225
|
+
let indentValue;
|
|
226
|
+
if (options.insertSpaces) {
|
|
227
|
+
indentValue = repeat(' ', options.tabSize || 4);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
indentValue = '\t';
|
|
231
|
+
}
|
|
232
|
+
const scanner = createScanner(formatText, false);
|
|
233
|
+
let hasError = false;
|
|
234
|
+
function newLineAndIndent() {
|
|
235
|
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
236
|
+
}
|
|
237
|
+
function scanNext() {
|
|
238
|
+
let token = scanner.scan();
|
|
239
|
+
lineBreak = false;
|
|
240
|
+
while (token === 15 || token === 14 ) {
|
|
241
|
+
lineBreak = lineBreak || ((token === 14) );
|
|
242
|
+
token = scanner.scan();
|
|
243
|
+
}
|
|
244
|
+
hasError = token === 16 || scanner.getTokenError() !== 0 ;
|
|
245
|
+
return token;
|
|
246
|
+
}
|
|
247
|
+
const editOperations = [];
|
|
248
|
+
function addEdit(text, startOffset, endOffset) {
|
|
249
|
+
if (!hasError && startOffset < rangeEnd && endOffset > rangeStart && documentText.substring(startOffset, endOffset) !== text) {
|
|
250
|
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
let firstToken = scanNext();
|
|
254
|
+
if (firstToken !== 17 ) {
|
|
255
|
+
const firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
256
|
+
const initialIndent = repeat(indentValue, initialIndentLevel);
|
|
257
|
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
258
|
+
}
|
|
259
|
+
while (firstToken !== 17 ) {
|
|
260
|
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
261
|
+
let secondToken = scanNext();
|
|
262
|
+
let replaceContent = '';
|
|
263
|
+
while (!lineBreak && ((secondToken === 12 || secondToken === 13) )) {
|
|
264
|
+
const commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
265
|
+
addEdit(' ', firstTokenEnd, commentTokenStart);
|
|
266
|
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
267
|
+
replaceContent = secondToken === 12 ? newLineAndIndent() : '';
|
|
268
|
+
secondToken = scanNext();
|
|
269
|
+
}
|
|
270
|
+
if (secondToken === 2 ) {
|
|
271
|
+
if (firstToken !== 1 ) {
|
|
272
|
+
indentLevel--;
|
|
273
|
+
replaceContent = newLineAndIndent();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (secondToken === 4 ) {
|
|
277
|
+
if (firstToken !== 3 ) {
|
|
278
|
+
indentLevel--;
|
|
279
|
+
replaceContent = newLineAndIndent();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
switch (firstToken) {
|
|
284
|
+
case 3 :
|
|
285
|
+
case 1 :
|
|
286
|
+
indentLevel++;
|
|
287
|
+
replaceContent = newLineAndIndent();
|
|
288
|
+
break;
|
|
289
|
+
case 5 :
|
|
290
|
+
case 12 :
|
|
291
|
+
replaceContent = newLineAndIndent();
|
|
292
|
+
break;
|
|
293
|
+
case 13 :
|
|
294
|
+
if (lineBreak) {
|
|
295
|
+
replaceContent = newLineAndIndent();
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
replaceContent = ' ';
|
|
299
|
+
}
|
|
300
|
+
break;
|
|
301
|
+
case 6 :
|
|
302
|
+
replaceContent = ' ';
|
|
303
|
+
break;
|
|
304
|
+
case 10 :
|
|
305
|
+
if (secondToken === 6 ) {
|
|
306
|
+
replaceContent = '';
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case 7 :
|
|
310
|
+
case 8 :
|
|
311
|
+
case 9 :
|
|
312
|
+
case 11 :
|
|
313
|
+
case 2 :
|
|
314
|
+
case 4 :
|
|
315
|
+
if (secondToken === 12 || secondToken === 13 ) {
|
|
316
|
+
replaceContent = ' ';
|
|
317
|
+
}
|
|
318
|
+
else if (secondToken !== 5 && secondToken !== 17 ) {
|
|
319
|
+
hasError = true;
|
|
320
|
+
}
|
|
321
|
+
break;
|
|
322
|
+
case 16 :
|
|
323
|
+
hasError = true;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
if (lineBreak && ((secondToken === 12 || secondToken === 13) )) {
|
|
327
|
+
replaceContent = newLineAndIndent();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
331
|
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
332
|
+
firstToken = secondToken;
|
|
333
|
+
}
|
|
334
|
+
return editOperations;
|
|
335
|
+
}
|
|
336
|
+
function repeat(s, count) {
|
|
337
|
+
let result = '';
|
|
338
|
+
for (let i = 0; i < count; i++) {
|
|
339
|
+
result += s;
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
function computeIndentLevel(content, options) {
|
|
344
|
+
let i = 0;
|
|
345
|
+
let nChars = 0;
|
|
346
|
+
const tabSize = options.tabSize || 4;
|
|
347
|
+
while (i < content.length) {
|
|
348
|
+
const ch = content.charAt(i);
|
|
349
|
+
if (ch === ' ') {
|
|
350
|
+
nChars++;
|
|
351
|
+
}
|
|
352
|
+
else if (ch === '\t') {
|
|
353
|
+
nChars += tabSize;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
i++;
|
|
359
|
+
}
|
|
360
|
+
return Math.floor(nChars / tabSize);
|
|
361
|
+
}
|
|
362
|
+
function getEOL(options, text) {
|
|
363
|
+
for (let i = 0; i < text.length; i++) {
|
|
364
|
+
const ch = text.charAt(i);
|
|
365
|
+
if (ch === '\r') {
|
|
366
|
+
if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
|
|
367
|
+
return '\r\n';
|
|
368
|
+
}
|
|
369
|
+
return '\r';
|
|
370
|
+
}
|
|
371
|
+
else if (ch === '\n') {
|
|
372
|
+
return '\n';
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return (options && options.eol) || '\n';
|
|
376
|
+
}
|
|
377
|
+
function isEOL(text, offset) {
|
|
378
|
+
return '\r\n'.indexOf(text.charAt(offset)) !== -1;
|
|
379
|
+
}
|
|
380
|
+
function setProperty(text, originalPath, value, formattingOptions, getInsertionIndex) {
|
|
381
|
+
const path = originalPath.slice();
|
|
382
|
+
const errors = [];
|
|
383
|
+
const root = parseTree(text, errors);
|
|
384
|
+
let parent = undefined;
|
|
385
|
+
let lastSegment = undefined;
|
|
386
|
+
while (path.length > 0) {
|
|
387
|
+
lastSegment = path.pop();
|
|
388
|
+
parent = findNodeAtLocation(root, path);
|
|
389
|
+
if (parent === undefined && value !== undefined) {
|
|
390
|
+
if (typeof lastSegment === 'string') {
|
|
391
|
+
value = { [lastSegment]: value };
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
value = [value];
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (!parent) {
|
|
402
|
+
if (value === undefined) {
|
|
403
|
+
throw new Error('Can not delete in empty document');
|
|
404
|
+
}
|
|
405
|
+
return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
|
|
406
|
+
}
|
|
407
|
+
else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
|
|
408
|
+
const existing = findNodeAtLocation(parent, [lastSegment]);
|
|
409
|
+
if (existing !== undefined) {
|
|
410
|
+
if (value === undefined) {
|
|
411
|
+
if (!existing.parent) {
|
|
412
|
+
throw new Error('Malformed AST');
|
|
413
|
+
}
|
|
414
|
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
415
|
+
let removeBegin;
|
|
416
|
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
417
|
+
if (propertyIndex > 0) {
|
|
418
|
+
const previous = parent.children[propertyIndex - 1];
|
|
419
|
+
removeBegin = previous.offset + previous.length;
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
removeBegin = parent.offset + 1;
|
|
423
|
+
if (parent.children.length > 1) {
|
|
424
|
+
const next = parent.children[1];
|
|
425
|
+
removeEnd = next.offset;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, formattingOptions);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, formattingOptions);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
if (value === undefined) {
|
|
436
|
+
return [];
|
|
437
|
+
}
|
|
438
|
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
439
|
+
const index = getInsertionIndex ? getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
|
|
440
|
+
let edit;
|
|
441
|
+
if (index > 0) {
|
|
442
|
+
const previous = parent.children[index - 1];
|
|
443
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
|
444
|
+
}
|
|
445
|
+
else if (parent.children.length === 0) {
|
|
446
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
|
|
450
|
+
}
|
|
451
|
+
return withFormatting(text, edit, formattingOptions);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
|
|
455
|
+
if (value !== undefined) {
|
|
456
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
457
|
+
let edit;
|
|
458
|
+
if (parent.children.length === 0 || lastSegment === 0) {
|
|
459
|
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
const index = lastSegment === -1 || lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
463
|
+
const previous = parent.children[index - 1];
|
|
464
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
|
|
465
|
+
}
|
|
466
|
+
return withFormatting(text, edit, formattingOptions);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
const removalIndex = lastSegment;
|
|
470
|
+
const toRemove = parent.children[removalIndex];
|
|
471
|
+
let edit;
|
|
472
|
+
if (parent.children.length === 1) {
|
|
473
|
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
|
|
474
|
+
}
|
|
475
|
+
else if (parent.children.length - 1 === removalIndex) {
|
|
476
|
+
const previous = parent.children[removalIndex - 1];
|
|
477
|
+
const offset = previous.offset + previous.length;
|
|
478
|
+
const parentEndOffset = parent.offset + parent.length;
|
|
479
|
+
edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
|
|
483
|
+
}
|
|
484
|
+
return withFormatting(text, edit, formattingOptions);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function withFormatting(text, edit, formattingOptions) {
|
|
492
|
+
let newText = applyEdit(text, edit);
|
|
493
|
+
let begin = edit.offset;
|
|
494
|
+
let end = edit.offset + edit.content.length;
|
|
495
|
+
if (edit.length === 0 || edit.content.length === 0) {
|
|
496
|
+
while (begin > 0 && !isEOL(newText, begin - 1)) {
|
|
497
|
+
begin--;
|
|
498
|
+
}
|
|
499
|
+
while (end < newText.length && !isEOL(newText, end)) {
|
|
500
|
+
end++;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const edits = format(newText, { offset: begin, length: end - begin }, formattingOptions);
|
|
504
|
+
for (let i = edits.length - 1; i >= 0; i--) {
|
|
505
|
+
const curr = edits[i];
|
|
506
|
+
newText = applyEdit(newText, curr);
|
|
507
|
+
begin = Math.min(begin, curr.offset);
|
|
508
|
+
end = Math.max(end, curr.offset + curr.length);
|
|
509
|
+
end += curr.content.length - curr.length;
|
|
510
|
+
}
|
|
511
|
+
const editLength = text.length - (newText.length - end) - begin;
|
|
512
|
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
|
513
|
+
}
|
|
514
|
+
function applyEdit(text, edit) {
|
|
515
|
+
return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
|
|
516
|
+
}
|
|
195
517
|
class ConfigurationService extends Disposable {
|
|
196
518
|
constructor(settingsResource, fileService, policyService, logService) {
|
|
197
519
|
super();
|
|
@@ -549,6 +871,14 @@ async function getUserConfiguration() {
|
|
|
549
871
|
const userDataProfilesService = StandaloneServices.get(IUserDataProfilesService);
|
|
550
872
|
return ( (await StandaloneServices.get(IFileService).readFile(userDataProfilesService.defaultProfile.settingsResource)).value.toString());
|
|
551
873
|
}
|
|
874
|
+
function onUserConfigurationChange(callback) {
|
|
875
|
+
const userDataProfilesService = StandaloneServices.get(IUserDataProfilesService);
|
|
876
|
+
return StandaloneServices.get(IFileService).onDidFilesChange(e => {
|
|
877
|
+
if (e.affects(userDataProfilesService.defaultProfile.settingsResource)) {
|
|
878
|
+
callback();
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
}
|
|
552
882
|
const configurationRegistry = ( Registry.as(Extensions.Configuration));
|
|
553
883
|
function updateJsonValue(jsonValue, jsonPath, value, configFileUrl) {
|
|
554
884
|
const creationOptions = StandaloneServices.get(IModelService).getCreationOptions('json', configFileUrl, true);
|
|
@@ -598,6 +928,7 @@ InjectedConfigurationService = ( __decorate([
|
|
|
598
928
|
], InjectedConfigurationService));
|
|
599
929
|
function initialize(instantiationService) {
|
|
600
930
|
instantiationService.createInstance(RegisterConfigurationSchemasContribution);
|
|
931
|
+
void updateUserConfiguration('{}');
|
|
601
932
|
}
|
|
602
933
|
function getServiceOverride() {
|
|
603
934
|
onServicesInitialized(initialize);
|
|
@@ -608,4 +939,4 @@ function getServiceOverride() {
|
|
|
608
939
|
[( ITextResourceConfigurationService.toString())]: new SyncDescriptor(TextResourceConfigurationService)
|
|
609
940
|
};
|
|
610
941
|
}
|
|
611
|
-
export { configurationRegistry, getServiceOverride as default, getUserConfiguration, updateUserConfiguration };
|
|
942
|
+
export { configurationRegistry, getServiceOverride as default, getUserConfiguration, onUserConfigurationChange, updateUserConfiguration };
|
package/dist/dialogs.js
CHANGED
|
@@ -4,7 +4,7 @@ import { g as getServiceOverride$1, D as DialogHandlerContribution } from './lay
|
|
|
4
4
|
import { _ as __decorate, a as __param, E as Emitter } from './workspace.js';
|
|
5
5
|
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
6
6
|
import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
7
|
-
import {
|
|
7
|
+
import { l as IWorkbenchEnvironmentService } from './services2.js';
|
|
8
8
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
9
9
|
import { o as onServicesInitialized } from './tools.js';
|
|
10
10
|
import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|