Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/files/browser/files.contribution.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as nls from '../../../../nls.js';
7
import { sep } from '../../../../base/common/path.js';
8
import { Registry } from '../../../../platform/registry/common/platform.js';
9
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from '../../../../platform/configuration/common/configurationRegistry.js';
10
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../common/contributions.js';
11
import { IFileEditorInput, IEditorFactoryRegistry, EditorExtensions } from '../../../common/editor.js';
12
import { AutoSaveConfiguration, HotExitConfiguration, FILES_EXCLUDE_CONFIG, FILES_ASSOCIATIONS_CONFIG, FILES_READONLY_INCLUDE_CONFIG, FILES_READONLY_EXCLUDE_CONFIG, FILES_READONLY_FROM_PERMISSIONS_CONFIG } from '../../../../platform/files/common/files.js';
13
import { SortOrder, LexicographicOptions, FILE_EDITOR_INPUT_ID, BINARY_TEXT_FILE_MODE, UndoConfirmLevel, IFilesConfiguration } from '../common/files.js';
14
import { TextFileEditorTracker } from './editors/textFileEditorTracker.js';
15
import { TextFileSaveErrorHandler } from './editors/textFileSaveErrorHandler.js';
16
import { FileEditorInput } from './editors/fileEditorInput.js';
17
import { BinaryFileEditor } from './editors/binaryFileEditor.js';
18
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
19
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';
20
import { isNative, isWeb, isWindows } from '../../../../base/common/platform.js';
21
import { ExplorerViewletViewsContribution } from './explorerViewlet.js';
22
import { IEditorPaneRegistry, EditorPaneDescriptor } from '../../../browser/editor.js';
23
import { ILabelService } from '../../../../platform/label/common/label.js';
24
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
25
import { ExplorerService, UNDO_REDO_SOURCE } from './explorerService.js';
26
import { GUESSABLE_ENCODINGS, SUPPORTED_ENCODINGS } from '../../../services/textfile/common/encoding.js';
27
import { Schemas } from '../../../../base/common/network.js';
28
import { WorkspaceWatcher } from './workspaceWatcher.js';
29
import { editorConfigurationBaseNode } from '../../../../editor/common/config/editorConfigurationSchema.js';
30
import { DirtyFilesIndicator } from '../common/dirtyFilesIndicator.js';
31
import { UndoCommand, RedoCommand } from '../../../../editor/browser/editorExtensions.js';
32
import { IUndoRedoService } from '../../../../platform/undoRedo/common/undoRedo.js';
33
import { IExplorerService } from './files.js';
34
import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from './editors/fileEditorHandler.js';
35
import { ModesRegistry } from '../../../../editor/common/languages/modesRegistry.js';
36
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
37
import { TextFileEditor } from './editors/textFileEditor.js';
38
39
class FileUriLabelContribution implements IWorkbenchContribution {
40
41
static readonly ID = 'workbench.contrib.fileUriLabel';
42
43
constructor(@ILabelService labelService: ILabelService) {
44
labelService.registerFormatter({
45
scheme: Schemas.file,
46
formatting: {
47
label: '${authority}${path}',
48
separator: sep,
49
tildify: !isWindows,
50
normalizeDriveLetter: isWindows,
51
authorityPrefix: sep + sep,
52
workspaceSuffix: ''
53
}
54
});
55
}
56
}
57
58
registerSingleton(IExplorerService, ExplorerService, InstantiationType.Delayed);
59
60
// Register file editors
61
62
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
63
EditorPaneDescriptor.create(
64
TextFileEditor,
65
TextFileEditor.ID,
66
nls.localize('textFileEditor', "Text File Editor")
67
),
68
[
69
new SyncDescriptor(FileEditorInput)
70
]
71
);
72
73
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
74
EditorPaneDescriptor.create(
75
BinaryFileEditor,
76
BinaryFileEditor.ID,
77
nls.localize('binaryFileEditor', "Binary File Editor")
78
),
79
[
80
new SyncDescriptor(FileEditorInput)
81
]
82
);
83
84
// Register default file input factory
85
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({
86
87
typeId: FILE_EDITOR_INPUT_ID,
88
89
createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => {
90
return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);
91
},
92
93
isFileEditor: (obj): obj is IFileEditorInput => {
94
return obj instanceof FileEditorInput;
95
}
96
});
97
98
// Register Editor Input Serializer & Handler
99
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(FILE_EDITOR_INPUT_ID, FileEditorInputSerializer);
100
registerWorkbenchContribution2(FileEditorWorkingCopyEditorHandler.ID, FileEditorWorkingCopyEditorHandler, WorkbenchPhase.BlockRestore);
101
102
// Register Explorer views
103
registerWorkbenchContribution2(ExplorerViewletViewsContribution.ID, ExplorerViewletViewsContribution, WorkbenchPhase.BlockStartup);
104
105
// Register Text File Editor Tracker
106
registerWorkbenchContribution2(TextFileEditorTracker.ID, TextFileEditorTracker, WorkbenchPhase.BlockStartup);
107
108
// Register Text File Save Error Handler
109
registerWorkbenchContribution2(TextFileSaveErrorHandler.ID, TextFileSaveErrorHandler, WorkbenchPhase.BlockStartup);
110
111
// Register uri display for file uris
112
registerWorkbenchContribution2(FileUriLabelContribution.ID, FileUriLabelContribution, WorkbenchPhase.BlockStartup);
113
114
// Register Workspace Watcher
115
registerWorkbenchContribution2(WorkspaceWatcher.ID, WorkspaceWatcher, WorkbenchPhase.AfterRestored);
116
117
// Register Dirty Files Indicator
118
registerWorkbenchContribution2(DirtyFilesIndicator.ID, DirtyFilesIndicator, WorkbenchPhase.BlockStartup);
119
120
// Configuration
121
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
122
123
const hotExitConfiguration: IConfigurationPropertySchema = isNative ?
124
{
125
'type': 'string',
126
'scope': ConfigurationScope.APPLICATION,
127
'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
128
'default': HotExitConfiguration.ON_EXIT,
129
'markdownEnumDescriptions': [
130
nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'),
131
nls.localize('hotExit.onExit', 'Hot exit will be triggered when the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu). All windows without folders opened will be restored upon next launch. A list of previously opened windows with unsaved files can be accessed via `File > Open Recent > More...`'),
132
nls.localize('hotExit.onExitAndWindowClose', 'Hot exit will be triggered when the last window is closed on Windows/Linux or when the `workbench.action.quit` command is triggered (command palette, keybinding, menu), and also for any window with a folder opened regardless of whether it\'s the last window. All windows without folders opened will be restored upon next launch. A list of previously opened windows with unsaved files can be accessed via `File > Open Recent > More...`')
133
],
134
'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE)
135
} : {
136
'type': 'string',
137
'scope': ConfigurationScope.APPLICATION,
138
'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
139
'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE,
140
'markdownEnumDescriptions': [
141
nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'),
142
nls.localize('hotExit.onExitAndWindowCloseBrowser', 'Hot exit will be triggered when the browser quits or the window or tab is closed.')
143
],
144
'markdownDescription': nls.localize('hotExit', "[Hot Exit](https://aka.ms/vscode-hot-exit) controls whether unsaved files are remembered between sessions, allowing the save prompt when exiting the editor to be skipped.", HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE)
145
};
146
147
configurationRegistry.registerConfiguration({
148
'id': 'files',
149
'order': 9,
150
'title': nls.localize('filesConfigurationTitle', "Files"),
151
'type': 'object',
152
'properties': {
153
[FILES_EXCLUDE_CONFIG]: {
154
'type': 'object',
155
'markdownDescription': nls.localize('exclude', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) for excluding files and folders. For example, the File Explorer decides which files and folders to show or hide based on this setting. Refer to the `#search.exclude#` setting to define search-specific excludes. Refer to the `#explorer.excludeGitIgnore#` setting for ignoring files based on your `.gitignore`."),
156
'default': {
157
...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/.DS_Store': true, '**/Thumbs.db': true },
158
...(isWeb ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined)
159
},
160
'scope': ConfigurationScope.RESOURCE,
161
'additionalProperties': {
162
'anyOf': [
163
{
164
'type': 'boolean',
165
'enum': [true, false],
166
'enumDescriptions': [nls.localize('trueDescription', "Enable the pattern."), nls.localize('falseDescription', "Disable the pattern.")],
167
'description': nls.localize('files.exclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."),
168
},
169
{
170
'type': 'object',
171
'properties': {
172
'when': {
173
'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
174
'pattern': '\\w*\\$\\(basename\\)\\w*',
175
'default': '$(basename).ext',
176
'markdownDescription': nls.localize({ key: 'files.exclude.when', comment: ['\\$(basename) should not be translated'] }, "Additional check on the siblings of a matching file. Use \\$(basename) as variable for the matching file name.")
177
}
178
}
179
}
180
]
181
}
182
},
183
[FILES_ASSOCIATIONS_CONFIG]: {
184
'type': 'object',
185
'markdownDescription': nls.localize('associations', "Configure [glob patterns](https://aka.ms/vscode-glob-patterns) of file associations to languages (for example `\"*.extension\": \"html\"`). Patterns will match on the absolute path of a file if they contain a path separator and will match on the name of the file otherwise. These have precedence over the default associations of the languages installed."),
186
'additionalProperties': {
187
'type': 'string'
188
}
189
},
190
'files.encoding': {
191
'type': 'string',
192
'enum': Object.keys(SUPPORTED_ENCODINGS),
193
'default': 'utf8',
194
'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),
195
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
196
'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
197
'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong)
198
},
199
'files.autoGuessEncoding': {
200
'type': 'boolean',
201
'default': false,
202
'markdownDescription': nls.localize('autoGuessEncoding', "When enabled, the editor will attempt to guess the character set encoding when opening files. This setting can also be configured per language. Note, this setting is not respected by text search. Only {0} is respected.", '`#files.encoding#`'),
203
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
204
},
205
'files.candidateGuessEncodings': {
206
'type': 'array',
207
'items': {
208
'type': 'string',
209
'enum': Object.keys(GUESSABLE_ENCODINGS),
210
'enumDescriptions': Object.keys(GUESSABLE_ENCODINGS).map(key => GUESSABLE_ENCODINGS[key].labelLong)
211
},
212
'default': [],
213
'markdownDescription': nls.localize('candidateGuessEncodings', "List of character set encodings that the editor should attempt to guess in the order they are listed. In case it cannot be determined, {0} is respected", '`#files.encoding#`'),
214
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
215
},
216
'files.eol': {
217
'type': 'string',
218
'enum': [
219
'\n',
220
'\r\n',
221
'auto'
222
],
223
'enumDescriptions': [
224
nls.localize('eol.LF', "LF"),
225
nls.localize('eol.CRLF', "CRLF"),
226
nls.localize('eol.auto', "Uses operating system specific end of line character.")
227
],
228
'default': 'auto',
229
'description': nls.localize('eol', "The default end of line character."),
230
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
231
},
232
'files.enableTrash': {
233
'type': 'boolean',
234
'default': true,
235
'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.")
236
},
237
'files.trimTrailingWhitespace': {
238
'type': 'boolean',
239
'default': false,
240
'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
241
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
242
},
243
'files.trimTrailingWhitespaceInRegexAndStrings': {
244
'type': 'boolean',
245
'default': true,
246
'description': nls.localize('trimTrailingWhitespaceInRegexAndStrings', "When enabled, trailing whitespace will be removed from multiline strings and regexes will be removed on save or when executing 'editor.action.trimTrailingWhitespace'. This can cause whitespace to not be trimmed from lines when there isn't up-to-date token information."),
247
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
248
},
249
'files.insertFinalNewline': {
250
'type': 'boolean',
251
'default': false,
252
'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
253
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
254
},
255
'files.trimFinalNewlines': {
256
'type': 'boolean',
257
'default': false,
258
'description': nls.localize('trimFinalNewlines', "When enabled, will trim all new lines after the final new line at the end of the file when saving it."),
259
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
260
},
261
'files.autoSave': {
262
'type': 'string',
263
'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
264
'markdownEnumDescriptions': [
265
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "An editor with changes is never automatically saved."),
266
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "An editor with changes is automatically saved after the configured `#files.autoSaveDelay#`."),
267
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "An editor with changes is automatically saved when the editor loses focus."),
268
nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "An editor with changes is automatically saved when the window loses focus.")
269
],
270
'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
271
'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSave' }, "Controls [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors that have unsaved changes.", AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE, AutoSaveConfiguration.AFTER_DELAY),
272
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
273
},
274
'files.autoSaveDelay': {
275
'type': 'number',
276
'default': 1000,
277
'minimum': 0,
278
'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in milliseconds after which an editor with unsaved changes is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY),
279
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
280
},
281
'files.autoSaveWorkspaceFilesOnly': {
282
'type': 'boolean',
283
'default': false,
284
'markdownDescription': nls.localize('autoSaveWorkspaceFilesOnly', "When enabled, will limit [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors to files that are inside the opened workspace. Only applies when {0} is enabled.", '`#files.autoSave#`'),
285
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
286
},
287
'files.autoSaveWhenNoErrors': {
288
'type': 'boolean',
289
'default': false,
290
'markdownDescription': nls.localize('autoSaveWhenNoErrors', "When enabled, will limit [auto save](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save) of editors to files that have no errors reported in them at the time the auto save is triggered. Only applies when {0} is enabled.", '`#files.autoSave#`'),
291
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE
292
},
293
'files.watcherExclude': {
294
'type': 'object',
295
'patternProperties': {
296
'.*': { 'type': 'boolean' }
297
},
298
'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/.hg/store/**': true },
299
'markdownDescription': nls.localize('watcherExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to exclude from file watching. Paths can either be relative to the watched folder or absolute. Glob patterns are matched relative from the watched folder. When you experience the file watcher process consuming a lot of CPU, make sure to exclude large folders that are of less interest (such as build output folders)."),
300
'scope': ConfigurationScope.RESOURCE
301
},
302
'files.watcherInclude': {
303
'type': 'array',
304
'items': {
305
'type': 'string'
306
},
307
'default': [],
308
'description': nls.localize('watcherInclude', "Configure extra paths to watch for changes inside the workspace. By default, all workspace folders will be watched recursively, except for folders that are symbolic links. You can explicitly add absolute or relative paths to support watching folders that are symbolic links. Relative paths will be resolved to an absolute path using the currently opened workspace."),
309
'scope': ConfigurationScope.RESOURCE
310
},
311
'files.hotExit': hotExitConfiguration,
312
'files.defaultLanguage': {
313
'type': 'string',
314
'markdownDescription': nls.localize('defaultLanguage', "The default language identifier that is assigned to new files. If configured to `${activeEditorLanguage}`, will use the language identifier of the currently active text editor if any.")
315
},
316
[FILES_READONLY_INCLUDE_CONFIG]: {
317
'type': 'object',
318
'patternProperties': {
319
'.*': { 'type': 'boolean' }
320
},
321
'default': {},
322
'markdownDescription': nls.localize('filesReadonlyInclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to mark as read-only. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. You can exclude matching paths via the `#files.readonlyExclude#` setting. Files from readonly file system providers will always be read-only independent of this setting."),
323
'scope': ConfigurationScope.RESOURCE
324
},
325
[FILES_READONLY_EXCLUDE_CONFIG]: {
326
'type': 'object',
327
'patternProperties': {
328
'.*': { 'type': 'boolean' }
329
},
330
'default': {},
331
'markdownDescription': nls.localize('filesReadonlyExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) to exclude from being marked as read-only if they match as a result of the `#files.readonlyInclude#` setting. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths. Files from readonly file system providers will always be read-only independent of this setting."),
332
'scope': ConfigurationScope.RESOURCE
333
},
334
[FILES_READONLY_FROM_PERMISSIONS_CONFIG]: {
335
'type': 'boolean',
336
'markdownDescription': nls.localize('filesReadonlyFromPermissions', "Marks files as read-only when their file permissions indicate as such. This can be overridden via `#files.readonlyInclude#` and `#files.readonlyExclude#` settings."),
337
'default': false
338
},
339
'files.restoreUndoStack': {
340
'type': 'boolean',
341
'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."),
342
'default': true
343
},
344
'files.saveConflictResolution': {
345
'type': 'string',
346
'enum': [
347
'askUser',
348
'overwriteFileOnDisk'
349
],
350
'enumDescriptions': [
351
nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."),
352
nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.")
353
],
354
'description': nls.localize('files.saveConflictResolution', "A save conflict can occur when a file is saved to disk that was changed by another program in the meantime. To prevent data loss, the user is asked to compare the changes in the editor with the version on disk. This setting should only be changed if you frequently encounter save conflict errors and may result in data loss if used without caution."),
355
'default': 'askUser',
356
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
357
},
358
'files.dialog.defaultPath': {
359
'type': 'string',
360
'pattern': '^((\\/|\\\\\\\\|[a-zA-Z]:\\\\).*)?$', // slash OR UNC-root OR drive-root OR undefined
361
'patternErrorMessage': nls.localize('defaultPathErrorMessage', "Default path for file dialogs must be an absolute path (e.g. C:\\\\myFolder or /myFolder)."),
362
'description': nls.localize('fileDialogDefaultPath', "Default path for file dialogs, overriding user's home path. Only used in the absence of a context-specific path, such as most recently opened file or folder."),
363
'scope': ConfigurationScope.MACHINE
364
},
365
'files.simpleDialog.enable': {
366
'type': 'boolean',
367
'description': nls.localize('files.simpleDialog.enable', "Enables the simple file dialog for opening and saving files and folders. The simple file dialog replaces the system file dialog when enabled."),
368
'default': false
369
},
370
'files.participants.timeout': {
371
type: 'number',
372
default: 60000,
373
markdownDescription: nls.localize('files.participants.timeout', "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."),
374
}
375
}
376
});
377
378
configurationRegistry.registerConfiguration({
379
...editorConfigurationBaseNode,
380
properties: {
381
'editor.formatOnSave': {
382
'type': 'boolean',
383
'markdownDescription': nls.localize('formatOnSave', "Format a file on save. A formatter must be available and the editor must not be shutting down. When {0} is set to `afterDelay`, the file will only be formatted when saved explicitly.", '`#files.autoSave#`'),
384
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
385
},
386
'editor.formatOnSaveMode': {
387
'type': 'string',
388
'default': 'file',
389
'enum': [
390
'file',
391
'modifications',
392
'modificationsIfAvailable'
393
],
394
'enumDescriptions': [
395
nls.localize({ key: 'everything', comment: ['This is the description of an option'] }, "Format the whole file."),
396
nls.localize({ key: 'modification', comment: ['This is the description of an option'] }, "Format modifications (requires source control)."),
397
nls.localize({ key: 'modificationIfAvailable', comment: ['This is the description of an option'] }, "Will attempt to format modifications only (requires source control). If source control can't be used, then the whole file will be formatted."),
398
],
399
'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."),
400
'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
401
},
402
}
403
});
404
405
configurationRegistry.registerConfiguration({
406
'id': 'explorer',
407
'order': 10,
408
'title': nls.localize('explorerConfigurationTitle', "File Explorer"),
409
'type': 'object',
410
'properties': {
411
'explorer.openEditors.visible': {
412
'type': 'number',
413
'description': nls.localize({ key: 'openEditorsVisible', comment: ['Open is an adjective'] }, "The initial maximum number of editors shown in the Open Editors pane. Exceeding this limit will show a scroll bar and allow resizing the pane to display more items."),
414
'default': 9,
415
'minimum': 1
416
},
417
'explorer.openEditors.minVisible': {
418
'type': 'number',
419
'description': nls.localize({ key: 'openEditorsVisibleMin', comment: ['Open is an adjective'] }, "The minimum number of editor slots pre-allocated in the Open Editors pane. If set to 0 the Open Editors pane will dynamically resize based on the number of editors."),
420
'default': 0,
421
'minimum': 0
422
},
423
'explorer.openEditors.sortOrder': {
424
'type': 'string',
425
'enum': ['editorOrder', 'alphabetical', 'fullPath'],
426
'description': nls.localize({ key: 'openEditorsSortOrder', comment: ['Open is an adjective'] }, "Controls the sorting order of editors in the Open Editors pane."),
427
'enumDescriptions': [
428
nls.localize('sortOrder.editorOrder', 'Editors are ordered in the same order editor tabs are shown.'),
429
nls.localize('sortOrder.alphabetical', 'Editors are ordered alphabetically by tab name inside each editor group.'),
430
nls.localize('sortOrder.fullPath', 'Editors are ordered alphabetically by full path inside each editor group.')
431
],
432
'default': 'editorOrder'
433
},
434
'explorer.autoReveal': {
435
'type': ['boolean', 'string'],
436
'enum': [true, false, 'focusNoScroll'],
437
'default': true,
438
'enumDescriptions': [
439
nls.localize('autoReveal.on', 'Files will be revealed and selected.'),
440
nls.localize('autoReveal.off', 'Files will not be revealed and selected.'),
441
nls.localize('autoReveal.focusNoScroll', 'Files will not be scrolled into view, but will still be focused.'),
442
],
443
'description': nls.localize('autoReveal', "Controls whether the Explorer should automatically reveal and select files when opening them.")
444
},
445
'explorer.autoRevealExclude': {
446
'type': 'object',
447
'markdownDescription': nls.localize('autoRevealExclude', "Configure paths or [glob patterns](https://aka.ms/vscode-glob-patterns) for excluding files and folders from being revealed and selected in the Explorer when they are opened. Glob patterns are always evaluated relative to the path of the workspace folder unless they are absolute paths."),
448
'default': { '**/node_modules': true, '**/bower_components': true },
449
'additionalProperties': {
450
'anyOf': [
451
{
452
'type': 'boolean',
453
'description': nls.localize('explorer.autoRevealExclude.boolean', "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern."),
454
},
455
{
456
type: 'object',
457
properties: {
458
when: {
459
type: 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
460
pattern: '\\w*\\$\\(basename\\)\\w*',
461
default: '$(basename).ext',
462
description: nls.localize('explorer.autoRevealExclude.when', 'Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.')
463
}
464
}
465
}
466
]
467
}
468
},
469
'explorer.enableDragAndDrop': {
470
'type': 'boolean',
471
'description': nls.localize('enableDragAndDrop', "Controls whether the Explorer should allow to move files and folders via drag and drop. This setting only effects drag and drop from inside the Explorer."),
472
'default': true
473
},
474
'explorer.confirmDragAndDrop': {
475
'type': 'boolean',
476
'description': nls.localize('confirmDragAndDrop', "Controls whether the Explorer should ask for confirmation to move files and folders via drag and drop."),
477
'default': true
478
},
479
'explorer.confirmPasteNative': {
480
'type': 'boolean',
481
'description': nls.localize('confirmPasteNative', "Controls whether the Explorer should ask for confirmation when pasting native files and folders."),
482
'default': true
483
},
484
'explorer.confirmDelete': {
485
'type': 'boolean',
486
'description': nls.localize('confirmDelete', "Controls whether the Explorer should ask for confirmation when deleting a file via the trash."),
487
'default': true
488
},
489
'explorer.enableUndo': {
490
'type': 'boolean',
491
'description': nls.localize('enableUndo', "Controls whether the Explorer should support undoing file and folder operations."),
492
'default': true
493
},
494
'explorer.confirmUndo': {
495
'type': 'string',
496
'enum': [UndoConfirmLevel.Verbose, UndoConfirmLevel.Default, UndoConfirmLevel.Light],
497
'description': nls.localize('confirmUndo', "Controls whether the Explorer should ask for confirmation when undoing."),
498
'default': UndoConfirmLevel.Default,
499
'enumDescriptions': [
500
nls.localize('enableUndo.verbose', 'Explorer will prompt before all undo operations.'),
501
nls.localize('enableUndo.default', 'Explorer will prompt before destructive undo operations.'),
502
nls.localize('enableUndo.light', 'Explorer will not prompt before undo operations when focused.'),
503
],
504
},
505
'explorer.expandSingleFolderWorkspaces': {
506
'type': 'boolean',
507
'description': nls.localize('expandSingleFolderWorkspaces', "Controls whether the Explorer should expand multi-root workspaces containing only one folder during initialization"),
508
'default': true
509
},
510
'explorer.sortOrder': {
511
'type': 'string',
512
'enum': [SortOrder.Default, SortOrder.Mixed, SortOrder.FilesFirst, SortOrder.Type, SortOrder.Modified, SortOrder.FoldersNestsFiles],
513
'default': SortOrder.Default,
514
'enumDescriptions': [
515
nls.localize('sortOrder.default', 'Files and folders are sorted by their names. Folders are displayed before files.'),
516
nls.localize('sortOrder.mixed', 'Files and folders are sorted by their names. Files are interwoven with folders.'),
517
nls.localize('sortOrder.filesFirst', 'Files and folders are sorted by their names. Files are displayed before folders.'),
518
nls.localize('sortOrder.type', 'Files and folders are grouped by extension type then sorted by their names. Folders are displayed before files.'),
519
nls.localize('sortOrder.modified', 'Files and folders are sorted by last modified date in descending order. Folders are displayed before files.'),
520
nls.localize('sortOrder.foldersNestsFiles', 'Files and folders are sorted by their names. Folders are displayed before files. Files with nested children are displayed before other files.')
521
],
522
'markdownDescription': nls.localize('sortOrder', "Controls the property-based sorting of files and folders in the Explorer. When `#explorer.fileNesting.enabled#` is enabled, also controls sorting of nested files.")
523
},
524
'explorer.sortOrderLexicographicOptions': {
525
'type': 'string',
526
'enum': [LexicographicOptions.Default, LexicographicOptions.Upper, LexicographicOptions.Lower, LexicographicOptions.Unicode],
527
'default': LexicographicOptions.Default,
528
'enumDescriptions': [
529
nls.localize('sortOrderLexicographicOptions.default', 'Uppercase and lowercase names are mixed together.'),
530
nls.localize('sortOrderLexicographicOptions.upper', 'Uppercase names are grouped together before lowercase names.'),
531
nls.localize('sortOrderLexicographicOptions.lower', 'Lowercase names are grouped together before uppercase names.'),
532
nls.localize('sortOrderLexicographicOptions.unicode', 'Names are sorted in Unicode order.')
533
],
534
'description': nls.localize('sortOrderLexicographicOptions', "Controls the lexicographic sorting of file and folder names in the Explorer.")
535
},
536
'explorer.sortOrderReverse': {
537
'type': 'boolean',
538
'description': nls.localize('sortOrderReverse', "Controls whether the file and folder sort order, should be reversed."),
539
'default': false,
540
},
541
'explorer.decorations.colors': {
542
type: 'boolean',
543
description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
544
default: true
545
},
546
'explorer.decorations.badges': {
547
type: 'boolean',
548
description: nls.localize('explorer.decorations.badges', "Controls whether file decorations should use badges."),
549
default: true
550
},
551
'explorer.incrementalNaming': {
552
'type': 'string',
553
enum: ['simple', 'smart', 'disabled'],
554
enumDescriptions: [
555
nls.localize('simple', "Appends the word \"copy\" at the end of the duplicated name potentially followed by a number."),
556
nls.localize('smart', "Adds a number at the end of the duplicated name. If some number is already part of the name, tries to increase that number."),
557
nls.localize('disabled', "Disables incremental naming. If two files with the same name exist you will be prompted to overwrite the existing file.")
558
],
559
description: nls.localize('explorer.incrementalNaming', "Controls which naming strategy to use when giving a new name to a duplicated Explorer item on paste."),
560
default: 'simple'
561
},
562
'explorer.autoOpenDroppedFile': {
563
'type': 'boolean',
564
'description': nls.localize('autoOpenDroppedFile', "Controls whether the Explorer should automatically open a file when it is dropped into the explorer"),
565
'default': true
566
},
567
'explorer.compactFolders': {
568
'type': 'boolean',
569
'description': nls.localize('compressSingleChildFolders', "Controls whether the Explorer should render folders in a compact form. In such a form, single child folders will be compressed in a combined tree element. Useful for Java package structures, for example."),
570
'default': true
571
},
572
'explorer.copyRelativePathSeparator': {
573
'type': 'string',
574
'enum': [
575
'/',
576
'\\',
577
'auto'
578
],
579
'enumDescriptions': [
580
nls.localize('copyRelativePathSeparator.slash', "Use slash as path separation character."),
581
nls.localize('copyRelativePathSeparator.backslash', "Use backslash as path separation character."),
582
nls.localize('copyRelativePathSeparator.auto', "Uses operating system specific path separation character."),
583
],
584
'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths."),
585
'default': 'auto'
586
},
587
'explorer.copyPathSeparator': {
588
'type': 'string',
589
'enum': [
590
'/',
591
'\\',
592
'auto'
593
],
594
'enumDescriptions': [
595
nls.localize('copyPathSeparator.slash', "Use slash as path separation character."),
596
nls.localize('copyPathSeparator.backslash', "Use backslash as path separation character."),
597
nls.localize('copyPathSeparator.auto', "Uses operating system specific path separation character."),
598
],
599
'description': nls.localize('copyPathSeparator', "The path separation character used when copying file paths."),
600
'default': 'auto'
601
},
602
'explorer.excludeGitIgnore': {
603
type: 'boolean',
604
markdownDescription: nls.localize('excludeGitignore', "Controls whether entries in .gitignore should be parsed and excluded from the Explorer. Similar to {0}.", '`#files.exclude#`'),
605
default: false,
606
scope: ConfigurationScope.RESOURCE
607
},
608
'explorer.fileNesting.enabled': {
609
'type': 'boolean',
610
scope: ConfigurationScope.RESOURCE,
611
'markdownDescription': nls.localize('fileNestingEnabled', "Controls whether file nesting is enabled in the Explorer. File nesting allows for related files in a directory to be visually grouped together under a single parent file."),
612
'default': false,
613
},
614
'explorer.fileNesting.expand': {
615
'type': 'boolean',
616
'markdownDescription': nls.localize('fileNestingExpand', "Controls whether file nests are automatically expanded. {0} must be set for this to take effect.", '`#explorer.fileNesting.enabled#`'),
617
'default': true,
618
},
619
'explorer.fileNesting.patterns': {
620
'type': 'object',
621
scope: ConfigurationScope.RESOURCE,
622
'markdownDescription': nls.localize('fileNestingPatterns', "Controls nesting of files in the Explorer. {0} must be set for this to take effect. Each __Item__ represents a parent pattern and may contain a single `*` character that matches any string. Each __Value__ represents a comma separated list of the child patterns that should be shown nested under a given parent. Child patterns may contain several special tokens:\n- `${capture}`: Matches the resolved value of the `*` from the parent pattern\n- `${basename}`: Matches the parent file's basename, the `file` in `file.ts`\n- `${extname}`: Matches the parent file's extension, the `ts` in `file.ts`\n- `${dirname}`: Matches the parent file's directory name, the `src` in `src/file.ts`\n- `*`: Matches any string, may only be used once per child pattern", '`#explorer.fileNesting.enabled#`'),
623
patternProperties: {
624
'^[^*]*\\*?[^*]*$': {
625
markdownDescription: nls.localize('fileNesting.description', "Each key pattern may contain a single `*` character which will match any string."),
626
type: 'string',
627
pattern: '^([^,*]*\\*?[^,*]*)(, ?[^,*]*\\*?[^,*]*)*$',
628
}
629
},
630
additionalProperties: false,
631
'default': {
632
'*.ts': '${capture}.js',
633
'*.js': '${capture}.js.map, ${capture}.min.js, ${capture}.d.ts',
634
'*.jsx': '${capture}.js',
635
'*.tsx': '${capture}.ts',
636
'tsconfig.json': 'tsconfig.*.json',
637
'package.json': 'package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, bun.lock',
638
}
639
}
640
}
641
});
642
643
UndoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
644
const undoRedoService = accessor.get(IUndoRedoService);
645
const explorerService = accessor.get(IExplorerService);
646
const configurationService = accessor.get(IConfigurationService);
647
648
const explorerCanUndo = configurationService.getValue<IFilesConfiguration>().explorer.enableUndo;
649
if (explorerService.hasViewFocus() && undoRedoService.canUndo(UNDO_REDO_SOURCE) && explorerCanUndo) {
650
undoRedoService.undo(UNDO_REDO_SOURCE);
651
return true;
652
}
653
654
return false;
655
});
656
657
RedoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
658
const undoRedoService = accessor.get(IUndoRedoService);
659
const explorerService = accessor.get(IExplorerService);
660
const configurationService = accessor.get(IConfigurationService);
661
662
const explorerCanUndo = configurationService.getValue<IFilesConfiguration>().explorer.enableUndo;
663
if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE) && explorerCanUndo) {
664
undoRedoService.redo(UNDO_REDO_SOURCE);
665
return true;
666
}
667
668
return false;
669
});
670
671
ModesRegistry.registerLanguage({
672
id: BINARY_TEXT_FILE_MODE,
673
aliases: ['Binary'],
674
mimetypes: ['text/x-code-binary']
675
});
676
677