@codingame/monaco-vscode-api 2.0.2 → 2.0.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/package.json +8 -8
- package/vscode/src/vs/workbench/browser/parts/editor/editor.autosave.contribution.js +4 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorInput.js +342 -0
- package/vscode/src/vs/workbench/contrib/files/browser/files.configuration.contribution.js +463 -0
- package/vscode/src/vs/workbench/contrib/files/browser/files.fileEditorFactory.contribution.js +13 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +0 -1375
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +0 -162
- package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +0 -885
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +0 -99
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "VSCode public API plugged on the monaco editor",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": {
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"vscode-marked": "npm:marked@=3.0.2",
|
|
98
98
|
"vscode-semver": "npm:semver@=5.5.0",
|
|
99
|
-
"@codingame/monaco-vscode-extensions-service-override": "2.0.
|
|
100
|
-
"@codingame/monaco-vscode-files-service-override": "2.0.
|
|
101
|
-
"@codingame/monaco-vscode-quickaccess-service-override": "2.0.
|
|
102
|
-
"@codingame/monaco-vscode-environment-service-override": "2.0.
|
|
103
|
-
"@codingame/monaco-vscode-layout-service-override": "2.0.
|
|
104
|
-
"@codingame/monaco-vscode-host-service-override": "2.0.
|
|
105
|
-
"@codingame/monaco-vscode-base-service-override": "2.0.
|
|
99
|
+
"@codingame/monaco-vscode-extensions-service-override": "2.0.3",
|
|
100
|
+
"@codingame/monaco-vscode-files-service-override": "2.0.3",
|
|
101
|
+
"@codingame/monaco-vscode-quickaccess-service-override": "2.0.3",
|
|
102
|
+
"@codingame/monaco-vscode-environment-service-override": "2.0.3",
|
|
103
|
+
"@codingame/monaco-vscode-layout-service-override": "2.0.3",
|
|
104
|
+
"@codingame/monaco-vscode-host-service-override": "2.0.3",
|
|
105
|
+
"@codingame/monaco-vscode-base-service-override": "2.0.3"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Registry } from '../../../../platform/registry/common/platform.js';
|
|
2
|
+
import { EditorAutoSave } from './editorAutoSave.js';
|
|
3
|
+
import { Extensions } from '../../../common/contributions.js';
|
|
4
|
+
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(EditorAutoSave, 2 );
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { DEFAULT_EDITOR_ASSOCIATION, findViewStateForEditor, isResourceEditorInput } from '../../../../common/editor.js';
|
|
3
|
+
import { AbstractTextResourceEditorInput } from '../../../../common/editor/textResourceEditorInput.js';
|
|
4
|
+
import { BinaryEditorModel } from '../../../../common/editor/binaryEditorModel.js';
|
|
5
|
+
import { getLargeFileConfirmationLimit, ByteSize, IFileService } from '../../../../../platform/files/common/files.js';
|
|
6
|
+
import { ITextFileService } from '../../../../services/textfile/common/textfiles.js';
|
|
7
|
+
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
|
|
8
|
+
import { DisposableStore, dispose } from '../../../../../base/common/lifecycle.js';
|
|
9
|
+
import { ITextModelService } from '../../../../../editor/common/services/resolverService.js';
|
|
10
|
+
import { FILE_EDITOR_INPUT_ID, BINARY_FILE_EDITOR_ID, TEXT_FILE_EDITOR_ID } from '../../common/files.js';
|
|
11
|
+
import { ILabelService } from '../../../../../platform/label/common/label.js';
|
|
12
|
+
import { IFilesConfigurationService } from '../../../../services/filesConfiguration/common/filesConfigurationService.js';
|
|
13
|
+
import { IEditorService } from '../../../../services/editor/common/editorService.js';
|
|
14
|
+
import { isEqual } from '../../../../../base/common/resources.js';
|
|
15
|
+
import { Event } from '../../../../../base/common/event.js';
|
|
16
|
+
import { Schemas } from '../../../../../base/common/network.js';
|
|
17
|
+
import { createTextBufferFactory } from '../../../../../editor/common/model/textModel.js';
|
|
18
|
+
import { IPathService } from '../../../../services/path/common/pathService.js';
|
|
19
|
+
import { ITextResourceConfigurationService } from '../../../../../editor/common/services/textResourceConfiguration.js';
|
|
20
|
+
import { isConfigured } from '../../../../../platform/configuration/common/configuration.js';
|
|
21
|
+
var FileEditorInput_1;
|
|
22
|
+
let FileEditorInput = FileEditorInput_1 = class FileEditorInput extends AbstractTextResourceEditorInput {
|
|
23
|
+
get typeId() {
|
|
24
|
+
return FILE_EDITOR_INPUT_ID;
|
|
25
|
+
}
|
|
26
|
+
get editorId() {
|
|
27
|
+
return DEFAULT_EDITOR_ASSOCIATION.id;
|
|
28
|
+
}
|
|
29
|
+
get capabilities() {
|
|
30
|
+
let capabilities = 32 ;
|
|
31
|
+
if (this.model) {
|
|
32
|
+
if (this.model.isReadonly()) {
|
|
33
|
+
capabilities |= 2 ;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (this.fileService.hasProvider(this.resource)) {
|
|
38
|
+
if (this.filesConfigurationService.isReadonly(this.resource)) {
|
|
39
|
+
capabilities |= 2 ;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
capabilities |= 4 ;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!((capabilities & 2) )) {
|
|
47
|
+
capabilities |= 128 ;
|
|
48
|
+
}
|
|
49
|
+
return capabilities;
|
|
50
|
+
}
|
|
51
|
+
constructor(resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService, textFileService, textModelService, labelService, fileService, filesConfigurationService, editorService, pathService, textResourceConfigurationService) {
|
|
52
|
+
super(resource, preferredResource, editorService, textFileService, labelService, fileService, filesConfigurationService);
|
|
53
|
+
this.instantiationService = instantiationService;
|
|
54
|
+
this.textModelService = textModelService;
|
|
55
|
+
this.pathService = pathService;
|
|
56
|
+
this.textResourceConfigurationService = textResourceConfigurationService;
|
|
57
|
+
this.forceOpenAs = 0 ;
|
|
58
|
+
this.model = undefined;
|
|
59
|
+
this.cachedTextFileModelReference = undefined;
|
|
60
|
+
this.modelListeners = this._register(( new DisposableStore()));
|
|
61
|
+
this.model = this.textFileService.files.get(resource);
|
|
62
|
+
if (preferredName) {
|
|
63
|
+
this.setPreferredName(preferredName);
|
|
64
|
+
}
|
|
65
|
+
if (preferredDescription) {
|
|
66
|
+
this.setPreferredDescription(preferredDescription);
|
|
67
|
+
}
|
|
68
|
+
if (preferredEncoding) {
|
|
69
|
+
this.setPreferredEncoding(preferredEncoding);
|
|
70
|
+
}
|
|
71
|
+
if (preferredLanguageId) {
|
|
72
|
+
this.setPreferredLanguageId(preferredLanguageId);
|
|
73
|
+
}
|
|
74
|
+
if (typeof preferredContents === 'string') {
|
|
75
|
+
this.setPreferredContents(preferredContents);
|
|
76
|
+
}
|
|
77
|
+
this._register(this.textFileService.files.onDidCreate(model => this.onDidCreateTextFileModel(model)));
|
|
78
|
+
if (this.model) {
|
|
79
|
+
this.registerModelListeners(this.model);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
onDidCreateTextFileModel(model) {
|
|
83
|
+
if (isEqual(model.resource, this.resource)) {
|
|
84
|
+
this.model = model;
|
|
85
|
+
this.registerModelListeners(model);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
registerModelListeners(model) {
|
|
89
|
+
this.modelListeners.clear();
|
|
90
|
+
this.modelListeners.add(model.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
|
91
|
+
this.modelListeners.add(model.onDidChangeReadonly(() => this._onDidChangeCapabilities.fire()));
|
|
92
|
+
this.modelListeners.add(model.onDidSaveError(() => this._onDidChangeDirty.fire()));
|
|
93
|
+
this.modelListeners.add(Event.once(model.onWillDispose)(() => {
|
|
94
|
+
this.modelListeners.clear();
|
|
95
|
+
this.model = undefined;
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
getName() {
|
|
99
|
+
return this.preferredName || super.getName();
|
|
100
|
+
}
|
|
101
|
+
setPreferredName(name) {
|
|
102
|
+
if (!this.allowLabelOverride()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (this.preferredName !== name) {
|
|
106
|
+
this.preferredName = name;
|
|
107
|
+
this._onDidChangeLabel.fire();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
allowLabelOverride() {
|
|
111
|
+
return this.resource.scheme !== this.pathService.defaultUriScheme &&
|
|
112
|
+
this.resource.scheme !== Schemas.vscodeUserData &&
|
|
113
|
+
this.resource.scheme !== Schemas.file &&
|
|
114
|
+
this.resource.scheme !== Schemas.vscodeRemote;
|
|
115
|
+
}
|
|
116
|
+
getPreferredName() {
|
|
117
|
+
return this.preferredName;
|
|
118
|
+
}
|
|
119
|
+
isReadonly() {
|
|
120
|
+
return this.model ? this.model.isReadonly() : this.filesConfigurationService.isReadonly(this.resource);
|
|
121
|
+
}
|
|
122
|
+
getDescription(verbosity) {
|
|
123
|
+
return this.preferredDescription || super.getDescription(verbosity);
|
|
124
|
+
}
|
|
125
|
+
setPreferredDescription(description) {
|
|
126
|
+
if (!this.allowLabelOverride()) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (this.preferredDescription !== description) {
|
|
130
|
+
this.preferredDescription = description;
|
|
131
|
+
this._onDidChangeLabel.fire();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
getPreferredDescription() {
|
|
135
|
+
return this.preferredDescription;
|
|
136
|
+
}
|
|
137
|
+
getTitle(verbosity) {
|
|
138
|
+
let title = super.getTitle(verbosity);
|
|
139
|
+
const preferredTitle = this.getPreferredTitle();
|
|
140
|
+
if (preferredTitle) {
|
|
141
|
+
title = `${preferredTitle} (${title})`;
|
|
142
|
+
}
|
|
143
|
+
return title;
|
|
144
|
+
}
|
|
145
|
+
getPreferredTitle() {
|
|
146
|
+
if (this.preferredName && this.preferredDescription) {
|
|
147
|
+
return `${this.preferredName} ${this.preferredDescription}`;
|
|
148
|
+
}
|
|
149
|
+
if (this.preferredName || this.preferredDescription) {
|
|
150
|
+
return this.preferredName ?? this.preferredDescription;
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
getEncoding() {
|
|
155
|
+
if (this.model) {
|
|
156
|
+
return this.model.getEncoding();
|
|
157
|
+
}
|
|
158
|
+
return this.preferredEncoding;
|
|
159
|
+
}
|
|
160
|
+
getPreferredEncoding() {
|
|
161
|
+
return this.preferredEncoding;
|
|
162
|
+
}
|
|
163
|
+
async setEncoding(encoding, mode) {
|
|
164
|
+
this.setPreferredEncoding(encoding);
|
|
165
|
+
return this.model?.setEncoding(encoding, mode);
|
|
166
|
+
}
|
|
167
|
+
setPreferredEncoding(encoding) {
|
|
168
|
+
this.preferredEncoding = encoding;
|
|
169
|
+
this.setForceOpenAsText();
|
|
170
|
+
}
|
|
171
|
+
getLanguageId() {
|
|
172
|
+
if (this.model) {
|
|
173
|
+
return this.model.getLanguageId();
|
|
174
|
+
}
|
|
175
|
+
return this.preferredLanguageId;
|
|
176
|
+
}
|
|
177
|
+
getPreferredLanguageId() {
|
|
178
|
+
return this.preferredLanguageId;
|
|
179
|
+
}
|
|
180
|
+
setLanguageId(languageId, source) {
|
|
181
|
+
this.setPreferredLanguageId(languageId);
|
|
182
|
+
this.model?.setLanguageId(languageId, source);
|
|
183
|
+
}
|
|
184
|
+
setPreferredLanguageId(languageId) {
|
|
185
|
+
this.preferredLanguageId = languageId;
|
|
186
|
+
this.setForceOpenAsText();
|
|
187
|
+
}
|
|
188
|
+
setPreferredContents(contents) {
|
|
189
|
+
this.preferredContents = contents;
|
|
190
|
+
this.setForceOpenAsText();
|
|
191
|
+
}
|
|
192
|
+
setForceOpenAsText() {
|
|
193
|
+
this.forceOpenAs = 1 ;
|
|
194
|
+
}
|
|
195
|
+
setForceOpenAsBinary() {
|
|
196
|
+
this.forceOpenAs = 2 ;
|
|
197
|
+
}
|
|
198
|
+
isDirty() {
|
|
199
|
+
return !!(this.model?.isDirty());
|
|
200
|
+
}
|
|
201
|
+
isSaving() {
|
|
202
|
+
if (this.model?.hasState(0 ) || this.model?.hasState(3 ) || this.model?.hasState(5 )) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (this.filesConfigurationService.getAutoSaveMode() === 1 ) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return super.isSaving();
|
|
209
|
+
}
|
|
210
|
+
prefersEditorPane(editorPanes) {
|
|
211
|
+
if (this.forceOpenAs === 2 ) {
|
|
212
|
+
return editorPanes.find(editorPane => editorPane.typeId === BINARY_FILE_EDITOR_ID);
|
|
213
|
+
}
|
|
214
|
+
return editorPanes.find(editorPane => editorPane.typeId === TEXT_FILE_EDITOR_ID);
|
|
215
|
+
}
|
|
216
|
+
resolve(options) {
|
|
217
|
+
if (this.forceOpenAs === 2 ) {
|
|
218
|
+
return this.doResolveAsBinary();
|
|
219
|
+
}
|
|
220
|
+
return this.doResolveAsText(options);
|
|
221
|
+
}
|
|
222
|
+
async doResolveAsText(options) {
|
|
223
|
+
try {
|
|
224
|
+
const preferredContents = this.preferredContents;
|
|
225
|
+
this.preferredContents = undefined;
|
|
226
|
+
await this.textFileService.files.resolve(this.resource, {
|
|
227
|
+
languageId: this.preferredLanguageId,
|
|
228
|
+
encoding: this.preferredEncoding,
|
|
229
|
+
contents: typeof preferredContents === 'string' ? createTextBufferFactory(preferredContents) : undefined,
|
|
230
|
+
reload: { async: true },
|
|
231
|
+
allowBinary: this.forceOpenAs === 1 ,
|
|
232
|
+
reason: 1 ,
|
|
233
|
+
limits: this.ensureLimits(options)
|
|
234
|
+
});
|
|
235
|
+
if (!this.cachedTextFileModelReference) {
|
|
236
|
+
this.cachedTextFileModelReference = await this.textModelService.createModelReference(this.resource);
|
|
237
|
+
}
|
|
238
|
+
const model = this.cachedTextFileModelReference.object;
|
|
239
|
+
if (this.isDisposed()) {
|
|
240
|
+
this.disposeModelReference();
|
|
241
|
+
}
|
|
242
|
+
return model;
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
if (error.textFileOperationResult === 0 ) {
|
|
246
|
+
return this.doResolveAsBinary();
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
ensureLimits(options) {
|
|
252
|
+
if (options?.limits) {
|
|
253
|
+
return options.limits;
|
|
254
|
+
}
|
|
255
|
+
const defaultSizeLimit = getLargeFileConfirmationLimit(this.resource);
|
|
256
|
+
let configuredSizeLimit = undefined;
|
|
257
|
+
const configuredSizeLimitMb = this.textResourceConfigurationService.inspect(this.resource, null, 'workbench.editorLargeFileConfirmation');
|
|
258
|
+
if (isConfigured(configuredSizeLimitMb)) {
|
|
259
|
+
configuredSizeLimit = configuredSizeLimitMb.value * ByteSize.MB;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
size: configuredSizeLimit ?? defaultSizeLimit
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
async doResolveAsBinary() {
|
|
266
|
+
const model = this.instantiationService.createInstance(BinaryEditorModel, this.preferredResource, this.getName());
|
|
267
|
+
await model.resolve();
|
|
268
|
+
return model;
|
|
269
|
+
}
|
|
270
|
+
isResolved() {
|
|
271
|
+
return !!this.model;
|
|
272
|
+
}
|
|
273
|
+
async rename(group, target) {
|
|
274
|
+
return {
|
|
275
|
+
editor: {
|
|
276
|
+
resource: target,
|
|
277
|
+
encoding: this.getEncoding(),
|
|
278
|
+
options: {
|
|
279
|
+
viewState: findViewStateForEditor(this, group, this.editorService)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
toUntyped(options) {
|
|
285
|
+
const untypedInput = {
|
|
286
|
+
resource: this.preferredResource,
|
|
287
|
+
forceFile: true,
|
|
288
|
+
options: {
|
|
289
|
+
override: this.editorId
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
if (typeof options?.preserveViewState === 'number') {
|
|
293
|
+
untypedInput.encoding = this.getEncoding();
|
|
294
|
+
untypedInput.languageId = this.getLanguageId();
|
|
295
|
+
untypedInput.contents = (() => {
|
|
296
|
+
const model = this.textFileService.files.get(this.resource);
|
|
297
|
+
if (model?.isDirty() && !model.textEditorModel.isTooLargeForHeapOperation()) {
|
|
298
|
+
return model.textEditorModel.getValue();
|
|
299
|
+
}
|
|
300
|
+
return undefined;
|
|
301
|
+
})();
|
|
302
|
+
untypedInput.options = {
|
|
303
|
+
...untypedInput.options,
|
|
304
|
+
viewState: findViewStateForEditor(this, options.preserveViewState, this.editorService)
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return untypedInput;
|
|
308
|
+
}
|
|
309
|
+
matches(otherInput) {
|
|
310
|
+
if (this === otherInput) {
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
if (otherInput instanceof FileEditorInput_1) {
|
|
314
|
+
return isEqual(otherInput.resource, this.resource);
|
|
315
|
+
}
|
|
316
|
+
if (isResourceEditorInput(otherInput)) {
|
|
317
|
+
return super.matches(otherInput);
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
dispose() {
|
|
322
|
+
this.model = undefined;
|
|
323
|
+
this.disposeModelReference();
|
|
324
|
+
super.dispose();
|
|
325
|
+
}
|
|
326
|
+
disposeModelReference() {
|
|
327
|
+
dispose(this.cachedTextFileModelReference);
|
|
328
|
+
this.cachedTextFileModelReference = undefined;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
FileEditorInput = FileEditorInput_1 = ( __decorate([
|
|
332
|
+
( __param(7, IInstantiationService)),
|
|
333
|
+
( __param(8, ITextFileService)),
|
|
334
|
+
( __param(9, ITextModelService)),
|
|
335
|
+
( __param(10, ILabelService)),
|
|
336
|
+
( __param(11, IFileService)),
|
|
337
|
+
( __param(12, IFilesConfigurationService)),
|
|
338
|
+
( __param(13, IEditorService)),
|
|
339
|
+
( __param(14, IPathService)),
|
|
340
|
+
( __param(15, ITextResourceConfigurationService))
|
|
341
|
+
], FileEditorInput));
|
|
342
|
+
export { FileEditorInput };
|