files.contribution.ts 25.0 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 } 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 { 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';
E
Erich Gamma 已提交
36

I
isidor 已提交
37
class FileUriLabelContribution implements IWorkbenchContribution {
38

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

I
isidor 已提交
54
registerSingleton(IExplorerService, ExplorerService, true);
I
isidor 已提交
55

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

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

71 72
	typeId: FILE_EDITOR_INPUT_ID,

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

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

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

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

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

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

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

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

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

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

107
const hotExitConfiguration: IConfigurationPropertySchema = isNative ?
108 109 110 111 112 113
	{
		'type': 'string',
		'scope': ConfigurationScope.APPLICATION,
		'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
		'default': HotExitConfiguration.ON_EXIT,
		'markdownEnumDescriptions': [
114
			nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with dirty files.'),
115 116
			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...`')
117 118 119 120 121 122 123 124
		],
		'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': [
125
			nls.localize('hotExit.off', 'Disable hot exit. A prompt will show when attempting to close a window with dirty files.'),
126 127 128 129 130
			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 已提交
131 132
configurationRegistry.registerConfiguration({
	'id': 'files',
133
	'order': 9,
134
	'title': nls.localize('filesConfigurationTitle', "Files"),
E
Erich Gamma 已提交
135 136
	'type': 'object',
	'properties': {
137
		[FILES_EXCLUDE_CONFIG]: {
E
Erich Gamma 已提交
138
			'type': 'object',
139
			'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)."),
P
Peter V 已提交
140
			'default': { '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true },
S
Sandeep Somavarapu 已提交
141
			'scope': ConfigurationScope.RESOURCE,
E
Erich Gamma 已提交
142 143 144 145 146 147 148 149 150 151 152 153 154
			'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 已提交
155
								'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 已提交
156 157 158 159 160 161
							}
						}
					}
				]
			}
		},
162
		[FILES_ASSOCIATIONS_CONFIG]: {
163
			'type': 'object',
164
			'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 已提交
165 166 167
			'additionalProperties': {
				'type': 'string'
			}
168
		},
E
Erich Gamma 已提交
169 170 171 172
		'files.encoding': {
			'type': 'string',
			'enum': Object.keys(SUPPORTED_ENCODINGS),
			'default': 'utf8',
173
			'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 已提交
174
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
175
			'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
176
			'enumItemLabels': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong)
E
Erich Gamma 已提交
177
		},
178
		'files.autoGuessEncoding': {
179 180
			'type': 'boolean',
			'default': false,
181
			'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."),
182
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
183
		},
184 185 186 187
		'files.eol': {
			'type': 'string',
			'enum': [
				'\n',
S
Sandeep Somavarapu 已提交
188 189
				'\r\n',
				'auto'
190
			],
191 192
			'enumDescriptions': [
				nls.localize('eol.LF', "LF"),
S
Sandeep Somavarapu 已提交
193 194
				nls.localize('eol.CRLF', "CRLF"),
				nls.localize('eol.auto', "Uses operating system specific end of line character.")
195
			],
S
Sandeep Somavarapu 已提交
196
			'default': 'auto',
197
			'description': nls.localize('eol', "The default end of line character."),
S
Sandeep Somavarapu 已提交
198
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
199
		},
B
Benjamin Pasero 已提交
200 201 202 203 204
		'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 已提交
205 206 207
		'files.trimTrailingWhitespace': {
			'type': 'boolean',
			'default': false,
208
			'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
S
Sandeep Somavarapu 已提交
209
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
210 211 212 213
		},
		'files.insertFinalNewline': {
			'type': 'boolean',
			'default': false,
214
			'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
S
Sandeep Somavarapu 已提交
215
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
216
		},
217 218 219 220
		'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 已提交
221
			scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
222
		},
223 224
		'files.autoSave': {
			'type': 'string',
B
Benjamin Pasero 已提交
225
			'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
226
			'markdownEnumDescriptions': [
B
Benjamin Pasero 已提交
227 228 229 230
				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.")
231
			],
232
			'default': isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
B
Benjamin Pasero 已提交
233
			'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)
234
		},
235
		'files.autoSaveDelay': {
236
			'type': 'number',
237
			'default': 1000,
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: '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)
239 240
		},
		'files.watcherExclude': {
241
			'type': 'object',
242
			'default': { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true, '**/.hg/store/**': true },
243
			'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/**`). Changing this setting requires a restart. When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load."),
S
Sandeep Somavarapu 已提交
244
			'scope': ConfigurationScope.RESOURCE
D
Daniel Imms 已提交
245
		},
246
		'files.hotExit': hotExitConfiguration,
247 248
		'files.defaultLanguage': {
			'type': 'string',
249
			'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.")
250 251 252 253
		},
		'files.maxMemoryForLargeFilesMB': {
			'type': 'number',
			'default': 4096,
254
			'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."),
255
			included: isNative
256
		},
257 258 259 260
		'files.restoreUndoStack': {
			'type': 'boolean',
			'description': nls.localize('files.restoreUndoStack', "Restore the undo stack when a file is reopened."),
			'default': true
261
		},
262 263 264 265 266 267 268 269 270 271 272 273
		'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 已提交
274
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE
275
		},
276 277 278
		'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."),
279
			'default': false
280 281 282 283 284
		}
	}
});

configurationRegistry.registerConfiguration({
285
	...editorConfigurationBaseNode,
286
	properties: {
287 288
		'editor.formatOnSave': {
			'type': 'boolean',
J
Johannes Rieken 已提交
289
			'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."),
290 291 292
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
		},
		'editor.formatOnSaveMode': {
293
			'type': 'string',
294
			'default': 'file',
295 296 297 298 299
			'enum': [
				'file',
				'modifications'
			],
			'enumDescriptions': [
300 301
				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)."),
302
			],
303
			'markdownDescription': nls.localize('formatOnSaveMode', "Controls if format on save formats the whole file or only modifications. Only applies when `#editor.formatOnSave#` is enabled."),
304 305
			'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE,
		},
E
Erich Gamma 已提交
306 307 308 309 310
	}
});

configurationRegistry.registerConfiguration({
	'id': 'explorer',
311
	'order': 10,
312
	'title': nls.localize('explorerConfigurationTitle', "File Explorer"),
E
Erich Gamma 已提交
313 314
	'type': 'object',
	'properties': {
315
		'explorer.openEditors.visible': {
E
Erich Gamma 已提交
316
			'type': 'number',
I
isidor 已提交
317
			'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 已提交
318 319
			'default': 9
		},
I
isidor 已提交
320 321 322 323 324 325 326 327 328 329
		'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'
		},
330
		'explorer.autoReveal': {
331
			'type': ['boolean', 'string'],
I
isidor 已提交
332
			'enum': [true, false, 'focusNoScroll'],
J
James Koss 已提交
333
			'default': true,
334 335 336
			'enumDescriptions': [
				nls.localize('autoReveal.on', 'Files will be revealed and selected.'),
				nls.localize('autoReveal.off', 'Files will not be revealed and selected.'),
I
isidor 已提交
337
				nls.localize('autoReveal.focusNoScroll', 'Files will not be scrolled into view, but will still be focused.'),
338 339
			],
			'description': nls.localize('autoReveal', "Controls whether the explorer should automatically reveal and select files when opening them.")
340 341 342
		},
		'explorer.enableDragAndDrop': {
			'type': 'boolean',
343
			'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."),
344
			'default': true
345
		},
346 347
		'explorer.confirmDragAndDrop': {
			'type': 'boolean',
R
Rob Lourens 已提交
348
			'description': nls.localize('confirmDragAndDrop', "Controls whether the explorer should ask for confirmation to move files and folders via drag and drop."),
349 350
			'default': true
		},
351 352
		'explorer.confirmDelete': {
			'type': 'boolean',
R
Rob Lourens 已提交
353
			'description': nls.localize('confirmDelete', "Controls whether the explorer should ask for confirmation when deleting a file via the trash."),
354 355
			'default': true
		},
356 357
		'explorer.sortOrder': {
			'type': 'string',
358 359
			'enum': [SortOrder.Default, SortOrder.Mixed, SortOrder.FilesFirst, SortOrder.Type, SortOrder.Modified],
			'default': SortOrder.Default,
360
			'enumDescriptions': [
361 362 363
				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.'),
364
				nls.localize('sortOrder.type', 'Files and folders are grouped by extension type then sorted by their names. Folders are displayed before files.'),
365
				nls.localize('sortOrder.modified', 'Files and folders are sorted by last modified date in descending order. Folders are displayed before files.')
366
			],
367
			'description': nls.localize('sortOrder', "Controls the property-based sorting of files and folders in the explorer.")
368
		},
369
		'explorer.sortOrderLexicographicOptions': {
370
			'type': 'string',
371 372
			'enum': [LexicographicOptions.Default, LexicographicOptions.Upper, LexicographicOptions.Lower, LexicographicOptions.Unicode],
			'default': LexicographicOptions.Default,
373
			'enumDescriptions': [
374 375
				nls.localize('sortOrderLexicographicOptions.default', 'Uppercase and lowercase names are mixed together.'),
				nls.localize('sortOrderLexicographicOptions.upper', 'Uppercase names are grouped together before lowercase names.'),
376
				nls.localize('sortOrderLexicographicOptions.lower', 'Lowercase names are grouped together before uppercase names.'),
377
				nls.localize('sortOrderLexicographicOptions.unicode', 'Names are sorted in unicode order.')
378
			],
379
			'description': nls.localize('sortOrderLexicographicOptions', "Controls the lexicographic sorting of file and folder names in the explorer.")
380
		},
381
		'explorer.decorations.colors': {
382
			type: 'boolean',
R
Rob Lourens 已提交
383
			description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
384
			default: true
385
		},
386
		'explorer.decorations.badges': {
387
			type: 'boolean',
R
Rob Lourens 已提交
388
			description: nls.localize('explorer.decorations.badges', "Controls whether file decorations should use badges."),
389 390
			default: true
		},
I
isidor 已提交
391
		'explorer.incrementalNaming': {
392
			'type': 'string',
I
isidor 已提交
393 394 395 396 397 398 399
			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 已提交
400
		},
J
Joao Moreno 已提交
401
		'explorer.compactFolders': {
J
Joao Moreno 已提交
402
			'type': 'boolean',
J
Joao Moreno 已提交
403
			'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."),
404
			'default': true
J
Joao Moreno 已提交
405
		},
406 407 408 409 410 411 412 413 414 415 416 417
		'explorer.copyRelativePathSeparator': {
			'type': 'string',
			'enum': [
				'/',
				'\\'
			],
			'enumDescriptions': [
				nls.localize('copyRelativePathSeparator.slash', "Use slash as path separation character."),
				nls.localize('copyRelativePathSeparator.backslash', "Use backslash as path separation character."),
			],
			'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths. Will use the operating system default unless specified."),
		}
E
Erich Gamma 已提交
418
	}
419
});
420

421
UndoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
422 423
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
424
	if (explorerService.hasViewFocus() && undoRedoService.canUndo(UNDO_REDO_SOURCE)) {
425
		undoRedoService.undo(UNDO_REDO_SOURCE);
I
isidor 已提交
426 427 428 429 430 431
		return true;
	}

	return false;
});

432
RedoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
433 434
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
435
	if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE)) {
436
		undoRedoService.redo(UNDO_REDO_SOURCE);
I
isidor 已提交
437 438 439 440
		return true;
	}

	return false;
441
});