@codingame/monaco-vscode-base-service-override 25.1.2 → 26.0.0

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.
Files changed (22) hide show
  1. package/index.js +4 -1
  2. package/package.json +2 -2
  3. package/vscode/src/vs/base/common/observableInternal/experimental/time.js +3 -5
  4. package/vscode/src/vs/base/parts/request/common/requestImpl.js +25 -29
  5. package/vscode/src/vs/platform/download/common/downloadService.js +6 -7
  6. package/vscode/src/vs/platform/request/common/requestIpc.js +9 -6
  7. package/vscode/src/vs/workbench/contrib/inlineCompletions/browser/renameSymbolTrackerService.d.ts +18 -0
  8. package/vscode/src/vs/workbench/contrib/inlineCompletions/browser/renameSymbolTrackerService.js +240 -0
  9. package/vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js +37 -23
  10. package/vscode/src/vs/workbench/services/decorations/browser/decorationsService.js +64 -45
  11. package/vscode/src/vs/workbench/services/inlineCompletions/common/inlineCompletionsUnification.js +39 -29
  12. package/vscode/src/vs/workbench/services/label/common/labelService.js +139 -111
  13. package/vscode/src/vs/workbench/services/path/browser/pathService.js +1 -1
  14. package/vscode/src/vs/workbench/services/path/common/pathService.js +12 -19
  15. package/vscode/src/vs/workbench/services/request/browser/requestService.js +16 -14
  16. package/vscode/src/vs/workbench/services/url/browser/urlService.js +9 -9
  17. package/vscode/src/vs/workbench/services/userActivity/common/userActivityRegistry.js +1 -1
  18. package/vscode/src/vs/workbench/services/userActivity/common/userActivityService.js +4 -4
  19. package/vscode/src/vs/workbench/services/userAttention/browser/userAttentionBrowser.js +32 -19
  20. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopySaveParticipant.js +9 -12
  21. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileOperationParticipant.js +4 -8
  22. package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyFileService.js +100 -41
package/index.js CHANGED
@@ -39,6 +39,8 @@ import { MarkdownRendererService } from '@codingame/monaco-vscode-api/vscode/vs/
39
39
  import { IUserAttentionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userAttention/common/userAttentionService.service';
40
40
  import { UserAttentionService } from './vscode/src/vs/workbench/services/userAttention/browser/userAttentionBrowser.js';
41
41
  import { EditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/editorWorkerService';
42
+ import { IRenameSymbolTrackerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/renameSymbolTrackerService.service';
43
+ import { RenameSymbolTrackerService } from './vscode/src/vs/workbench/contrib/inlineCompletions/browser/renameSymbolTrackerService.js';
42
44
 
43
45
  let BrowserPathServiceOverride = class BrowserPathServiceOverride extends AbstractPathService {
44
46
  constructor(remoteAgentService, environmentService, contextService) {
@@ -67,7 +69,8 @@ function getServiceOverride() {
67
69
  [IEditorWorkerService.toString()]: new SyncDescriptor(EditorWorkerService, [], true),
68
70
  [IInlineCompletionsUnificationService.toString()]: new SyncDescriptor(InlineCompletionsUnificationImpl, [], true),
69
71
  [IMarkdownRendererService.toString()]: new SyncDescriptor(MarkdownRendererService, [], true),
70
- [IUserAttentionService.toString()]: new SyncDescriptor(UserAttentionService, [], true)
72
+ [IUserAttentionService.toString()]: new SyncDescriptor(UserAttentionService, [], true),
73
+ [IRenameSymbolTrackerService.toString()]: new SyncDescriptor(RenameSymbolTrackerService, [], true)
71
74
  };
72
75
  }
73
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-base-service-override",
3
- "version": "25.1.2",
3
+ "version": "26.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - base service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "25.1.2"
18
+ "@codingame/monaco-vscode-api": "26.0.0"
19
19
  },
20
20
  "main": "index.js",
21
21
  "module": "index.js",
@@ -16,8 +16,7 @@ class TotalTrueTimeObservable extends Disposable {
16
16
  const isTrue = this.value.read(reader);
17
17
  if (isTrue) {
18
18
  this._startTime = Date.now();
19
- }
20
- else {
19
+ } else {
21
20
  if (this._startTime !== undefined) {
22
21
  const delta = Date.now() - this._startTime;
23
22
  this._totalTime += delta;
@@ -65,7 +64,7 @@ class TotalTrueTimeObservable extends Disposable {
65
64
  }
66
65
  }
67
66
  function wasTrueRecently(obs, timeMs, store) {
68
- const result = observableValue('wasTrueRecently', false);
67
+ const result = observableValue("wasTrueRecently", false);
69
68
  let timeout;
70
69
  store.add(autorun(reader => {
71
70
  const value = obs.read(reader);
@@ -75,8 +74,7 @@ function wasTrueRecently(obs, timeMs, store) {
75
74
  clearTimeout(timeout);
76
75
  timeout = undefined;
77
76
  }
78
- }
79
- else {
77
+ } else {
80
78
  timeout = setTimeout(() => {
81
79
  result.set(false, undefined);
82
80
  timeout = undefined;
@@ -9,70 +9,68 @@ async function request(options, token, isOnline) {
9
9
  }
10
10
  const cancellation = ( new AbortController());
11
11
  const disposable = token.onCancellationRequested(() => cancellation.abort());
12
- const signal = options.timeout ? AbortSignal.any([
13
- cancellation.signal,
14
- AbortSignal.timeout(options.timeout),
15
- ]) : cancellation.signal;
12
+ const signal = options.timeout ? AbortSignal.any([cancellation.signal, AbortSignal.timeout(options.timeout)]) : cancellation.signal;
16
13
  try {
17
14
  const fetchInit = {
18
- method: options.type || 'GET',
15
+ method: options.type || "GET",
19
16
  headers: getRequestHeaders(options),
20
17
  body: options.data,
21
18
  signal
22
19
  };
23
20
  if (options.disableCache) {
24
- fetchInit.cache = 'no-store';
21
+ fetchInit.cache = "no-store";
25
22
  }
26
- const res = await fetch(options.url || '', fetchInit);
23
+ const res = await fetch(options.url || "", fetchInit);
27
24
  return {
28
25
  res: {
29
26
  statusCode: res.status,
30
- headers: getResponseHeaders(res),
27
+ headers: getResponseHeaders(res)
31
28
  },
32
- stream: bufferToStream(VSBuffer.wrap(( new Uint8Array(await res.arrayBuffer())))),
29
+ stream: bufferToStream(VSBuffer.wrap(( new Uint8Array(await res.arrayBuffer()))))
33
30
  };
34
- }
35
- catch (err) {
31
+ } catch (err) {
36
32
  if (isOnline && !isOnline()) {
37
33
  throw ( new OfflineError());
38
34
  }
39
- if (err?.name === 'AbortError') {
35
+ if (err?.name === "AbortError") {
40
36
  throw canceled();
41
37
  }
42
- if (err?.name === 'TimeoutError') {
38
+ if (err?.name === "TimeoutError") {
43
39
  throw ( new Error(`Fetch timeout: ${options.timeout}ms`));
44
40
  }
45
41
  throw err;
46
- }
47
- finally {
42
+ } finally {
48
43
  disposable.dispose();
49
44
  }
50
45
  }
51
46
  function getRequestHeaders(options) {
52
47
  if (options.headers || options.user || options.password || options.proxyAuthorization) {
53
48
  const headers = ( new Headers());
54
- outer: for (const k in options.headers) {
49
+ outer:
50
+ for (const k in options.headers) {
55
51
  switch (k.toLowerCase()) {
56
- case 'user-agent':
57
- case 'accept-encoding':
58
- case 'content-length':
59
- continue outer;
52
+ case "user-agent":
53
+ case "accept-encoding":
54
+ case "content-length":
55
+ continue outer;
60
56
  }
61
57
  const header = options.headers[k];
62
- if (typeof header === 'string') {
58
+ if (typeof header === "string") {
63
59
  headers.set(k, header);
64
- }
65
- else if (Array.isArray(header)) {
60
+ } else if (Array.isArray(header)) {
66
61
  for (const h of header) {
67
62
  headers.append(k, h);
68
63
  }
69
64
  }
70
65
  }
71
66
  if (options.user || options.password) {
72
- headers.set('Authorization', 'Basic ' + btoa(`${options.user || ''}:${options.password || ''}`));
67
+ headers.set(
68
+ "Authorization",
69
+ "Basic " + btoa(`${options.user || ""}:${options.password || ""}`)
70
+ );
73
71
  }
74
72
  if (options.proxyAuthorization) {
75
- headers.set('Proxy-Authorization', options.proxyAuthorization);
73
+ headers.set("Proxy-Authorization", options.proxyAuthorization);
76
74
  }
77
75
  return headers;
78
76
  }
@@ -84,12 +82,10 @@ function getResponseHeaders(res) {
84
82
  if (headers[key]) {
85
83
  if (Array.isArray(headers[key])) {
86
84
  headers[key].push(value);
87
- }
88
- else {
85
+ } else {
89
86
  headers[key] = [headers[key], value];
90
87
  }
91
- }
92
- else {
88
+ } else {
93
89
  headers[key] = value;
94
90
  }
95
91
  });
@@ -16,20 +16,19 @@ let DownloadService = class DownloadService {
16
16
  await this.fileService.copy(resource, target);
17
17
  return;
18
18
  }
19
- const options = { type: 'GET', url: ( resource.toString(true)) };
19
+ const options = {
20
+ type: "GET",
21
+ url: ( resource.toString(true))
22
+ };
20
23
  const context = await this.requestService.request(options, cancellationToken);
21
24
  if (context.res.statusCode === 200) {
22
25
  await this.fileService.writeFile(target, context.stream);
23
- }
24
- else {
26
+ } else {
25
27
  const message = await asTextOrError(context);
26
28
  throw ( new Error(`Expected 200, got back ${context.res.statusCode} instead.\n\n${message}`));
27
29
  }
28
30
  }
29
31
  };
30
- DownloadService = ( __decorate([
31
- ( __param(0, IRequestService)),
32
- ( __param(1, IFileService))
33
- ], DownloadService));
32
+ DownloadService = ( __decorate([( __param(0, IRequestService)), ( __param(1, IFileService))], DownloadService));
34
33
 
35
34
  export { DownloadService };
@@ -7,20 +7,23 @@ class RequestChannelClient {
7
7
  this.channel = channel;
8
8
  }
9
9
  async request(options, token) {
10
- const [res, buffer] = await this.channel.call('request', [options], token);
11
- return { res, stream: bufferToStream(buffer) };
10
+ const [res, buffer] = await this.channel.call("request", [options], token);
11
+ return {
12
+ res,
13
+ stream: bufferToStream(buffer)
14
+ };
12
15
  }
13
16
  async resolveProxy(url) {
14
- return this.channel.call('resolveProxy', [url]);
17
+ return this.channel.call("resolveProxy", [url]);
15
18
  }
16
19
  async lookupAuthorization(authInfo) {
17
- return this.channel.call('lookupAuthorization', [authInfo]);
20
+ return this.channel.call("lookupAuthorization", [authInfo]);
18
21
  }
19
22
  async lookupKerberosAuthorization(url) {
20
- return this.channel.call('lookupKerberosAuthorization', [url]);
23
+ return this.channel.call("lookupKerberosAuthorization", [url]);
21
24
  }
22
25
  async loadCertificates() {
23
- return this.channel.call('loadCertificates');
26
+ return this.channel.call("loadCertificates");
24
27
  }
25
28
  }
26
29
 
@@ -0,0 +1,18 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
3
+ import { ICodeEditorService } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service";
4
+ import { type ITrackedWord } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/renameSymbolTrackerService";
5
+ import { IRenameSymbolTrackerService } from "@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/renameSymbolTrackerService.service";
6
+ import { IModelService } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service";
7
+ export declare class RenameSymbolTrackerService extends Disposable implements IRenameSymbolTrackerService {
8
+ private readonly _codeEditorService;
9
+ private readonly _modelService;
10
+ _serviceBrand: undefined;
11
+ private readonly _modelTrackers;
12
+ private readonly _editorFocusTrackingDisposables;
13
+ private readonly _focusedModelTracker;
14
+ readonly trackedWord: IObservable<ITrackedWord | undefined>;
15
+ constructor(_codeEditorService: ICodeEditorService, _modelService: IModelService);
16
+ private _setupEditorTracking;
17
+ dispose(): void;
18
+ }
@@ -0,0 +1,240 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
5
+ import { observableCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/observableCodeEditor';
6
+ import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service';
7
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
8
+ import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
9
+ import { StandardTokenType } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/encodedTokenAttributes';
10
+ import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
11
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
12
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
13
+ import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
14
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
15
+
16
+ function isUserEdit(event) {
17
+ if (event.isUndoing || event.isRedoing || event.isFlush) {
18
+ return false;
19
+ }
20
+ for (const source of event.detailedReasons) {
21
+ if (!isUserEditSource(source)) {
22
+ return false;
23
+ }
24
+ }
25
+ return event.detailedReasons.length > 0;
26
+ }
27
+ const userEditKinds = ( new Set([
28
+ "type",
29
+ "paste",
30
+ "cut",
31
+ "executeCommands",
32
+ "executeCommand",
33
+ "compositionType",
34
+ "compositionEnd"
35
+ ]));
36
+ function isUserEditSource(source) {
37
+ const metadata = source.metadata;
38
+ if (metadata.source !== "cursor") {
39
+ return false;
40
+ }
41
+ const kind = metadata.kind;
42
+ return ( userEditKinds.has(kind));
43
+ }
44
+ class ModelSymbolRenameTracker extends Disposable {
45
+ constructor(_model) {
46
+ super();
47
+ this._model = _model;
48
+ this._trackedWord = observableValue(this, undefined);
49
+ this.trackedWord = this._trackedWord;
50
+ this._capturedWord = undefined;
51
+ this._lastWordBeforeEdit = undefined;
52
+ this._pendingContentChange = false;
53
+ this._lastCursorPosition = undefined;
54
+ this._register(this._model.onDidChangeContent(e => {
55
+ if (!isUserEdit(e)) {
56
+ const position = this._lastCursorPosition;
57
+ this.reset();
58
+ if (position !== undefined) {
59
+ this.updateCursorPosition(position);
60
+ }
61
+ return;
62
+ }
63
+ this._pendingContentChange = true;
64
+ }));
65
+ }
66
+ updateCursorPosition(position) {
67
+ this._lastCursorPosition = position;
68
+ const wordAtPosition = this._model.getWordAtPosition(position);
69
+ if (!wordAtPosition) {
70
+ this._lastWordBeforeEdit = undefined;
71
+ this._pendingContentChange = false;
72
+ return;
73
+ }
74
+ if (this._isPositionInComment(position)) {
75
+ this._lastWordBeforeEdit = undefined;
76
+ this._pendingContentChange = false;
77
+ return;
78
+ }
79
+ const currentWord = {
80
+ word: wordAtPosition.word,
81
+ range: ( new Range(
82
+ position.lineNumber,
83
+ wordAtPosition.startColumn,
84
+ position.lineNumber,
85
+ wordAtPosition.endColumn
86
+ )),
87
+ position
88
+ };
89
+ const contentChanged = this._pendingContentChange;
90
+ this._pendingContentChange = false;
91
+ if (!contentChanged) {
92
+ this._lastWordBeforeEdit = currentWord;
93
+ return;
94
+ }
95
+ if (!this._capturedWord) {
96
+ const originalWord = this._lastWordBeforeEdit ?? currentWord;
97
+ this._capturedWord = {
98
+ ...originalWord
99
+ };
100
+ this._trackedWord.set({
101
+ model: this._model,
102
+ originalWord: originalWord.word,
103
+ originalPosition: originalWord.position,
104
+ originalRange: originalWord.range,
105
+ currentWord: currentWord.word,
106
+ currentRange: currentWord.range
107
+ }, undefined);
108
+ this._lastWordBeforeEdit = currentWord;
109
+ return;
110
+ }
111
+ const capturedWord = this._capturedWord;
112
+ const isOnSameWord = this._rangesOverlap(capturedWord.range, currentWord.range) || this._isAdjacent(capturedWord.range, currentWord.range);
113
+ if (isOnSameWord) {
114
+ this._trackedWord.set({
115
+ model: this._model,
116
+ originalWord: capturedWord.word,
117
+ originalPosition: capturedWord.position,
118
+ originalRange: capturedWord.range,
119
+ currentWord: currentWord.word,
120
+ currentRange: currentWord.range
121
+ }, undefined);
122
+ } else {
123
+ const originalWord = this._lastWordBeforeEdit ?? currentWord;
124
+ this._capturedWord = {
125
+ ...originalWord
126
+ };
127
+ this._trackedWord.set({
128
+ model: this._model,
129
+ originalWord: originalWord.word,
130
+ originalPosition: originalWord.position,
131
+ originalRange: originalWord.range,
132
+ currentWord: currentWord.word,
133
+ currentRange: currentWord.range
134
+ }, undefined);
135
+ }
136
+ this._lastWordBeforeEdit = currentWord;
137
+ }
138
+ reset() {
139
+ this._trackedWord.set(undefined, undefined);
140
+ this._capturedWord = undefined;
141
+ this._lastWordBeforeEdit = undefined;
142
+ this._pendingContentChange = false;
143
+ this._lastCursorPosition = undefined;
144
+ }
145
+ _isPositionInComment(position) {
146
+ this._model.tokenization.tokenizeIfCheap(position.lineNumber);
147
+ const tokens = this._model.tokenization.getLineTokens(position.lineNumber);
148
+ const tokenIndex = tokens.findTokenIndexAtOffset(position.column - 1);
149
+ const tokenType = tokens.getStandardTokenType(tokenIndex);
150
+ return tokenType === StandardTokenType.Comment;
151
+ }
152
+ _rangesOverlap(a, b) {
153
+ if (a.startLineNumber !== b.startLineNumber) {
154
+ return false;
155
+ }
156
+ return !(a.endColumn < b.startColumn || b.endColumn < a.startColumn);
157
+ }
158
+ _isAdjacent(a, b) {
159
+ if (a.startLineNumber !== b.startLineNumber) {
160
+ return false;
161
+ }
162
+ return a.endColumn === b.startColumn || b.endColumn === a.startColumn;
163
+ }
164
+ }
165
+ let RenameSymbolTrackerService = class RenameSymbolTrackerService extends Disposable {
166
+ constructor(_codeEditorService, _modelService) {
167
+ super();
168
+ this._codeEditorService = _codeEditorService;
169
+ this._modelService = _modelService;
170
+ this._modelTrackers = ( new Map());
171
+ this._editorFocusTrackingDisposables = ( new Map());
172
+ this._focusedModelTracker = observableValue(this, undefined);
173
+ this.trackedWord = derived(this, reader => {
174
+ const tracker = this._focusedModelTracker.read(reader);
175
+ return tracker?.trackedWord.read(reader);
176
+ });
177
+ for (const editor of this._codeEditorService.listCodeEditors()) {
178
+ this._setupEditorTracking(editor);
179
+ }
180
+ this._register(this._codeEditorService.onCodeEditorAdd(editor => {
181
+ this._setupEditorTracking(editor);
182
+ }));
183
+ this._register(this._codeEditorService.onCodeEditorRemove(editor => {
184
+ const focusDisposable = this._editorFocusTrackingDisposables.get(editor);
185
+ if (focusDisposable) {
186
+ focusDisposable.dispose();
187
+ this._editorFocusTrackingDisposables.delete(editor);
188
+ }
189
+ }));
190
+ this._register(this._modelService.onModelRemoved(model => {
191
+ const tracker = this._modelTrackers.get(model);
192
+ if (tracker) {
193
+ tracker.dispose();
194
+ this._modelTrackers.delete(model);
195
+ }
196
+ }));
197
+ }
198
+ _setupEditorTracking(editor) {
199
+ if (editor.isSimpleWidget) {
200
+ return;
201
+ }
202
+ if (!( this._editorFocusTrackingDisposables.has(editor))) {
203
+ const obsEditor = observableCodeEditor(editor);
204
+ const focusDisposable = autorun(reader => {
205
+ const isFocused = obsEditor.isFocused.read(reader);
206
+ const model = obsEditor.model.read(reader);
207
+ const cursorPosition = obsEditor.cursorPosition.read(reader);
208
+ if (!isFocused || !model) {
209
+ return;
210
+ }
211
+ let tracker = this._modelTrackers.get(model);
212
+ if (!tracker) {
213
+ tracker = ( new ModelSymbolRenameTracker(model));
214
+ this._modelTrackers.set(model, tracker);
215
+ }
216
+ if (this._focusedModelTracker.read(undefined) !== tracker) {
217
+ this._focusedModelTracker.set(tracker, undefined);
218
+ }
219
+ if (cursorPosition) {
220
+ tracker.updateCursorPosition(cursorPosition);
221
+ }
222
+ });
223
+ this._editorFocusTrackingDisposables.set(editor, focusDisposable);
224
+ }
225
+ }
226
+ dispose() {
227
+ for (const tracker of ( this._modelTrackers.values())) {
228
+ tracker.dispose();
229
+ }
230
+ this._modelTrackers.clear();
231
+ for (const disposable of ( this._editorFocusTrackingDisposables.values())) {
232
+ disposable.dispose();
233
+ }
234
+ this._editorFocusTrackingDisposables.clear();
235
+ super.dispose();
236
+ }
237
+ };
238
+ RenameSymbolTrackerService = ( __decorate([( __param(0, ICodeEditorService)), ( __param(1, IModelService))], RenameSymbolTrackerService));
239
+
240
+ export { RenameSymbolTrackerService };
@@ -16,7 +16,12 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/ext
16
16
  import { IFilesConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
17
17
 
18
18
  let JSONEditingService = class JSONEditingService {
19
- constructor(fileService, textModelResolverService, textFileService, filesConfigurationService) {
19
+ constructor(
20
+ fileService,
21
+ textModelResolverService,
22
+ textFileService,
23
+ filesConfigurationService
24
+ ) {
20
25
  this.fileService = fileService;
21
26
  this.textModelResolverService = textModelResolverService;
22
27
  this.textFileService = textFileService;
@@ -30,8 +35,7 @@ let JSONEditingService = class JSONEditingService {
30
35
  const reference = await this.resolveAndValidate(resource, true);
31
36
  try {
32
37
  await this.writeToBuffer(reference.object.textEditorModel, values);
33
- }
34
- finally {
38
+ } finally {
35
39
  reference.dispose();
36
40
  }
37
41
  }
@@ -47,8 +51,7 @@ let JSONEditingService = class JSONEditingService {
47
51
  if (hasEdits) {
48
52
  return this.textFileService.save(model.uri);
49
53
  }
50
- }
51
- finally {
54
+ } finally {
52
55
  disposable?.dispose();
53
56
  }
54
57
  return undefined;
@@ -76,29 +79,44 @@ let JSONEditingService = class JSONEditingService {
76
79
  return false;
77
80
  }
78
81
  getEdits(model, configurationValue) {
79
- const { tabSize, insertSpaces } = model.getOptions();
82
+ const {
83
+ tabSize,
84
+ insertSpaces
85
+ } = model.getOptions();
80
86
  const eol = model.getEOL();
81
- const { path, value } = configurationValue;
87
+ const {
88
+ path,
89
+ value
90
+ } = configurationValue;
82
91
  if (!path.length) {
83
- const content = JSON.stringify(value, null, insertSpaces ? ' '.repeat(tabSize) : '\t');
92
+ const content = JSON.stringify(value, null, insertSpaces ? " ".repeat(tabSize) : "\t");
84
93
  return [{
85
- content,
86
- length: content.length,
87
- offset: 0
88
- }];
94
+ content,
95
+ length: content.length,
96
+ offset: 0
97
+ }];
89
98
  }
90
- return setProperty(model.getValue(), path, value, { tabSize, insertSpaces, eol });
99
+ return setProperty(model.getValue(), path, value, {
100
+ tabSize,
101
+ insertSpaces,
102
+ eol
103
+ });
91
104
  }
92
105
  async resolveModelReference(resource) {
93
106
  const exists = await this.fileService.exists(resource);
94
107
  if (!exists) {
95
- await this.textFileService.write(resource, '{}', { encoding: 'utf8' });
108
+ await this.textFileService.write(resource, "{}", {
109
+ encoding: "utf8"
110
+ });
96
111
  }
97
112
  return this.textModelResolverService.createModelReference(resource);
98
113
  }
99
114
  hasParseErrors(model) {
100
115
  const parseErrors = [];
101
- parse(model.getValue(), parseErrors, { allowTrailingComma: true, allowEmptyContent: true });
116
+ parse(model.getValue(), parseErrors, {
117
+ allowTrailingComma: true,
118
+ allowEmptyContent: true
119
+ });
102
120
  return parseErrors.length > 0;
103
121
  }
104
122
  async resolveAndValidate(resource, checkDirty) {
@@ -116,20 +134,16 @@ let JSONEditingService = class JSONEditingService {
116
134
  }
117
135
  toErrorMessage(error) {
118
136
  switch (error) {
119
- case JSONEditingErrorCode.ERROR_INVALID_FILE: {
137
+ case JSONEditingErrorCode.ERROR_INVALID_FILE:
138
+ {
120
139
  return localize(
121
- 13800,
140
+ 14187,
122
141
  "Unable to write into the file. Please open the file to correct errors/warnings in the file and try again."
123
142
  );
124
143
  }
125
144
  }
126
145
  }
127
146
  };
128
- JSONEditingService = ( __decorate([
129
- ( __param(0, IFileService)),
130
- ( __param(1, ITextModelService)),
131
- ( __param(2, ITextFileService)),
132
- ( __param(3, IFilesConfigurationService))
133
- ], JSONEditingService));
147
+ JSONEditingService = ( __decorate([( __param(0, IFileService)), ( __param(1, ITextModelService)), ( __param(2, ITextFileService)), ( __param(3, IFilesConfigurationService))], JSONEditingService));
134
148
 
135
149
  export { JSONEditingService };