Path: blob/main/src/vs/workbench/contrib/files/browser/files.contribution.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as nls from '../../../../nls.js';6import { sep } from '../../../../base/common/path.js';7import { Registry } from '../../../../platform/registry/common/platform.js';8import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from '../../../../platform/configuration/common/configurationRegistry.js';9import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../common/contributions.js';10import { IFileEditorInput, IEditorFactoryRegistry, EditorExtensions } from '../../../common/editor.js';11import { 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';12import { SortOrder, LexicographicOptions, FILE_EDITOR_INPUT_ID, BINARY_TEXT_FILE_MODE, UndoConfirmLevel, IFilesConfiguration } from '../common/files.js';13import { TextFileEditorTracker } from './editors/textFileEditorTracker.js';14import { TextFileSaveErrorHandler } from './editors/textFileSaveErrorHandler.js';15import { FileEditorInput } from './editors/fileEditorInput.js';16import { BinaryFileEditor } from './editors/binaryFileEditor.js';17import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';18import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';19import { isNative, isWeb, isWindows } from '../../../../base/common/platform.js';20import { ExplorerViewletViewsContribution } from './explorerViewlet.js';21import { IEditorPaneRegistry, EditorPaneDescriptor } from '../../../browser/editor.js';22import { ILabelService } from '../../../../platform/label/common/label.js';23import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';24import { ExplorerService, UNDO_REDO_SOURCE } from './explorerService.js';25import { GUESSABLE_ENCODINGS, SUPPORTED_ENCODINGS } from '../../../services/textfile/common/encoding.js';26import { Schemas } from '../../../../base/common/network.js';27import { WorkspaceWatcher } from './workspaceWatcher.js';28import { editorConfigurationBaseNode } from '../../../../editor/common/config/editorConfigurationSchema.js';29import { DirtyFilesIndicator } from '../common/dirtyFilesIndicator.js';30import { UndoCommand, RedoCommand } from '../../../../editor/browser/editorExtensions.js';31import { IUndoRedoService } from '../../../../platform/undoRedo/common/undoRedo.js';32import { IExplorerService } from './files.js';33import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from './editors/fileEditorHandler.js';34import { ModesRegistry } from '../../../../editor/common/languages/modesRegistry.js';35import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';36import { TextFileEditor } from './editors/textFileEditor.js';3738class FileUriLabelContribution implements IWorkbenchContribution {3940static readonly ID = 'workbench.contrib.fileUriLabel';4142constructor(@ILabelService labelService: ILabelService) {43labelService.registerFormatter({44scheme: Schemas.file,45formatting: {46label: '${authority}${path}',47separator: sep,48tildify: !isWindows,49normalizeDriveLetter: isWindows,50authorityPrefix: sep + sep,51workspaceSuffix: ''52}53});54}55}5657registerSingleton(IExplorerService, ExplorerService, InstantiationType.Delayed);5859// Register file editors6061Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(62EditorPaneDescriptor.create(63TextFileEditor,64TextFileEditor.ID,65nls.localize('textFileEditor', "Text File Editor")66),67[68new SyncDescriptor(FileEditorInput)69]70);7172Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(73EditorPaneDescriptor.create(74BinaryFileEditor,75BinaryFileEditor.ID,76nls.localize('binaryFileEditor', "Binary File Editor")77),78[79new SyncDescriptor(FileEditorInput)80]81);8283// Register default file input factory84Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({8586typeId: FILE_EDITOR_INPUT_ID,8788createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => {89return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);90},9192isFileEditor: (obj): obj is IFileEditorInput => {93return obj instanceof FileEditorInput;94}95});9697// Register Editor Input Serializer & Handler98Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(FILE_EDITOR_INPUT_ID, FileEditorInputSerializer);99registerWorkbenchContribution2(FileEditorWorkingCopyEditorHandler.ID, FileEditorWorkingCopyEditorHandler, WorkbenchPhase.BlockRestore);100101// Register Explorer views102registerWorkbenchContribution2(ExplorerViewletViewsContribution.ID, ExplorerViewletViewsContribution, WorkbenchPhase.BlockStartup);103104// Register Text File Editor Tracker105registerWorkbenchContribution2(TextFileEditorTracker.ID, TextFileEditorTracker, WorkbenchPhase.BlockStartup);106107// Register Text File Save Error Handler108registerWorkbenchContribution2(TextFileSaveErrorHandler.ID, TextFileSaveErrorHandler, WorkbenchPhase.BlockStartup);109110// Register uri display for file uris111registerWorkbenchContribution2(FileUriLabelContribution.ID, FileUriLabelContribution, WorkbenchPhase.BlockStartup);112113// Register Workspace Watcher114registerWorkbenchContribution2(WorkspaceWatcher.ID, WorkspaceWatcher, WorkbenchPhase.AfterRestored);115116// Register Dirty Files Indicator117registerWorkbenchContribution2(DirtyFilesIndicator.ID, DirtyFilesIndicator, WorkbenchPhase.BlockStartup);118119// Configuration120const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);121122const hotExitConfiguration: IConfigurationPropertySchema = isNative ?123{124'type': 'string',125'scope': ConfigurationScope.APPLICATION,126'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],127'default': HotExitConfiguration.ON_EXIT,128'markdownEnumDescriptions': [129nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'),130nls.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...`'),131nls.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...`')132],133'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)134} : {135'type': 'string',136'scope': ConfigurationScope.APPLICATION,137'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],138'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE,139'markdownEnumDescriptions': [140nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with editors that have unsaved changes.'),141nls.localize('hotExit.onExitAndWindowCloseBrowser', 'Hot exit will be triggered when the browser quits or the window or tab is closed.')142],143'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)144};145146configurationRegistry.registerConfiguration({147'id': 'files',148'order': 9,149'title': nls.localize('filesConfigurationTitle', "Files"),150'type': 'object',151'properties': {152[FILES_EXCLUDE_CONFIG]: {153'type': 'object',154'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`."),155'default': {156...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/.DS_Store': true, '**/Thumbs.db': true },157...(isWeb ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined)158},159'scope': ConfigurationScope.RESOURCE,160'additionalProperties': {161'anyOf': [162{163'type': 'boolean',164'enum': [true, false],165'enumDescriptions': [nls.localize('trueDescription', "Enable the pattern."), nls.localize('falseDescription', "Disable the pattern.")],166'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."),167},168{169'type': 'object',170'properties': {171'when': {172'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })173'pattern': '\\w*\\$\\(basename\\)\\w*',174'default': '$(basename).ext',175'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.")176}177}178}179]180}181},182[FILES_ASSOCIATIONS_CONFIG]: {183'type': 'object',184'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."),185'additionalProperties': {186'type': 'string'187}188},189'files.encoding': {190'type': 'string',191'enum': Object.keys(SUPPORTED_ENCODINGS),192'default': 'utf8',193'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),194'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,195'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),196'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong)197},198'files.autoGuessEncoding': {199'type': 'boolean',200'default': false,201'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#`'),202'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE203},204'files.candidateGuessEncodings': {205'type': 'array',206'items': {207'type': 'string',208'enum': Object.keys(GUESSABLE_ENCODINGS),209'enumDescriptions': Object.keys(GUESSABLE_ENCODINGS).map(key => GUESSABLE_ENCODINGS[key].labelLong)210},211'default': [],212'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#`'),213'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE214},215'files.eol': {216'type': 'string',217'enum': [218'\n',219'\r\n',220'auto'221],222'enumDescriptions': [223nls.localize('eol.LF', "LF"),224nls.localize('eol.CRLF', "CRLF"),225nls.localize('eol.auto', "Uses operating system specific end of line character.")226],227'default': 'auto',228'description': nls.localize('eol', "The default end of line character."),229'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE230},231'files.enableTrash': {232'type': 'boolean',233'default': true,234'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.")235},236'files.trimTrailingWhitespace': {237'type': 'boolean',238'default': false,239'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),240'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE241},242'files.trimTrailingWhitespaceInRegexAndStrings': {243'type': 'boolean',244'default': true,245'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."),246'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE247},248'files.insertFinalNewline': {249'type': 'boolean',250'default': false,251'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),252'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE253},254'files.trimFinalNewlines': {255'type': 'boolean',256'default': false,257'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."),258scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,259},260'files.autoSave': {261'type': 'string',262'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],263'markdownEnumDescriptions': [264nls.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."),265nls.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#`."),266nls.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."),267nls.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.")268],269'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,270'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),271scope: ConfigurationScope.LANGUAGE_OVERRIDABLE272},273'files.autoSaveDelay': {274'type': 'number',275'default': 1000,276'minimum': 0,277'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),278scope: ConfigurationScope.LANGUAGE_OVERRIDABLE279},280'files.autoSaveWorkspaceFilesOnly': {281'type': 'boolean',282'default': false,283'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#`'),284scope: ConfigurationScope.LANGUAGE_OVERRIDABLE285},286'files.autoSaveWhenNoErrors': {287'type': 'boolean',288'default': false,289'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#`'),290scope: ConfigurationScope.LANGUAGE_OVERRIDABLE291},292'files.watcherExclude': {293'type': 'object',294'patternProperties': {295'.*': { 'type': 'boolean' }296},297'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/.hg/store/**': true },298'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)."),299'scope': ConfigurationScope.RESOURCE300},301'files.watcherInclude': {302'type': 'array',303'items': {304'type': 'string'305},306'default': [],307'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."),308'scope': ConfigurationScope.RESOURCE309},310'files.hotExit': hotExitConfiguration,311'files.defaultLanguage': {312'type': 'string',313'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.")314},315[FILES_READONLY_INCLUDE_CONFIG]: {316'type': 'object',317'patternProperties': {318'.*': { 'type': 'boolean' }319},320'default': {},321'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."),322'scope': ConfigurationScope.RESOURCE323},324[FILES_READONLY_EXCLUDE_CONFIG]: {325'type': 'object',326'patternProperties': {327'.*': { 'type': 'boolean' }328},329'default': {},330'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."),331'scope': ConfigurationScope.RESOURCE332},333[FILES_READONLY_FROM_PERMISSIONS_CONFIG]: {334'type': 'boolean',335'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."),336'default': false337},338'files.restoreUndoStack': {339'type': 'boolean',340'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."),341'default': true342},343'files.saveConflictResolution': {344'type': 'string',345'enum': [346'askUser',347'overwriteFileOnDisk'348],349'enumDescriptions': [350nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."),351nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.")352],353'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."),354'default': 'askUser',355'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE356},357'files.dialog.defaultPath': {358'type': 'string',359'pattern': '^((\\/|\\\\\\\\|[a-zA-Z]:\\\\).*)?$', // slash OR UNC-root OR drive-root OR undefined360'patternErrorMessage': nls.localize('defaultPathErrorMessage', "Default path for file dialogs must be an absolute path (e.g. C:\\\\myFolder or /myFolder)."),361'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."),362'scope': ConfigurationScope.MACHINE363},364'files.simpleDialog.enable': {365'type': 'boolean',366'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."),367'default': false368},369'files.participants.timeout': {370type: 'number',371default: 60000,372markdownDescription: nls.localize('files.participants.timeout', "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use `0` to disable participants."),373}374}375});376377configurationRegistry.registerConfiguration({378...editorConfigurationBaseNode,379properties: {380'editor.formatOnSave': {381'type': 'boolean',382'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#`'),383'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,384},385'editor.formatOnSaveMode': {386'type': 'string',387'default': 'file',388'enum': [389'file',390'modifications',391'modificationsIfAvailable'392],393'enumDescriptions': [394nls.localize({ key: 'everything', comment: ['This is the description of an option'] }, "Format the whole file."),395nls.localize({ key: 'modification', comment: ['This is the description of an option'] }, "Format modifications (requires source control)."),396nls.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."),397],398'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."),399'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,400},401}402});403404configurationRegistry.registerConfiguration({405'id': 'explorer',406'order': 10,407'title': nls.localize('explorerConfigurationTitle', "File Explorer"),408'type': 'object',409'properties': {410'explorer.openEditors.visible': {411'type': 'number',412'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."),413'default': 9,414'minimum': 1415},416'explorer.openEditors.minVisible': {417'type': 'number',418'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."),419'default': 0,420'minimum': 0421},422'explorer.openEditors.sortOrder': {423'type': 'string',424'enum': ['editorOrder', 'alphabetical', 'fullPath'],425'description': nls.localize({ key: 'openEditorsSortOrder', comment: ['Open is an adjective'] }, "Controls the sorting order of editors in the Open Editors pane."),426'enumDescriptions': [427nls.localize('sortOrder.editorOrder', 'Editors are ordered in the same order editor tabs are shown.'),428nls.localize('sortOrder.alphabetical', 'Editors are ordered alphabetically by tab name inside each editor group.'),429nls.localize('sortOrder.fullPath', 'Editors are ordered alphabetically by full path inside each editor group.')430],431'default': 'editorOrder'432},433'explorer.autoReveal': {434'type': ['boolean', 'string'],435'enum': [true, false, 'focusNoScroll'],436'default': true,437'enumDescriptions': [438nls.localize('autoReveal.on', 'Files will be revealed and selected.'),439nls.localize('autoReveal.off', 'Files will not be revealed and selected.'),440nls.localize('autoReveal.focusNoScroll', 'Files will not be scrolled into view, but will still be focused.'),441],442'description': nls.localize('autoReveal', "Controls whether the Explorer should automatically reveal and select files when opening them.")443},444'explorer.autoRevealExclude': {445'type': 'object',446'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."),447'default': { '**/node_modules': true, '**/bower_components': true },448'additionalProperties': {449'anyOf': [450{451'type': 'boolean',452'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."),453},454{455type: 'object',456properties: {457when: {458type: 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })459pattern: '\\w*\\$\\(basename\\)\\w*',460default: '$(basename).ext',461description: nls.localize('explorer.autoRevealExclude.when', 'Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.')462}463}464}465]466}467},468'explorer.enableDragAndDrop': {469'type': 'boolean',470'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."),471'default': true472},473'explorer.confirmDragAndDrop': {474'type': 'boolean',475'description': nls.localize('confirmDragAndDrop', "Controls whether the Explorer should ask for confirmation to move files and folders via drag and drop."),476'default': true477},478'explorer.confirmPasteNative': {479'type': 'boolean',480'description': nls.localize('confirmPasteNative', "Controls whether the Explorer should ask for confirmation when pasting native files and folders."),481'default': true482},483'explorer.confirmDelete': {484'type': 'boolean',485'description': nls.localize('confirmDelete', "Controls whether the Explorer should ask for confirmation when deleting a file via the trash."),486'default': true487},488'explorer.enableUndo': {489'type': 'boolean',490'description': nls.localize('enableUndo', "Controls whether the Explorer should support undoing file and folder operations."),491'default': true492},493'explorer.confirmUndo': {494'type': 'string',495'enum': [UndoConfirmLevel.Verbose, UndoConfirmLevel.Default, UndoConfirmLevel.Light],496'description': nls.localize('confirmUndo', "Controls whether the Explorer should ask for confirmation when undoing."),497'default': UndoConfirmLevel.Default,498'enumDescriptions': [499nls.localize('enableUndo.verbose', 'Explorer will prompt before all undo operations.'),500nls.localize('enableUndo.default', 'Explorer will prompt before destructive undo operations.'),501nls.localize('enableUndo.light', 'Explorer will not prompt before undo operations when focused.'),502],503},504'explorer.expandSingleFolderWorkspaces': {505'type': 'boolean',506'description': nls.localize('expandSingleFolderWorkspaces', "Controls whether the Explorer should expand multi-root workspaces containing only one folder during initialization"),507'default': true508},509'explorer.sortOrder': {510'type': 'string',511'enum': [SortOrder.Default, SortOrder.Mixed, SortOrder.FilesFirst, SortOrder.Type, SortOrder.Modified, SortOrder.FoldersNestsFiles],512'default': SortOrder.Default,513'enumDescriptions': [514nls.localize('sortOrder.default', 'Files and folders are sorted by their names. Folders are displayed before files.'),515nls.localize('sortOrder.mixed', 'Files and folders are sorted by their names. Files are interwoven with folders.'),516nls.localize('sortOrder.filesFirst', 'Files and folders are sorted by their names. Files are displayed before folders.'),517nls.localize('sortOrder.type', 'Files and folders are grouped by extension type then sorted by their names. Folders are displayed before files.'),518nls.localize('sortOrder.modified', 'Files and folders are sorted by last modified date in descending order. Folders are displayed before files.'),519nls.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.')520],521'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.")522},523'explorer.sortOrderLexicographicOptions': {524'type': 'string',525'enum': [LexicographicOptions.Default, LexicographicOptions.Upper, LexicographicOptions.Lower, LexicographicOptions.Unicode],526'default': LexicographicOptions.Default,527'enumDescriptions': [528nls.localize('sortOrderLexicographicOptions.default', 'Uppercase and lowercase names are mixed together.'),529nls.localize('sortOrderLexicographicOptions.upper', 'Uppercase names are grouped together before lowercase names.'),530nls.localize('sortOrderLexicographicOptions.lower', 'Lowercase names are grouped together before uppercase names.'),531nls.localize('sortOrderLexicographicOptions.unicode', 'Names are sorted in Unicode order.')532],533'description': nls.localize('sortOrderLexicographicOptions', "Controls the lexicographic sorting of file and folder names in the Explorer.")534},535'explorer.sortOrderReverse': {536'type': 'boolean',537'description': nls.localize('sortOrderReverse', "Controls whether the file and folder sort order, should be reversed."),538'default': false,539},540'explorer.decorations.colors': {541type: 'boolean',542description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),543default: true544},545'explorer.decorations.badges': {546type: 'boolean',547description: nls.localize('explorer.decorations.badges', "Controls whether file decorations should use badges."),548default: true549},550'explorer.incrementalNaming': {551'type': 'string',552enum: ['simple', 'smart', 'disabled'],553enumDescriptions: [554nls.localize('simple', "Appends the word \"copy\" at the end of the duplicated name potentially followed by a number."),555nls.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."),556nls.localize('disabled', "Disables incremental naming. If two files with the same name exist you will be prompted to overwrite the existing file.")557],558description: nls.localize('explorer.incrementalNaming', "Controls which naming strategy to use when giving a new name to a duplicated Explorer item on paste."),559default: 'simple'560},561'explorer.autoOpenDroppedFile': {562'type': 'boolean',563'description': nls.localize('autoOpenDroppedFile', "Controls whether the Explorer should automatically open a file when it is dropped into the explorer"),564'default': true565},566'explorer.compactFolders': {567'type': 'boolean',568'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."),569'default': true570},571'explorer.copyRelativePathSeparator': {572'type': 'string',573'enum': [574'/',575'\\',576'auto'577],578'enumDescriptions': [579nls.localize('copyRelativePathSeparator.slash', "Use slash as path separation character."),580nls.localize('copyRelativePathSeparator.backslash', "Use backslash as path separation character."),581nls.localize('copyRelativePathSeparator.auto', "Uses operating system specific path separation character."),582],583'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths."),584'default': 'auto'585},586'explorer.copyPathSeparator': {587'type': 'string',588'enum': [589'/',590'\\',591'auto'592],593'enumDescriptions': [594nls.localize('copyPathSeparator.slash', "Use slash as path separation character."),595nls.localize('copyPathSeparator.backslash', "Use backslash as path separation character."),596nls.localize('copyPathSeparator.auto', "Uses operating system specific path separation character."),597],598'description': nls.localize('copyPathSeparator', "The path separation character used when copying file paths."),599'default': 'auto'600},601'explorer.excludeGitIgnore': {602type: 'boolean',603markdownDescription: nls.localize('excludeGitignore', "Controls whether entries in .gitignore should be parsed and excluded from the Explorer. Similar to {0}.", '`#files.exclude#`'),604default: false,605scope: ConfigurationScope.RESOURCE606},607'explorer.fileNesting.enabled': {608'type': 'boolean',609scope: ConfigurationScope.RESOURCE,610'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."),611'default': false,612},613'explorer.fileNesting.expand': {614'type': 'boolean',615'markdownDescription': nls.localize('fileNestingExpand', "Controls whether file nests are automatically expanded. {0} must be set for this to take effect.", '`#explorer.fileNesting.enabled#`'),616'default': true,617},618'explorer.fileNesting.patterns': {619'type': 'object',620scope: ConfigurationScope.RESOURCE,621'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#`'),622patternProperties: {623'^[^*]*\\*?[^*]*$': {624markdownDescription: nls.localize('fileNesting.description', "Each key pattern may contain a single `*` character which will match any string."),625type: 'string',626pattern: '^([^,*]*\\*?[^,*]*)(, ?[^,*]*\\*?[^,*]*)*$',627}628},629additionalProperties: false,630'default': {631'*.ts': '${capture}.js',632'*.js': '${capture}.js.map, ${capture}.min.js, ${capture}.d.ts',633'*.jsx': '${capture}.js',634'*.tsx': '${capture}.ts',635'tsconfig.json': 'tsconfig.*.json',636'package.json': 'package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, bun.lock',637}638}639}640});641642UndoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {643const undoRedoService = accessor.get(IUndoRedoService);644const explorerService = accessor.get(IExplorerService);645const configurationService = accessor.get(IConfigurationService);646647const explorerCanUndo = configurationService.getValue<IFilesConfiguration>().explorer.enableUndo;648if (explorerService.hasViewFocus() && undoRedoService.canUndo(UNDO_REDO_SOURCE) && explorerCanUndo) {649undoRedoService.undo(UNDO_REDO_SOURCE);650return true;651}652653return false;654});655656RedoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {657const undoRedoService = accessor.get(IUndoRedoService);658const explorerService = accessor.get(IExplorerService);659const configurationService = accessor.get(IConfigurationService);660661const explorerCanUndo = configurationService.getValue<IFilesConfiguration>().explorer.enableUndo;662if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE) && explorerCanUndo) {663undoRedoService.redo(UNDO_REDO_SOURCE);664return true;665}666667return false;668});669670ModesRegistry.registerLanguage({671id: BINARY_TEXT_FILE_MODE,672aliases: ['Binary'],673mimetypes: ['text/x-code-binary']674});675676677