@codingame/monaco-vscode-api 1.85.1 → 1.85.3
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 +18 -5
- package/missing-services.js +324 -64
- package/monaco-editor-treemending.patch +946 -946
- package/package.json +8 -7
- package/service-override/tools/editor.js +1 -1
- package/services.js +10 -6
- package/vscode/src/vs/base/browser/ui/tree/treeDefaults.js +14 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionEnablementService.js +140 -0
- package/vscode/src/vs/platform/extensions/common/extensions.d.ts +1062 -93
- package/vscode/src/vs/platform/files/common/inMemoryFilesystemProvider.js +220 -0
- package/vscode/src/vs/platform/quickinput/browser/quickPickPin.js +102 -0
- package/vscode/src/vs/platform/userDataSync/common/content.js +9 -0
- package/vscode/src/vs/platform/userDataSync/common/settingsMerge.js +514 -0
- package/vscode/src/vs/platform/userDataSync/common/userDataSync.js +154 -2
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncAccount.js +43 -1
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncMachines.js +177 -0
- package/vscode/src/vs/platform/workspace/common/virtualWorkspace.js +4 -1
- package/vscode/src/vs/workbench/api/common/extHostApiCommands.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTypeConverters.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostWebview.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/views/checkbox.js +105 -0
- package/vscode/src/vs/workbench/browser/parts/views/media/views.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/views/treeView.js +1614 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.js +7 -7
- package/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.js +73 -2
- package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +6 -6
- package/vscode/src/vs/workbench/contrib/tasks/common/taskService.js +12 -2
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +712 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +130 -0
- package/vscode/src/vs/workbench/contrib/timeline/common/timeline.js +2 -1
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +20 -1
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverSchema.js +205 -0
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverUtils.js +11 -0
- package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +9 -9
- package/vscode/src/vs/workbench/services/extensionManagement/browser/extensionBisect.js +1 -1
- package/vscode/src/vs/workbench/services/keybinding/common/keybindingEditing.js +2 -2
- package/vscode/src/vs/workbench/services/languageStatus/common/languageStatusService.js +24 -1
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorInput.js +41 -0
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorModel.js +588 -0
- package/vscode/src/vs/workbench/services/preferences/common/preferencesEditorInput.js +43 -0
- package/vscode/src/vs/workbench/services/search/common/search.js +3 -3
- package/vscode/src/vs/workbench/services/terminal/common/embedderTerminalService.js +75 -1
- package/vscode/src/vs/workbench/services/timer/browser/timerService.js +240 -1
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +31 -1
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +25 -1
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfileIcons.js +75 -1
- package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +74 -4
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +708 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyHistory.js +4 -0
- package/vscode/src/vs/base/parts/request/browser/request.js +0 -60
- package/vscode/src/vs/platform/request/browser/requestService.js +0 -28
- package/vscode/src/vs/platform/request/common/requestIpc.js +0 -17
- package/vscode/src/vs/platform/url/common/urlService.js +0 -17
- package/vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js +0 -120
- package/vscode/src/vs/workbench/services/decorations/browser/decorationsService.js +0 -319
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +0 -9
- package/vscode/src/vs/workbench/services/host/browser/browserHostService.js +0 -408
- package/vscode/src/vs/workbench/services/request/browser/requestService.js +0 -48
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +0 -56
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +0 -639
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +0 -402
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +0 -62
- package/vscode/src/vs/workbench/services/themes/browser/browserHostColorSchemeService.js +0 -38
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +0 -295
- package/vscode/src/vs/workbench/services/url/browser/urlService.js +0 -47
- package/vscode/src/vs/workbench/services/views/common/treeViewsService.js +0 -20
- package/vscode/src/vs/workbench/services/workspaces/common/canonicalUriService.js +0 -19
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
-
import { TextFileOperationError, toBufferOrReadable, stringToSnapshot } from '../common/textfiles.js';
|
|
4
|
-
import { SaveSourceRegistry } from '../../../common/editor.js';
|
|
5
|
-
import { ILifecycleService } from '../../lifecycle/common/lifecycle.js';
|
|
6
|
-
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
7
|
-
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
8
|
-
import { extname } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
9
|
-
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
|
|
10
|
-
import { IUntitledTextEditorService } from '../../untitled/common/untitledTextEditorService.js';
|
|
11
|
-
import { UntitledTextEditorModel } from '../../untitled/common/untitledTextEditorModel.js';
|
|
12
|
-
import { TextFileEditorModelManager } from '../common/textFileEditorModelManager.js';
|
|
13
|
-
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
14
|
-
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
15
|
-
import { createTextBufferFactoryFromStream, createTextBufferFactoryFromSnapshot } from 'monaco-editor/esm/vs/editor/common/model/textModel.js';
|
|
16
|
-
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
17
|
-
import { isEqual, toLocalResource, basename, dirname, joinPath, extname as extname$1 } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
18
|
-
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
19
|
-
import { bufferToStream } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
20
|
-
import { ITextResourceConfigurationService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
|
|
21
|
-
import { PLAINTEXT_LANGUAGE_ID } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
22
|
-
import { IFilesConfigurationService } from '../../filesConfiguration/common/filesConfigurationService.js';
|
|
23
|
-
import { BaseTextEditorModel } from '../../../common/editor/textEditorModel.js';
|
|
24
|
-
import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
25
|
-
import { IPathService } from '../../path/common/pathService.js';
|
|
26
|
-
import { IWorkingCopyFileService } from '../../workingCopy/common/workingCopyFileService.js';
|
|
27
|
-
import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
|
|
28
|
-
import { WORKSPACE_EXTENSION, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
29
|
-
import { UTF8, toEncodeReadable, toDecodeStream, UTF16be, UTF16le, UTF8_with_bom, encodingExists } from '../common/encoding.js';
|
|
30
|
-
import { consumeStream } from 'monaco-editor/esm/vs/base/common/stream.js';
|
|
31
|
-
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
32
|
-
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
33
|
-
import { CancellationToken, CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
34
|
-
import { IElevatedFileService } from '../../files/common/elevatedFileService.js';
|
|
35
|
-
import { IDecorationsService } from '../../decorations/common/decorations.js';
|
|
36
|
-
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
37
|
-
import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
|
|
38
|
-
import { listErrorForeground } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
39
|
-
import { firstOrDefault } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
40
|
-
import { IDialogService, IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js';
|
|
41
|
-
var AbstractTextFileService_1;
|
|
42
|
-
let AbstractTextFileService = class AbstractTextFileService extends Disposable {
|
|
43
|
-
static { AbstractTextFileService_1 = this; }
|
|
44
|
-
static { this.TEXTFILE_SAVE_CREATE_SOURCE = SaveSourceRegistry.registerSource('textFileCreate.source', ( localizeWithPath(
|
|
45
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
46
|
-
'textFileCreate.source',
|
|
47
|
-
"File Created"
|
|
48
|
-
))); }
|
|
49
|
-
static { this.TEXTFILE_SAVE_REPLACE_SOURCE = SaveSourceRegistry.registerSource('textFileOverwrite.source', ( localizeWithPath(
|
|
50
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
51
|
-
'textFileOverwrite.source',
|
|
52
|
-
"File Replaced"
|
|
53
|
-
))); }
|
|
54
|
-
constructor(fileService, untitledTextEditorService, lifecycleService, instantiationService, modelService, environmentService, dialogService, fileDialogService, textResourceConfigurationService, filesConfigurationService, codeEditorService, pathService, workingCopyFileService, uriIdentityService, languageService, logService, elevatedFileService, decorationsService) {
|
|
55
|
-
super();
|
|
56
|
-
this.fileService = fileService;
|
|
57
|
-
this.untitledTextEditorService = untitledTextEditorService;
|
|
58
|
-
this.lifecycleService = lifecycleService;
|
|
59
|
-
this.instantiationService = instantiationService;
|
|
60
|
-
this.modelService = modelService;
|
|
61
|
-
this.environmentService = environmentService;
|
|
62
|
-
this.dialogService = dialogService;
|
|
63
|
-
this.fileDialogService = fileDialogService;
|
|
64
|
-
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
65
|
-
this.filesConfigurationService = filesConfigurationService;
|
|
66
|
-
this.codeEditorService = codeEditorService;
|
|
67
|
-
this.pathService = pathService;
|
|
68
|
-
this.workingCopyFileService = workingCopyFileService;
|
|
69
|
-
this.uriIdentityService = uriIdentityService;
|
|
70
|
-
this.languageService = languageService;
|
|
71
|
-
this.logService = logService;
|
|
72
|
-
this.elevatedFileService = elevatedFileService;
|
|
73
|
-
this.decorationsService = decorationsService;
|
|
74
|
-
this.files = this._register(this.instantiationService.createInstance(TextFileEditorModelManager));
|
|
75
|
-
this.untitled = this.untitledTextEditorService;
|
|
76
|
-
this.provideDecorations();
|
|
77
|
-
}
|
|
78
|
-
provideDecorations() {
|
|
79
|
-
const provider = this._register(new (class extends Disposable {
|
|
80
|
-
constructor(files) {
|
|
81
|
-
super();
|
|
82
|
-
this.files = files;
|
|
83
|
-
this.label = ( localizeWithPath(
|
|
84
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
85
|
-
'textFileModelDecorations',
|
|
86
|
-
"Text File Model Decorations"
|
|
87
|
-
));
|
|
88
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
89
|
-
this.onDidChange = this._onDidChange.event;
|
|
90
|
-
this.registerListeners();
|
|
91
|
-
}
|
|
92
|
-
registerListeners() {
|
|
93
|
-
this._register(this.files.onDidResolve(({ model }) => {
|
|
94
|
-
if (model.isReadonly() || model.hasState(4 )) {
|
|
95
|
-
this._onDidChange.fire([model.resource]);
|
|
96
|
-
}
|
|
97
|
-
}));
|
|
98
|
-
this._register(this.files.onDidRemove(modelUri => this._onDidChange.fire([modelUri])));
|
|
99
|
-
this._register(this.files.onDidChangeReadonly(model => this._onDidChange.fire([model.resource])));
|
|
100
|
-
this._register(this.files.onDidChangeOrphaned(model => this._onDidChange.fire([model.resource])));
|
|
101
|
-
}
|
|
102
|
-
provideDecorations(uri) {
|
|
103
|
-
const model = this.files.get(uri);
|
|
104
|
-
if (!model || model.isDisposed()) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
const isReadonly = model.isReadonly();
|
|
108
|
-
const isOrphaned = model.hasState(4 );
|
|
109
|
-
if (isReadonly && isOrphaned) {
|
|
110
|
-
return {
|
|
111
|
-
color: listErrorForeground,
|
|
112
|
-
letter: Codicon.lockSmall,
|
|
113
|
-
strikethrough: true,
|
|
114
|
-
tooltip: ( localizeWithPath(
|
|
115
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
116
|
-
'readonlyAndDeleted',
|
|
117
|
-
"Deleted, Read-only"
|
|
118
|
-
)),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
else if (isReadonly) {
|
|
122
|
-
return {
|
|
123
|
-
letter: Codicon.lockSmall,
|
|
124
|
-
tooltip: ( localizeWithPath(
|
|
125
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
126
|
-
'readonly',
|
|
127
|
-
"Read-only"
|
|
128
|
-
)),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
else if (isOrphaned) {
|
|
132
|
-
return {
|
|
133
|
-
color: listErrorForeground,
|
|
134
|
-
strikethrough: true,
|
|
135
|
-
tooltip: ( localizeWithPath(
|
|
136
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
137
|
-
'deleted',
|
|
138
|
-
"Deleted"
|
|
139
|
-
)),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
return undefined;
|
|
143
|
-
}
|
|
144
|
-
})(this.files));
|
|
145
|
-
this._register(this.decorationsService.registerDecorationsProvider(provider));
|
|
146
|
-
}
|
|
147
|
-
get encoding() {
|
|
148
|
-
if (!this._encoding) {
|
|
149
|
-
this._encoding = this._register(this.instantiationService.createInstance(EncodingOracle));
|
|
150
|
-
}
|
|
151
|
-
return this._encoding;
|
|
152
|
-
}
|
|
153
|
-
async read(resource, options) {
|
|
154
|
-
const [bufferStream, decoder] = await this.doRead(resource, {
|
|
155
|
-
...options,
|
|
156
|
-
preferUnbuffered: true
|
|
157
|
-
});
|
|
158
|
-
return {
|
|
159
|
-
...bufferStream,
|
|
160
|
-
encoding: decoder.detected.encoding || UTF8,
|
|
161
|
-
value: await consumeStream(decoder.stream, strings => strings.join(''))
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
async readStream(resource, options) {
|
|
165
|
-
const [bufferStream, decoder] = await this.doRead(resource, options);
|
|
166
|
-
return {
|
|
167
|
-
...bufferStream,
|
|
168
|
-
encoding: decoder.detected.encoding || UTF8,
|
|
169
|
-
value: await createTextBufferFactoryFromStream(decoder.stream)
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async doRead(resource, options) {
|
|
173
|
-
const cts = ( new CancellationTokenSource());
|
|
174
|
-
let bufferStream;
|
|
175
|
-
if (options?.preferUnbuffered) {
|
|
176
|
-
const content = await this.fileService.readFile(resource, options, cts.token);
|
|
177
|
-
bufferStream = {
|
|
178
|
-
...content,
|
|
179
|
-
value: bufferToStream(content.value)
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
bufferStream = await this.fileService.readFileStream(resource, options, cts.token);
|
|
184
|
-
}
|
|
185
|
-
try {
|
|
186
|
-
const decoder = await this.doGetDecodedStream(resource, bufferStream.value, options);
|
|
187
|
-
return [bufferStream, decoder];
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
cts.dispose(true);
|
|
191
|
-
if (error.decodeStreamErrorKind === 1 ) {
|
|
192
|
-
throw new TextFileOperationError(localizeWithPath('vs/workbench/services/textfile/browser/textFileService', 'fileBinaryError', "File seems to be binary and cannot be opened as text"), 0 , options);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async create(operations, undoInfo) {
|
|
200
|
-
const operationsWithContents = await Promise.all(( operations.map(async (operation) => {
|
|
201
|
-
const contents = await this.getEncodedReadable(operation.resource, operation.value);
|
|
202
|
-
return {
|
|
203
|
-
resource: operation.resource,
|
|
204
|
-
contents,
|
|
205
|
-
overwrite: operation.options?.overwrite
|
|
206
|
-
};
|
|
207
|
-
})));
|
|
208
|
-
return this.workingCopyFileService.create(operationsWithContents, CancellationToken.None, undoInfo);
|
|
209
|
-
}
|
|
210
|
-
async write(resource, value, options) {
|
|
211
|
-
const readable = await this.getEncodedReadable(resource, value, options);
|
|
212
|
-
if (options?.writeElevated && this.elevatedFileService.isSupported(resource)) {
|
|
213
|
-
return this.elevatedFileService.writeFileElevated(resource, readable, options);
|
|
214
|
-
}
|
|
215
|
-
return this.fileService.writeFile(resource, readable, options);
|
|
216
|
-
}
|
|
217
|
-
async getEncodedReadable(resource, value, options) {
|
|
218
|
-
const { encoding, addBOM } = await this.encoding.getWriteEncoding(resource, options);
|
|
219
|
-
if (encoding === UTF8 && !addBOM) {
|
|
220
|
-
return typeof value === 'undefined'
|
|
221
|
-
? undefined
|
|
222
|
-
: toBufferOrReadable(value);
|
|
223
|
-
}
|
|
224
|
-
value = value || '';
|
|
225
|
-
const snapshot = typeof value === 'string' ? stringToSnapshot(value) : value;
|
|
226
|
-
return toEncodeReadable(snapshot, encoding, { addBOM });
|
|
227
|
-
}
|
|
228
|
-
async getDecodedStream(resource, value, options) {
|
|
229
|
-
return (await this.doGetDecodedStream(resource, value, options)).stream;
|
|
230
|
-
}
|
|
231
|
-
doGetDecodedStream(resource, stream, options) {
|
|
232
|
-
return toDecodeStream(stream, {
|
|
233
|
-
acceptTextOnly: options?.acceptTextOnly ?? false,
|
|
234
|
-
guessEncoding: options?.autoGuessEncoding || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'),
|
|
235
|
-
overwriteEncoding: async (detectedEncoding) => {
|
|
236
|
-
const { encoding } = await this.encoding.getPreferredReadEncoding(resource, options, detectedEncoding ?? undefined);
|
|
237
|
-
return encoding;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
async save(resource, options) {
|
|
242
|
-
if (resource.scheme === Schemas.untitled) {
|
|
243
|
-
const model = this.untitled.get(resource);
|
|
244
|
-
if (model) {
|
|
245
|
-
let targetUri;
|
|
246
|
-
if (model.hasAssociatedFilePath) {
|
|
247
|
-
targetUri = await this.suggestSavePath(resource);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
targetUri = await this.fileDialogService.pickFileToSave(await this.suggestSavePath(resource), options?.availableFileSystems);
|
|
251
|
-
}
|
|
252
|
-
if (targetUri) {
|
|
253
|
-
return this.saveAs(resource, targetUri, options);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
const model = this.files.get(resource);
|
|
259
|
-
if (model) {
|
|
260
|
-
return (await model.save(options)) ? resource : undefined;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
async saveAs(source, target, options) {
|
|
266
|
-
if (!target) {
|
|
267
|
-
target = await this.fileDialogService.pickFileToSave(await this.suggestSavePath(options?.suggestedTarget ?? source), options?.availableFileSystems);
|
|
268
|
-
}
|
|
269
|
-
if (!target) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
if (this.filesConfigurationService.isReadonly(target)) {
|
|
273
|
-
const confirmed = await this.confirmMakeWriteable(target);
|
|
274
|
-
if (!confirmed) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
this.filesConfigurationService.updateReadonly(target, false);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (isEqual(source, target)) {
|
|
282
|
-
return this.save(source, { ...options, force: true });
|
|
283
|
-
}
|
|
284
|
-
if (this.fileService.hasProvider(source) && this.uriIdentityService.extUri.isEqual(source, target) && (await this.fileService.exists(source))) {
|
|
285
|
-
await this.workingCopyFileService.move([{ file: { source, target } }], CancellationToken.None);
|
|
286
|
-
const success = await this.save(source, options);
|
|
287
|
-
if (!success) {
|
|
288
|
-
await this.save(target, options);
|
|
289
|
-
}
|
|
290
|
-
return target;
|
|
291
|
-
}
|
|
292
|
-
return this.doSaveAs(source, target, options);
|
|
293
|
-
}
|
|
294
|
-
async doSaveAs(source, target, options) {
|
|
295
|
-
let success = false;
|
|
296
|
-
const textFileModel = this.files.get(source);
|
|
297
|
-
if (textFileModel?.isResolved()) {
|
|
298
|
-
success = await this.doSaveAsTextFile(textFileModel, source, target, options);
|
|
299
|
-
}
|
|
300
|
-
else if (this.fileService.hasProvider(source)) {
|
|
301
|
-
await this.fileService.copy(source, target, true);
|
|
302
|
-
success = true;
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
const textModel = this.modelService.getModel(source);
|
|
306
|
-
if (textModel) {
|
|
307
|
-
success = await this.doSaveAsTextFile(textModel, source, target, options);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
if (!success) {
|
|
311
|
-
return undefined;
|
|
312
|
-
}
|
|
313
|
-
try {
|
|
314
|
-
await this.revert(source);
|
|
315
|
-
}
|
|
316
|
-
catch (error) {
|
|
317
|
-
this.logService.error(error);
|
|
318
|
-
}
|
|
319
|
-
return target;
|
|
320
|
-
}
|
|
321
|
-
async doSaveAsTextFile(sourceModel, source, target, options) {
|
|
322
|
-
let sourceModelEncoding = undefined;
|
|
323
|
-
const sourceModelWithEncodingSupport = sourceModel;
|
|
324
|
-
if (typeof sourceModelWithEncodingSupport.getEncoding === 'function') {
|
|
325
|
-
sourceModelEncoding = sourceModelWithEncodingSupport.getEncoding();
|
|
326
|
-
}
|
|
327
|
-
let targetExists = false;
|
|
328
|
-
let targetModel = this.files.get(target);
|
|
329
|
-
if (targetModel?.isResolved()) {
|
|
330
|
-
targetExists = true;
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
targetExists = await this.fileService.exists(target);
|
|
334
|
-
if (!targetExists) {
|
|
335
|
-
await this.create([{ resource: target, value: '' }]);
|
|
336
|
-
}
|
|
337
|
-
try {
|
|
338
|
-
targetModel = await this.files.resolve(target, { encoding: sourceModelEncoding });
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
if (targetExists) {
|
|
342
|
-
if (error.textFileOperationResult === 0 ||
|
|
343
|
-
error.fileOperationResult === 7 ) {
|
|
344
|
-
await this.fileService.del(target);
|
|
345
|
-
return this.doSaveAsTextFile(sourceModel, source, target, options);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
throw error;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
let write;
|
|
352
|
-
if (sourceModel instanceof UntitledTextEditorModel && sourceModel.hasAssociatedFilePath && targetExists && this.uriIdentityService.extUri.isEqual(target, toLocalResource(sourceModel.resource, this.environmentService.remoteAuthority, this.pathService.defaultUriScheme))) {
|
|
353
|
-
write = await this.confirmOverwrite(target);
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
write = true;
|
|
357
|
-
}
|
|
358
|
-
if (!write) {
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
let sourceTextModel = undefined;
|
|
362
|
-
if (sourceModel instanceof BaseTextEditorModel) {
|
|
363
|
-
if (sourceModel.isResolved()) {
|
|
364
|
-
sourceTextModel = sourceModel.textEditorModel ?? undefined;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
368
|
-
sourceTextModel = sourceModel;
|
|
369
|
-
}
|
|
370
|
-
let targetTextModel = undefined;
|
|
371
|
-
if (targetModel.isResolved()) {
|
|
372
|
-
targetTextModel = targetModel.textEditorModel;
|
|
373
|
-
}
|
|
374
|
-
if (sourceTextModel && targetTextModel) {
|
|
375
|
-
targetModel.updatePreferredEncoding(sourceModelEncoding);
|
|
376
|
-
this.modelService.updateModel(targetTextModel, createTextBufferFactoryFromSnapshot(sourceTextModel.createSnapshot()));
|
|
377
|
-
const sourceLanguageId = sourceTextModel.getLanguageId();
|
|
378
|
-
const targetLanguageId = targetTextModel.getLanguageId();
|
|
379
|
-
if (sourceLanguageId !== PLAINTEXT_LANGUAGE_ID && targetLanguageId === PLAINTEXT_LANGUAGE_ID) {
|
|
380
|
-
targetTextModel.setLanguage(sourceLanguageId);
|
|
381
|
-
}
|
|
382
|
-
const sourceTransientProperties = this.codeEditorService.getTransientModelProperties(sourceTextModel);
|
|
383
|
-
if (sourceTransientProperties) {
|
|
384
|
-
for (const [key, value] of sourceTransientProperties) {
|
|
385
|
-
this.codeEditorService.setTransientModelProperty(targetTextModel, key, value);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
if (!options?.source) {
|
|
390
|
-
options = {
|
|
391
|
-
...options,
|
|
392
|
-
source: targetExists ? AbstractTextFileService_1.TEXTFILE_SAVE_REPLACE_SOURCE : AbstractTextFileService_1.TEXTFILE_SAVE_CREATE_SOURCE
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
return targetModel.save(options);
|
|
396
|
-
}
|
|
397
|
-
async confirmOverwrite(resource) {
|
|
398
|
-
const { confirmed } = await this.dialogService.confirm({
|
|
399
|
-
type: 'warning',
|
|
400
|
-
message: ( localizeWithPath(
|
|
401
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
402
|
-
'confirmOverwrite',
|
|
403
|
-
"'{0}' already exists. Do you want to replace it?",
|
|
404
|
-
basename(resource)
|
|
405
|
-
)),
|
|
406
|
-
detail: ( localizeWithPath(
|
|
407
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
408
|
-
'overwriteIrreversible',
|
|
409
|
-
"A file or folder with the name '{0}' already exists in the folder '{1}'. Replacing it will overwrite its current contents.",
|
|
410
|
-
basename(resource),
|
|
411
|
-
basename(dirname(resource))
|
|
412
|
-
)),
|
|
413
|
-
primaryButton: ( localizeWithPath(
|
|
414
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
415
|
-
{ key: 'replaceButtonLabel', comment: ['&& denotes a mnemonic'] },
|
|
416
|
-
"&&Replace"
|
|
417
|
-
)),
|
|
418
|
-
});
|
|
419
|
-
return confirmed;
|
|
420
|
-
}
|
|
421
|
-
async confirmMakeWriteable(resource) {
|
|
422
|
-
const { confirmed } = await this.dialogService.confirm({
|
|
423
|
-
type: 'warning',
|
|
424
|
-
message: ( localizeWithPath(
|
|
425
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
426
|
-
'confirmMakeWriteable',
|
|
427
|
-
"'{0}' is marked as read-only. Do you want to save anyway?",
|
|
428
|
-
basename(resource)
|
|
429
|
-
)),
|
|
430
|
-
detail: ( localizeWithPath(
|
|
431
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
432
|
-
'confirmMakeWriteableDetail',
|
|
433
|
-
"Paths can be configured as read-only via settings."
|
|
434
|
-
)),
|
|
435
|
-
primaryButton: ( localizeWithPath(
|
|
436
|
-
'vs/workbench/services/textfile/browser/textFileService',
|
|
437
|
-
{ key: 'makeWriteableButtonLabel', comment: ['&& denotes a mnemonic'] },
|
|
438
|
-
"&&Save Anyway"
|
|
439
|
-
))
|
|
440
|
-
});
|
|
441
|
-
return confirmed;
|
|
442
|
-
}
|
|
443
|
-
async suggestSavePath(resource) {
|
|
444
|
-
if (this.fileService.hasProvider(resource)) {
|
|
445
|
-
return resource;
|
|
446
|
-
}
|
|
447
|
-
const remoteAuthority = this.environmentService.remoteAuthority;
|
|
448
|
-
const defaultFilePath = await this.fileDialogService.defaultFilePath();
|
|
449
|
-
let suggestedFilename = undefined;
|
|
450
|
-
if (resource.scheme === Schemas.untitled) {
|
|
451
|
-
const model = this.untitled.get(resource);
|
|
452
|
-
if (model) {
|
|
453
|
-
if (model.hasAssociatedFilePath) {
|
|
454
|
-
return toLocalResource(resource, remoteAuthority, this.pathService.defaultUriScheme);
|
|
455
|
-
}
|
|
456
|
-
let nameCandidate;
|
|
457
|
-
if (await this.pathService.hasValidBasename(joinPath(defaultFilePath, model.name), model.name)) {
|
|
458
|
-
nameCandidate = model.name;
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
nameCandidate = basename(resource);
|
|
462
|
-
}
|
|
463
|
-
const languageId = model.getLanguageId();
|
|
464
|
-
if (languageId && languageId !== PLAINTEXT_LANGUAGE_ID) {
|
|
465
|
-
suggestedFilename = this.suggestFilename(languageId, nameCandidate);
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
suggestedFilename = nameCandidate;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
if (!suggestedFilename) {
|
|
473
|
-
suggestedFilename = basename(resource);
|
|
474
|
-
}
|
|
475
|
-
return joinPath(defaultFilePath, suggestedFilename);
|
|
476
|
-
}
|
|
477
|
-
suggestFilename(languageId, untitledName) {
|
|
478
|
-
const languageName = this.languageService.getLanguageName(languageId);
|
|
479
|
-
if (!languageName) {
|
|
480
|
-
return untitledName;
|
|
481
|
-
}
|
|
482
|
-
const untitledExtension = extname(untitledName);
|
|
483
|
-
const extensions = this.languageService.getExtensions(languageId);
|
|
484
|
-
if (extensions.includes(untitledExtension)) {
|
|
485
|
-
return untitledName;
|
|
486
|
-
}
|
|
487
|
-
const primaryExtension = firstOrDefault(extensions);
|
|
488
|
-
if (primaryExtension) {
|
|
489
|
-
if (untitledExtension) {
|
|
490
|
-
return `${untitledName.substring(0, untitledName.indexOf(untitledExtension))}${primaryExtension}`;
|
|
491
|
-
}
|
|
492
|
-
return `${untitledName}${primaryExtension}`;
|
|
493
|
-
}
|
|
494
|
-
const filenames = this.languageService.getFilenames(languageId);
|
|
495
|
-
if (filenames.includes(untitledName)) {
|
|
496
|
-
return untitledName;
|
|
497
|
-
}
|
|
498
|
-
return firstOrDefault(filenames) ?? untitledName;
|
|
499
|
-
}
|
|
500
|
-
async revert(resource, options) {
|
|
501
|
-
if (resource.scheme === Schemas.untitled) {
|
|
502
|
-
const model = this.untitled.get(resource);
|
|
503
|
-
if (model) {
|
|
504
|
-
return model.revert(options);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
const model = this.files.get(resource);
|
|
509
|
-
if (model && (model.isDirty() || options?.force)) {
|
|
510
|
-
return model.revert(options);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
isDirty(resource) {
|
|
515
|
-
const model = resource.scheme === Schemas.untitled ? this.untitled.get(resource) : this.files.get(resource);
|
|
516
|
-
if (model) {
|
|
517
|
-
return model.isDirty();
|
|
518
|
-
}
|
|
519
|
-
return false;
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
AbstractTextFileService = AbstractTextFileService_1 = ( __decorate([
|
|
523
|
-
( __param(0, IFileService)),
|
|
524
|
-
( __param(1, IUntitledTextEditorService)),
|
|
525
|
-
( __param(2, ILifecycleService)),
|
|
526
|
-
( __param(3, IInstantiationService)),
|
|
527
|
-
( __param(4, IModelService)),
|
|
528
|
-
( __param(5, IWorkbenchEnvironmentService)),
|
|
529
|
-
( __param(6, IDialogService)),
|
|
530
|
-
( __param(7, IFileDialogService)),
|
|
531
|
-
( __param(8, ITextResourceConfigurationService)),
|
|
532
|
-
( __param(9, IFilesConfigurationService)),
|
|
533
|
-
( __param(10, ICodeEditorService)),
|
|
534
|
-
( __param(11, IPathService)),
|
|
535
|
-
( __param(12, IWorkingCopyFileService)),
|
|
536
|
-
( __param(13, IUriIdentityService)),
|
|
537
|
-
( __param(14, ILanguageService)),
|
|
538
|
-
( __param(15, ILogService)),
|
|
539
|
-
( __param(16, IElevatedFileService)),
|
|
540
|
-
( __param(17, IDecorationsService))
|
|
541
|
-
], AbstractTextFileService));
|
|
542
|
-
let EncodingOracle = class EncodingOracle extends Disposable {
|
|
543
|
-
get encodingOverrides() { return this._encodingOverrides; }
|
|
544
|
-
set encodingOverrides(value) { this._encodingOverrides = value; }
|
|
545
|
-
constructor(textResourceConfigurationService, environmentService, contextService, uriIdentityService) {
|
|
546
|
-
super();
|
|
547
|
-
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
548
|
-
this.environmentService = environmentService;
|
|
549
|
-
this.contextService = contextService;
|
|
550
|
-
this.uriIdentityService = uriIdentityService;
|
|
551
|
-
this._encodingOverrides = this.getDefaultEncodingOverrides();
|
|
552
|
-
this.registerListeners();
|
|
553
|
-
}
|
|
554
|
-
registerListeners() {
|
|
555
|
-
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.encodingOverrides = this.getDefaultEncodingOverrides()));
|
|
556
|
-
}
|
|
557
|
-
getDefaultEncodingOverrides() {
|
|
558
|
-
const defaultEncodingOverrides = [];
|
|
559
|
-
defaultEncodingOverrides.push({ parent: this.environmentService.userRoamingDataHome, encoding: UTF8 });
|
|
560
|
-
defaultEncodingOverrides.push({ extension: WORKSPACE_EXTENSION, encoding: UTF8 });
|
|
561
|
-
defaultEncodingOverrides.push({ parent: this.environmentService.untitledWorkspacesHome, encoding: UTF8 });
|
|
562
|
-
this.contextService.getWorkspace().folders.forEach(folder => {
|
|
563
|
-
defaultEncodingOverrides.push({ parent: joinPath(folder.uri, '.vscode'), encoding: UTF8 });
|
|
564
|
-
});
|
|
565
|
-
return defaultEncodingOverrides;
|
|
566
|
-
}
|
|
567
|
-
async getWriteEncoding(resource, options) {
|
|
568
|
-
const { encoding, hasBOM } = await this.getPreferredWriteEncoding(resource, options ? options.encoding : undefined);
|
|
569
|
-
return { encoding, addBOM: hasBOM };
|
|
570
|
-
}
|
|
571
|
-
async getPreferredWriteEncoding(resource, preferredEncoding) {
|
|
572
|
-
const resourceEncoding = await this.getEncodingForResource(resource, preferredEncoding);
|
|
573
|
-
return {
|
|
574
|
-
encoding: resourceEncoding,
|
|
575
|
-
hasBOM: resourceEncoding === UTF16be || resourceEncoding === UTF16le || resourceEncoding === UTF8_with_bom
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
async getPreferredReadEncoding(resource, options, detectedEncoding) {
|
|
579
|
-
let preferredEncoding;
|
|
580
|
-
if (options?.encoding) {
|
|
581
|
-
if (detectedEncoding === UTF8_with_bom && options.encoding === UTF8) {
|
|
582
|
-
preferredEncoding = UTF8_with_bom;
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
preferredEncoding = options.encoding;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
else if (typeof detectedEncoding === 'string') {
|
|
589
|
-
preferredEncoding = detectedEncoding;
|
|
590
|
-
}
|
|
591
|
-
else if (this.textResourceConfigurationService.getValue(resource, 'files.encoding') === UTF8_with_bom) {
|
|
592
|
-
preferredEncoding = UTF8;
|
|
593
|
-
}
|
|
594
|
-
const encoding = await this.getEncodingForResource(resource, preferredEncoding);
|
|
595
|
-
return {
|
|
596
|
-
encoding,
|
|
597
|
-
hasBOM: encoding === UTF16be || encoding === UTF16le || encoding === UTF8_with_bom
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
async getEncodingForResource(resource, preferredEncoding) {
|
|
601
|
-
let fileEncoding;
|
|
602
|
-
const override = this.getEncodingOverride(resource);
|
|
603
|
-
if (override) {
|
|
604
|
-
fileEncoding = override;
|
|
605
|
-
}
|
|
606
|
-
else if (preferredEncoding) {
|
|
607
|
-
fileEncoding = preferredEncoding;
|
|
608
|
-
}
|
|
609
|
-
else {
|
|
610
|
-
fileEncoding = this.textResourceConfigurationService.getValue(resource, 'files.encoding');
|
|
611
|
-
}
|
|
612
|
-
if (fileEncoding !== UTF8) {
|
|
613
|
-
if (!fileEncoding || !(await encodingExists(fileEncoding))) {
|
|
614
|
-
fileEncoding = UTF8;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
return fileEncoding;
|
|
618
|
-
}
|
|
619
|
-
getEncodingOverride(resource) {
|
|
620
|
-
if (this.encodingOverrides?.length) {
|
|
621
|
-
for (const override of this.encodingOverrides) {
|
|
622
|
-
if (override.parent && this.uriIdentityService.extUri.isEqualOrParent(resource, override.parent)) {
|
|
623
|
-
return override.encoding;
|
|
624
|
-
}
|
|
625
|
-
if (override.extension && extname$1(resource) === `.${override.extension}`) {
|
|
626
|
-
return override.encoding;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return undefined;
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
EncodingOracle = ( __decorate([
|
|
634
|
-
( __param(0, ITextResourceConfigurationService)),
|
|
635
|
-
( __param(1, IWorkbenchEnvironmentService)),
|
|
636
|
-
( __param(2, IWorkspaceContextService)),
|
|
637
|
-
( __param(3, IUriIdentityService))
|
|
638
|
-
], EncodingOracle));
|
|
639
|
-
export { AbstractTextFileService, EncodingOracle };
|