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

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

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

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

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

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

72 73
	typeId: FILE_EDITOR_INPUT_ID,

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

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

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

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

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

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

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

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

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

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

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

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

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

427
UndoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
428 429
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
430
	if (explorerService.hasViewFocus() && undoRedoService.canUndo(UNDO_REDO_SOURCE)) {
431
		undoRedoService.undo(UNDO_REDO_SOURCE);
I
isidor 已提交
432 433 434 435 436 437
		return true;
	}

	return false;
});

438
RedoCommand.addImplementation(110, 'explorer', (accessor: ServicesAccessor) => {
I
isidor 已提交
439 440
	const undoRedoService = accessor.get(IUndoRedoService);
	const explorerService = accessor.get(IExplorerService);
441
	if (explorerService.hasViewFocus() && undoRedoService.canRedo(UNDO_REDO_SOURCE)) {
442
		undoRedoService.redo(UNDO_REDO_SOURCE);
I
isidor 已提交
443 444 445 446
		return true;
	}

	return false;
447
});
448 449 450 451 452 453

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