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