files.contribution.ts 26.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6
import * as nls from 'vs/nls';
7
import { sep } from 'vs/base/common/path';
8
import { Registry } from 'vs/platform/registry/common/platform';
M
Matt Bierner 已提交
9
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
10
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
B
Benjamin Pasero 已提交
11
import { IFileEditorInput, IEditorFactoryRegistry, EditorExtensions } from 'vs/workbench/common/editor';
12
import { AutoSaveConfiguration, HotExitConfiguration, FILES_EXCLUDE_CONFIG, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files';
13
import { SortOrder, LexicographicOptions, FILE_EDITOR_INPUT_ID, BINARY_TEXT_FILE_MODE } from 'vs/workbench/contrib/files/common/files';
B
Benjamin Pasero 已提交
14
import { TextFileEditorTracker } from 'vs/workbench/contrib/files/browser/editors/textFileEditorTracker';
15
import { TextFileSaveErrorHandler } from 'vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler';
16
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput';
17
import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor';
B
Benjamin Pasero 已提交
18
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
19
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
20
import { isLinux, isNative, isWeb, isWindows } from 'vs/base/common/platform';
21
import { ExplorerViewletViewsContribution } from 'vs/workbench/contrib/files/browser/explorerViewlet';
22
import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor';
23
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
I
isidor 已提交
24
import { ILabelService } from 'vs/platform/label/common/label';
I
isidor 已提交
25
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
26
import { ExplorerService, UNDO_REDO_SOURCE } from 'vs/workbench/contrib/files/browser/explorerService';
27
import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/encoding';
28
import { Schemas } from 'vs/base/common/network';
B
Benjamin Pasero 已提交
29
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/common/workspaceWatcher';
30
import { editorConfigurationBaseNode } from 'vs/editor/common/config/commonEditorConfig';
31
import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator';
I
isidor 已提交
32 33
import { UndoCommand, RedoCommand } from 'vs/editor/browser/editorExtensions';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
34 35
import { IExplorerService } from 'vs/workbench/contrib/files/browser/files';
import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler';
36
import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry';
37
import product from 'vs/platform/product/common/product';
E
Erich Gamma 已提交
38

I
isidor 已提交
39
class FileUriLabelContribution implements IWorkbenchContribution {
40

I
isidor 已提交
41
	constructor(@ILabelService labelService: ILabelService) {
42
		labelService.registerFormatter({
43
			scheme: Schemas.file,
44
			formatting: {
45
				label: '${authority}${path}',
46
				separator: sep,
47 48
				tildify: !isWindows,
				normalizeDriveLetter: isWindows,
49
				authorityPrefix: sep + sep,
50
				workspaceSuffix: ''
51
			}
52 53 54 55
		});
	}
}

I
isidor 已提交
56
registerSingleton(IExplorerService, ExplorerService, true);
I
isidor 已提交
57

E
Erich Gamma 已提交
58
// Register file editors
B
Benjamin Pasero 已提交
59
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
60
	EditorPaneDescriptor.create(
61 62 63
		BinaryFileEditor,
		BinaryFileEditor.ID,
		nls.localize('binaryFileEditor', "Binary File Editor")
E
Erich Gamma 已提交
64 65
	),
	[
66
		new SyncDescriptor(FileEditorInput)
E
Erich Gamma 已提交
67 68 69
	]
);

70
// Register default file input factory
B
Benjamin Pasero 已提交
71
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({
72

73 74
	typeId: FILE_EDITOR_INPUT_ID,

B
Benjamin Pasero 已提交
75
	createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode, preferredContents, instantiationService): IFileEditorInput => {
76
		return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode, preferredContents);
77 78
	},

B
Benjamin Pasero 已提交
79
	isFileEditor: (obj): obj is IFileEditorInput => {
80
		return obj instanceof FileEditorInput;
81 82
	}
});
E
Erich Gamma 已提交
83

84
// Register Editor Input Serializer & Handler
B
Benjamin Pasero 已提交
85
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(FILE_EDITOR_INPUT_ID, FileEditorInputSerializer);
86
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(FileEditorWorkingCopyEditorHandler, LifecyclePhase.Ready);
E
Erich Gamma 已提交
87

S
Sandeep Somavarapu 已提交
88 89 90
// Register Explorer views
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ExplorerViewletViewsContribution, LifecyclePhase.Starting);

B
Benjamin Pasero 已提交
91 92
// Register Text File Editor Tracker
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(TextFileEditorTracker, LifecyclePhase.Starting);
E
Erich Gamma 已提交
93

94 95
// Register Text File Save Error Handler
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(TextFileSaveErrorHandler, LifecyclePhase.Starting);
B
Benjamin Pasero 已提交
96

97
// Register uri display for file uris
I
isidor 已提交
98
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(FileUriLabelContribution, LifecyclePhase.Starting);
99

100
// Register Workspace Watcher
B
Benjamin Pasero 已提交
101
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceWatcher, LifecyclePhase.Restored);
102

103 104 105
// Register Dirty Files Indicator
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DirtyFilesIndicator, LifecyclePhase.Starting);

E
Erich Gamma 已提交
106
// Configuration
B
Benjamin Pasero 已提交
107
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
E
Erich Gamma 已提交
108

109
const hotExitConfiguration: IConfigurationPropertySchema = isNative ?
110 111 112 113 114 115
	{
		'type': 'string',
		'scope': ConfigurationScope.APPLICATION,
		'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
		'default': HotExitConfiguration.ON_EXIT,
		'markdownEnumDescriptions': [
116
			nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with dirty files.'),
117 118
			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...`'),
			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...`')
119 120 121 122 123 124 125 126
		],
		'description': nls.localize('hotExit', "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)
	} : {
		'type': 'string',
		'scope': ConfigurationScope.APPLICATION,
		'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
		'default': HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE,
		'markdownEnumDescriptions': [
127
			nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with dirty files.'),
128 129 130 131 132
			nls.localize('hotExit.onExitAndWindowCloseBrowser', 'Hot exit will be triggered when the browser quits or the window or tab is closed.')
		],
		'description': nls.localize('hotExit', "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)
	};

E
Erich Gamma 已提交
133 134
configurationRegistry.registerConfiguration({
	'id': 'files',
135
	'order': 9,
136
	'title': nls.localize('filesConfigurationTitle', "Files"),
E
Erich Gamma 已提交
137 138
	'type': 'object',
	'properties': {
139
		[FILES_EXCLUDE_CONFIG]: {
E
Erich Gamma 已提交
140
			'type': 'object',
141
			'markdownDescription': nls.localize('exclude', "Configure 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. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options)."),
142 143
			'default': {
				...{ '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true, '**/Thumbs.db': true },
144
				...(isWeb ? { '**/*.crswap': true /* filter out swap files used for local file access */ } : undefined)
145
			},
S
Sandeep Somavarapu 已提交
146
			'scope': ConfigurationScope.RESOURCE,
E
Erich Gamma 已提交
147 148 149 150 151 152 153 154 155 156 157 158 159
			'additionalProperties': {
				'anyOf': [
					{
						'type': 'boolean',
						'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."),
					},
					{
						'type': 'object',
						'properties': {
							'when': {
								'type': 'string', // expression ({ "**/*.js": { "when": "$(basename).js" } })
								'pattern': '\\w*\\$\\(basename\\)\\w*',
								'default': '$(basename).ext',
B
Benjamin Pasero 已提交
160
								'description': nls.localize('files.exclude.when', "Additional check on the siblings of a matching file. Use $(basename) as variable for the matching file name.")
E
Erich Gamma 已提交
161 162 163 164 165 166
							}
						}
					}
				]
			}
		},
167
		[FILES_ASSOCIATIONS_CONFIG]: {
168
			'type': 'object',
169
			'markdownDescription': nls.localize('associations', "Configure file associations to languages (e.g. `\"*.extension\": \"html\"`). These have precedence over the default associations of the languages installed."),
A
Aditya Thakral 已提交
170 171 172
			'additionalProperties': {
				'type': 'string'
			}
173
		},
E
Erich Gamma 已提交
174 175 176 177
		'files.encoding': {
			'type': 'string',
			'enum': Object.keys(SUPPORTED_ENCODINGS),
			'default': 'utf8',
178
			'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),
S
Sandeep Somavarapu 已提交
179
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
180
			'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
181
			'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong)
E
Erich Gamma 已提交
182
		},
183
		'files.autoGuessEncoding': {
184 185
			'type': 'boolean',
			'default': false,
186
			'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 `#files.encoding#` is respected."),
187
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
188
		},
189 190 191 192
		'files.eol': {
			'type': 'string',
			'enum': [
				'\n',
S
Sandeep Somavarapu 已提交
193 194
				'\r\n',
				'auto'
195
			],
196 197
			'enumDescriptions': [
				nls.localize('eol.LF', "LF"),
S
Sandeep Somavarapu 已提交
198 199
				nls.localize('eol.CRLF', "CRLF"),
				nls.localize('eol.auto', "Uses operating system specific end of line character.")
200
			],
S
Sandeep Somavarapu 已提交
201
			'default': 'auto',
202
			'description': nls.localize('eol', "The default end of line character."),
S
Sandeep Somavarapu 已提交
203
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
204
		},
B
Benjamin Pasero 已提交
205 206 207 208 209
		'files.enableTrash': {
			'type': 'boolean',
			'default': true,
			'description': nls.localize('useTrash', "Moves files/folders to the OS trash (recycle bin on Windows) when deleting. Disabling this will delete files/folders permanently.")
		},
E
Erich Gamma 已提交
210 211 212
		'files.trimTrailingWhitespace': {
			'type': 'boolean',
			'default': false,
213
			'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
S
Sandeep Somavarapu 已提交
214
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
215 216 217 218
		},
		'files.insertFinalNewline': {
			'type': 'boolean',
			'default': false,
219
			'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
S
Sandeep Somavarapu 已提交
220
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
221
		},
222 223 224 225
		'files.trimFinalNewlines': {
			'type': 'boolean',
			'default': false,
			'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."),
S
Sandeep Somavarapu 已提交
226
			scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
227
		},
228 229
		'files.autoSave': {
			'type': 'string',
B
Benjamin Pasero 已提交
230
			'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
231
			'markdownEnumDescriptions': [
B
Benjamin Pasero 已提交
232 233 234 235
				nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "A dirty editor is never automatically saved."),
				nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "A dirty editor is automatically saved after the configured `#files.autoSaveDelay#`."),
				nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "A dirty editor is automatically saved when the editor loses focus."),
				nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "A dirty editor is automatically saved when the window loses focus.")
236
			],
237
			'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
B
Benjamin Pasero 已提交
238
			'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 of dirty editors. Read more about autosave [here](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save).", AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE, AutoSaveConfiguration.AFTER_DELAY)
239
		},
240
		'files.autoSaveDelay': {
241
			'type': 'number',
242
			'default': 1000,
B
Benjamin Pasero 已提交
243
			'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 ms after which a dirty editor is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY)
244 245
		},
		'files.watcherExclude': {
246
			'type': 'object',
247
			'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true, '**/.hg/store/**': true },
248 249 250 251 252 253 254 255 256 257
			'markdownDescription': nls.localize('watcherExclude', "Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths, i.e. prefix with `**/` or the full path to match properly and suffix with `/**` to match files within a path (for example `**/build/output/**` or `/Users/name/workspaces/project/build/output/**`). When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load."),
			'scope': ConfigurationScope.RESOURCE
		},
		'files.watcherInclude': {
			'type': 'array',
			'items': {
				'type': 'string'
			},
			'default': [],
			'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 against the workspace folder to form an absolute path."),
S
Sandeep Somavarapu 已提交
258
			'scope': ConfigurationScope.RESOURCE
D
Daniel Imms 已提交
259
		},
260 261 262 263 264
		'files.legacyWatcher': {
			'type': 'boolean',
			'default': product.quality === 'stable' && isLinux,
			'description': nls.localize('legacyWatcher', "Controls the mechanism used for file watching. Only change this when you see issues related to file watching."),
		},
265
		'files.hotExit': hotExitConfiguration,
266 267
		'files.defaultLanguage': {
			'type': 'string',
268
			'markdownDescription': nls.localize('defaultLanguage', "The default language mode that is assigned to new files. If configured to `${activeEditorLanguage}`, will use the language mode of the currently active text editor if any.")
269 270 271 272
		},
		'files.maxMemoryForLargeFilesMB': {
			'type': 'number',
			'default': 4096,
273
			'markdownDescription': nls.localize('maxMemoryForLargeFilesMB', "Controls the memory available to VS Code after restart when trying to open large files. Same effect as specifying `--max-memory=NEWSIZE` on the command line."),
274
			included: isNative
275
		},
276 277 278 279
		'files.restoreUndoStack': {
			'type': 'boolean',
			'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."),
			'default': true
280
		},
281 282 283 284 285 286 287 288 289 290 291 292
		'files.saveConflictResolution': {
			'type': 'string',
			'enum': [
				'askUser',
				'overwriteFileOnDisk'
			],
			'enumDescriptions': [
				nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."),
				nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.")
			],
			'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."),
			'default': 'askUser',
S
Sandeep Somavarapu 已提交
293
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
294
		},
295 296 297
		'files.simpleDialog.enable': {
			'type': 'boolean',
			'description': nls.localize('files.simpleDialog.enable', "Enables the simple file dialog. The simple file dialog replaces the system file dialog when enabled."),
298
			'default': false
299 300 301 302 303
		}
	}
});

configurationRegistry.registerConfiguration({
304
	...editorConfigurationBaseNode,
305
	properties: {
306 307
		'editor.formatOnSave': {
			'type': 'boolean',
J
Johannes Rieken 已提交
308
			'description': nls.localize('formatOnSave', "Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down."),
309 310 311
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
		},
		'editor.formatOnSaveMode': {
312
			'type': 'string',
313
			'default': 'file',
314 315
			'enum': [
				'file',
I
Isaac Kilbourne 已提交
316 317
				'modifications',
				'modificationsIfAvailable'
318 319
			],
			'enumDescriptions': [
320 321
				nls.localize({ key: 'everything', comment: ['This is the description of an option'] }, "Format the whole file."),
				nls.localize({ key: 'modification', comment: ['This is the description of an option'] }, "Format modifications (requires source control)."),
I
Isaac Kilbourne 已提交
322
				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."),
323
			],
324
			'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."),
325 326
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
		},
E
Erich Gamma 已提交
327 328 329 330 331
	}
});

configurationRegistry.registerConfiguration({
	'id': 'explorer',
332
	'order': 10,
333
	'title': nls.localize('explorerConfigurationTitle', "File Explorer"),
E
Erich Gamma 已提交
334 335
	'type': 'object',
	'properties': {
336
		'explorer.openEditors.visible': {
E
Erich Gamma 已提交
337
			'type': 'number',
I
isidor 已提交
338
			'description': nls.localize({ key: 'openEditorsVisible', comment: ['Open is an adjective'] }, "Number of editors shown in the Open Editors pane. Setting this to 0 hides the Open Editors pane."),
E
Erich Gamma 已提交
339 340
			'default': 9
		},
I
isidor 已提交
341 342 343 344 345 346 347 348 349 350
		'explorer.openEditors.sortOrder': {
			'type': 'string',
			'enum': ['editorOrder', 'alphabetical'],
			'description': nls.localize({ key: 'openEditorsSortOrder', comment: ['Open is an adjective'] }, "Controls the sorting order of editors in the Open Editors pane."),
			'enumDescriptions': [
				nls.localize('sortOrder.editorOrder', 'Editors are ordered in the same order editor tabs are shown.'),
				nls.localize('sortOrder.alphabetical', 'Editors are ordered in alphabetical order inside each editor group.')
			],
			'default': 'editorOrder'
		},
351
		'explorer.autoReveal': {
352
			'type': ['boolean', 'string'],
I
isidor 已提交
353
			'enum': [true, false, 'focusNoScroll'],
J
James Koss 已提交
354
			'default': true,
355 356 357
			'enumDescriptions': [
				nls.localize('autoReveal.on', 'Files will be revealed and selected.'),
				nls.localize('autoReveal.off', 'Files will not be revealed and selected.'),
I
isidor 已提交
358
				nls.localize('autoReveal.focusNoScroll', 'Files will not be scrolled into view, but will still be focused.'),
359 360
			],
			'description': nls.localize('autoReveal', "Controls whether the explorer should automatically reveal and select files when opening them.")
361 362 363
		},
		'explorer.enableDragAndDrop': {
			'type': 'boolean',
364
			'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."),
365
			'default': true
366
		},
367 368
		'explorer.confirmDragAndDrop': {
			'type': 'boolean',
R
Rob Lourens 已提交
369
			'description': nls.localize('confirmDragAndDrop', "Controls whether the explorer should ask for confirmation to move files and folders via drag and drop."),
370 371
			'default': true
		},
372 373
		'explorer.confirmDelete': {
			'type': 'boolean',
R
Rob Lourens 已提交
374
			'description': nls.localize('confirmDelete', "Controls whether the explorer should ask for confirmation when deleting a file via the trash."),
375 376
			'default': true
		},
377 378
		'explorer.sortOrder': {
			'type': 'string',
379 380
			'enum': [SortOrder.Default, SortOrder.Mixed, SortOrder.FilesFirst, SortOrder.Type, SortOrder.Modified],
			'default': SortOrder.Default,
381
			'enumDescriptions': [
382 383 384
				nls.localize('sortOrder.default', 'Files and folders are sorted by their names. Folders are displayed before files.'),
				nls.localize('sortOrder.mixed', 'Files and folders are sorted by their names. Files are interwoven with folders.'),
				nls.localize('sortOrder.filesFirst', 'Files and folders are sorted by their names. Files are displayed before folders.'),
385
				nls.localize('sortOrder.type', 'Files and folders are grouped by extension type then sorted by their names. Folders are displayed before files.'),
386
				nls.localize('sortOrder.modified', 'Files and folders are sorted by last modified date in descending order. Folders are displayed before files.')
387
			],
388
			'description': nls.localize('sortOrder', "Controls the property-based sorting of files and folders in the explorer.")
389
		},
390
		'explorer.sortOrderLexicographicOptions': {
391
			'type': 'string',
392 393
			'enum': [LexicographicOptions.Default, LexicographicOptions.Upper, LexicographicOptions.Lower, LexicographicOptions.Unicode],
			'default': LexicographicOptions.Default,
394
			'enumDescriptions': [
395 396
				nls.localize('sortOrderLexicographicOptions.default', 'Uppercase and lowercase names are mixed together.'),
				nls.localize('sortOrderLexicographicOptions.upper', 'Uppercase names are grouped together before lowercase names.'),
397
				nls.localize('sortOrderLexicographicOptions.lower', 'Lowercase names are grouped together before uppercase names.'),
398
				nls.localize('sortOrderLexicographicOptions.unicode', 'Names are sorted in unicode order.')
399
			],
G
gregvanl 已提交
400
			'description': nls.localize('sortOrderLexicographicOptions', "Controls the lexicographic sorting of file and folder names in the Explorer.")
401
		},
402
		'explorer.decorations.colors': {
403
			type: 'boolean',
R
Rob Lourens 已提交
404
			description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
405
			default: true
406
		},
407
		'explorer.decorations.badges': {
408
			type: 'boolean',
R
Rob Lourens 已提交
409
			description: nls.localize('explorer.decorations.badges', "Controls whether file decorations should use badges."),
410 411
			default: true
		},
I
isidor 已提交
412
		'explorer.incrementalNaming': {
413
			'type': 'string',
I
isidor 已提交
414 415 416 417 418 419 420
			enum: ['simple', 'smart'],
			enumDescriptions: [
				nls.localize('simple', "Appends the word \"copy\" at the end of the duplicated name potentially followed by a number"),
				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")
			],
			description: nls.localize('explorer.incrementalNaming', "Controls what naming strategy to use when a giving a new name to a duplicated explorer item on paste."),
			default: 'simple'
J
Joao Moreno 已提交
421
		},
J
Joao Moreno 已提交
422
		'explorer.compactFolders': {
J
Joao Moreno 已提交
423
			'type': 'boolean',
J
Joao Moreno 已提交
424
			'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."),
425
			'default': true
J
Joao Moreno 已提交
426
		},
427 428 429 430
		'explorer.copyRelativePathSeparator': {
			'type': 'string',
			'enum': [
				'/',
431 432
				'\\',
				'auto'
433 434 435 436
			],
			'enumDescriptions': [
				nls.localize('copyRelativePathSeparator.slash', "Use slash as path separation character."),
				nls.localize('copyRelativePathSeparator.backslash', "Use backslash as path separation character."),
437
				nls.localize('copyRelativePathSeparator.auto', "Uses operating system specific path separation character."),
438
			],
439 440
			'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths."),
			'default': 'auto'
441
		}
E
Erich Gamma 已提交
442
	}
443
});
444

445
UndoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
446 447
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
448
	if (explorerService.hasViewFocus() && undoRedoService.canUndo(UNDO_REDO_SOURCE)) {
449
		undoRedoService.undo(UNDO_REDO_SOURCE);
I
isidor 已提交
450 451 452 453 454 455
		return true;
	}

	return false;
});

456
RedoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
457 458
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
459
	if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE)) {
460
		undoRedoService.redo(UNDO_REDO_SOURCE);
I
isidor 已提交
461 462 463 464
		return true;
	}

	return false;
465
});
466 467 468 469 470 471

ModesRegistry.registerLanguage({
	id: BINARY_TEXT_FILE_MODE,
	aliases: ['Binary'],
	mimetypes: ['text/x-code-binary']
});