files.contribution.ts 23.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.
 *--------------------------------------------------------------------------------------------*/

J
Johannes Rieken 已提交
6
import { URI, UriComponents } from 'vs/base/common/uri';
B
Benjamin Pasero 已提交
7
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ShowViewletAction } from 'vs/workbench/browser/viewlet';
8
import * as nls from 'vs/nls';
9
import { sep } from 'vs/base/common/path';
10
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
11
import { Registry } from 'vs/platform/registry/common/platform';
M
Matt Bierner 已提交
12
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
B
Benjamin Pasero 已提交
13
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
14
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
I
isidor 已提交
15
import { IEditorInputFactory, EditorInput, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
16
import { AutoSaveConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
17 18
import { VIEWLET_ID, SortOrderConfiguration, FILE_EDITOR_INPUT_ID, IExplorerService } from 'vs/workbench/contrib/files/common/files';
import { FileEditorTracker } from 'vs/workbench/contrib/files/browser/editors/fileEditorTracker';
19
import { TextFileSaveErrorHandler } from 'vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler';
20 21
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor';
22
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
23
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
A
Renames  
Alex Dima 已提交
24
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
B
Benjamin Pasero 已提交
25
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
26
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
27
import * as platform from 'vs/base/common/platform';
S
SteVen Batten 已提交
28
import { ExplorerViewletViewsContribution, ExplorerViewlet } from 'vs/workbench/contrib/files/browser/explorerViewlet';
29
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
30
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
31
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
32
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
I
isidor 已提交
33
import { ILabelService } from 'vs/platform/label/common/label';
34
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
I
isidor 已提交
35
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
36
import { ExplorerService } from 'vs/workbench/contrib/files/common/explorerService';
37
import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles';
38
import { Schemas } from 'vs/base/common/network';
B
Benjamin Pasero 已提交
39
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/common/workspaceWatcher';
40
import { editorConfigurationBaseNode } from 'vs/editor/common/config/commonEditorConfig';
41
import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator';
E
Erich Gamma 已提交
42 43

// Viewlet Action
B
Benjamin Pasero 已提交
44
export class OpenExplorerViewletAction extends ShowViewletAction {
45 46
	static readonly ID = VIEWLET_ID;
	static readonly LABEL = nls.localize('showExplorerViewlet', "Show Explorer");
E
Erich Gamma 已提交
47 48 49 50 51

	constructor(
		id: string,
		label: string,
		@IViewletService viewletService: IViewletService,
B
Benjamin Pasero 已提交
52
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
53
		@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
E
Erich Gamma 已提交
54
	) {
55
		super(id, label, VIEWLET_ID, viewletService, editorGroupService, layoutService);
E
Erich Gamma 已提交
56 57 58
	}
}

I
isidor 已提交
59
class FileUriLabelContribution implements IWorkbenchContribution {
60

I
isidor 已提交
61
	constructor(@ILabelService labelService: ILabelService) {
62
		labelService.registerFormatter({
63
			scheme: Schemas.file,
64
			formatting: {
65
				label: '${authority}${path}',
66
				separator: sep,
67
				tildify: !platform.isWindows,
I
isidor 已提交
68
				normalizeDriveLetter: platform.isWindows,
69
				authorityPrefix: sep + sep,
70
				workspaceSuffix: ''
71
			}
72 73 74 75
		});
	}
}

E
Erich Gamma 已提交
76
// Register Viewlet
77
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(ViewletDescriptor.create(
78
	ExplorerViewlet,
E
Erich Gamma 已提交
79
	VIEWLET_ID,
B
Benjamin Pasero 已提交
80
	nls.localize('explore', "Explorer"),
M
Miguel Solorio 已提交
81
	'codicon-files',
E
Erich Gamma 已提交
82 83 84
	0
));

I
isidor 已提交
85
registerSingleton(IExplorerService, ExplorerService, true);
I
isidor 已提交
86

B
Benjamin Pasero 已提交
87
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).setDefaultViewletId(VIEWLET_ID);
E
Erich Gamma 已提交
88

B
Benjamin Pasero 已提交
89
const openViewletKb: IKeybindings = {
E
Erich Gamma 已提交
90 91 92 93
	primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_E
};

// Register Action to Open Viewlet
B
Benjamin Pasero 已提交
94
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
95
registry.registerWorkbenchAction(
96
	SyncActionDescriptor.create(OpenExplorerViewletAction, OpenExplorerViewletAction.ID, OpenExplorerViewletAction.LABEL, openViewletKb),
97
	'View: Show Explorer',
98
	nls.localize('view', "View")
E
Erich Gamma 已提交
99 100 101
);

// Register file editors
B
Benjamin Pasero 已提交
102
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
103
	EditorDescriptor.create(
104 105 106
		BinaryFileEditor,
		BinaryFileEditor.ID,
		nls.localize('binaryFileEditor', "Binary File Editor")
E
Erich Gamma 已提交
107 108
	),
	[
109
		new SyncDescriptor<EditorInput>(FileEditorInput)
E
Erich Gamma 已提交
110 111 112
	]
);

113
// Register default file input factory
114
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerFileInputFactory({
115 116
	createFileInput: (resource, encoding, mode, instantiationService): IFileEditorInput => {
		return instantiationService.createInstance(FileEditorInput, resource, encoding, mode);
117 118 119 120
	},

	isFileInput: (obj): obj is IFileEditorInput => {
		return obj instanceof FileEditorInput;
121 122
	}
});
E
Erich Gamma 已提交
123 124

interface ISerializedFileInput {
125
	resource: string;
B
Benjamin Pasero 已提交
126
	resourceJSON: object;
127
	encoding?: string;
128
	modeId?: string;
E
Erich Gamma 已提交
129 130 131 132 133
}

// Register Editor Input Factory
class FileEditorInputFactory implements IEditorInputFactory {

134 135 136 137
	canSerialize(editorInput: EditorInput): boolean {
		return true;
	}

138
	serialize(editorInput: EditorInput): string {
B
Benjamin Pasero 已提交
139
		const fileEditorInput = <FileEditorInput>editorInput;
140
		const resource = fileEditorInput.getResource();
B
Benjamin Pasero 已提交
141
		const fileInput: ISerializedFileInput = {
142
			resource: resource.toString(), // Keep for backwards compatibility
143
			resourceJSON: resource.toJSON(),
144 145
			encoding: fileEditorInput.getEncoding(),
			modeId: fileEditorInput.getPreferredMode() // only using the preferred user associated mode here if available to not store redundant data
E
Erich Gamma 已提交
146 147 148 149 150
		};

		return JSON.stringify(fileInput);
	}

151
	deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): FileEditorInput {
152 153
		return instantiationService.invokeFunction<FileEditorInput>(accessor => {
			const fileInput: ISerializedFileInput = JSON.parse(serializedEditorInput);
J
Johannes Rieken 已提交
154
			const resource = !!fileInput.resourceJSON ? URI.revive(<UriComponents>fileInput.resourceJSON) : URI.parse(fileInput.resource);
155
			const encoding = fileInput.encoding;
156
			const mode = fileInput.modeId;
E
Erich Gamma 已提交
157

158
			return accessor.get(IEditorService).createInput({ resource, encoding, mode, forceFile: true }) as FileEditorInput;
159
		});
E
Erich Gamma 已提交
160 161 162
	}
}

163
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(FILE_EDITOR_INPUT_ID, FileEditorInputFactory);
E
Erich Gamma 已提交
164

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

168
// Register File Editor Tracker
169
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(FileEditorTracker, LifecyclePhase.Starting);
E
Erich Gamma 已提交
170

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

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

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

180 181 182
// Register Dirty Files Indicator
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DirtyFilesIndicator, LifecyclePhase.Starting);

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

M
Matt Bierner 已提交
186
const hotExitConfiguration: IConfigurationPropertySchema = platform.isNative ?
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
	{
		'type': 'string',
		'scope': ConfigurationScope.APPLICATION,
		'enum': [HotExitConfiguration.OFF, HotExitConfiguration.ON_EXIT, HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE],
		'default': HotExitConfiguration.ON_EXIT,
		'markdownEnumDescriptions': [
			nls.localize('hotExit.off', 'Disable hot exit.'),
			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 with backups will be restored upon next launch.'),
			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. To restore folder windows as they were before shutdown set `#window.restoreWindows#` to `all`.')
		],
		'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': [
			nls.localize('hotExit.off', 'Disable hot exit.'),
			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 已提交
210 211
configurationRegistry.registerConfiguration({
	'id': 'files',
212
	'order': 9,
213
	'title': nls.localize('filesConfigurationTitle', "Files"),
E
Erich Gamma 已提交
214 215 216 217
	'type': 'object',
	'properties': {
		'files.exclude': {
			'type': 'object',
218
			'markdownDescription': nls.localize('exclude', "Configure glob patterns for excluding files and folders. For example, the files explorer decides which files and folders to show or hide based on this setting. Read more about glob patterns [here](https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options)."),
P
Peter V 已提交
219
			'default': { '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true },
S
Sandeep Somavarapu 已提交
220
			'scope': ConfigurationScope.RESOURCE,
E
Erich Gamma 已提交
221 222 223 224 225 226 227 228 229 230 231 232 233
			'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 已提交
234
								'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 已提交
235 236 237 238 239 240
							}
						}
					}
				]
			}
		},
B
Benjamin Pasero 已提交
241
		'files.associations': {
242
			'type': 'object',
243
			'markdownDescription': nls.localize('associations', "Configure file associations to languages (e.g. `\"*.extension\": \"html\"`). These have precedence over the default associations of the languages installed."),
244
		},
E
Erich Gamma 已提交
245 246 247 248
		'files.encoding': {
			'type': 'string',
			'enum': Object.keys(SUPPORTED_ENCODINGS),
			'default': 'utf8',
249
			'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),
250
			'scope': ConfigurationScope.RESOURCE_LANGUAGE,
251 252
			'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
E
Erich Gamma 已提交
253
		},
254
		'files.autoGuessEncoding': {
255 256
			'type': 'boolean',
			'default': false,
257
			'description': 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."),
258
			'scope': ConfigurationScope.RESOURCE_LANGUAGE,
259
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
260
		},
261 262 263 264
		'files.eol': {
			'type': 'string',
			'enum': [
				'\n',
S
Sandeep Somavarapu 已提交
265 266
				'\r\n',
				'auto'
267
			],
268 269
			'enumDescriptions': [
				nls.localize('eol.LF', "LF"),
S
Sandeep Somavarapu 已提交
270 271
				nls.localize('eol.CRLF', "CRLF"),
				nls.localize('eol.auto', "Uses operating system specific end of line character.")
272
			],
S
Sandeep Somavarapu 已提交
273
			'default': 'auto',
274
			'description': nls.localize('eol', "The default end of line character."),
275
			'scope': ConfigurationScope.RESOURCE_LANGUAGE
276
		},
B
Benjamin Pasero 已提交
277 278 279 280 281
		'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 已提交
282 283 284
		'files.trimTrailingWhitespace': {
			'type': 'boolean',
			'default': false,
285
			'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
286
			'scope': ConfigurationScope.RESOURCE_LANGUAGE
287 288 289 290
		},
		'files.insertFinalNewline': {
			'type': 'boolean',
			'default': false,
291
			'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
292
			'scope': ConfigurationScope.RESOURCE_LANGUAGE
293
		},
294 295 296 297
		'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."),
298
			scope: ConfigurationScope.RESOURCE_LANGUAGE,
299
		},
300 301
		'files.autoSave': {
			'type': 'string',
B
Benjamin Pasero 已提交
302
			'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
303
			'markdownEnumDescriptions': [
304
				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 file is never automatically saved."),
305
				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 file is automatically saved after the configured `#files.autoSaveDelay#`."),
306 307
				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 file 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 file is automatically saved when the window loses focus.")
308
			],
B
Benjamin Pasero 已提交
309
			'default': platform.isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
310
			'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 files. 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)
311
		},
312
		'files.autoSaveDelay': {
313
			'type': 'number',
314
			'default': 1000,
315
			'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 file is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY)
316 317
		},
		'files.watcherExclude': {
318
			'type': 'object',
319
			'default': platform.isWindows /* https://github.com/Microsoft/vscode/issues/23954 */ ? { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/*/**': true } : { '**/.git/objects/**': true, '**/.git/subtree-cache/**': true, '**/node_modules/**': true },
B
Benjamin Pasero 已提交
320
			'description': 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). 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 已提交
321
			'scope': ConfigurationScope.RESOURCE
D
Daniel Imms 已提交
322
		},
323
		'files.hotExit': hotExitConfiguration,
324 325 326
		'files.defaultLanguage': {
			'type': 'string',
			'description': nls.localize('defaultLanguage', "The default language mode that is assigned to new files.")
327 328 329 330
		},
		'files.maxMemoryForLargeFilesMB': {
			'type': 'number',
			'default': 4096,
331 332
			'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."),
			included: platform.isNative
333
		},
334 335 336 337 338 339
		'files.preventSaveConflicts': {
			'type': 'boolean',
			'description': nls.localize('files.preventSaveConflicts', "When enabled, will prevent to save a file that has been changed since it was last edited. Instead, a diff editor is provided to compare the changes and accept or revert them. This setting should only be disabled if you frequently encounter save conflict errors and may result in data loss if used without caution."),
			'default': true,
			'scope': ConfigurationScope.RESOURCE
		},
340 341 342
		'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."),
343
			'default': false
344 345 346 347 348
		}
	}
});

configurationRegistry.registerConfiguration({
349
	...editorConfigurationBaseNode,
350
	properties: {
351 352 353
		'editor.formatOnSave': {
			'type': 'boolean',
			'default': false,
J
Johannes Rieken 已提交
354
			'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."),
355
			scope: ConfigurationScope.RESOURCE_LANGUAGE,
356 357 358 359
		},
		'editor.formatOnSaveTimeout': {
			'type': 'number',
			'default': 750,
360
			'description': nls.localize('formatOnSaveTimeout', "Timeout in milliseconds after which the formatting that is run on file save is cancelled."),
361
			scope: ConfigurationScope.RESOURCE_LANGUAGE,
E
Erich Gamma 已提交
362 363 364 365 366 367
		}
	}
});

configurationRegistry.registerConfiguration({
	'id': 'explorer',
368
	'order': 10,
369
	'title': nls.localize('explorerConfigurationTitle', "File Explorer"),
E
Erich Gamma 已提交
370 371
	'type': 'object',
	'properties': {
372
		'explorer.openEditors.visible': {
E
Erich Gamma 已提交
373
			'type': 'number',
374
			'description': nls.localize({ key: 'openEditorsVisible', comment: ['Open is an adjective'] }, "Number of editors shown in the Open Editors pane."),
E
Erich Gamma 已提交
375 376
			'default': 9
		},
377 378
		'explorer.autoReveal': {
			'type': 'boolean',
R
Rob Lourens 已提交
379
			'description': nls.localize('autoReveal', "Controls whether the explorer should automatically reveal and select files when opening them."),
380
			'default': true
381 382 383
		},
		'explorer.enableDragAndDrop': {
			'type': 'boolean',
R
Rob Lourens 已提交
384
			'description': nls.localize('enableDragAndDrop', "Controls whether the explorer should allow to move files and folders via drag and drop."),
385
			'default': true
386
		},
387 388
		'explorer.confirmDragAndDrop': {
			'type': 'boolean',
R
Rob Lourens 已提交
389
			'description': nls.localize('confirmDragAndDrop', "Controls whether the explorer should ask for confirmation to move files and folders via drag and drop."),
390 391
			'default': true
		},
392 393
		'explorer.confirmDelete': {
			'type': 'boolean',
R
Rob Lourens 已提交
394
			'description': nls.localize('confirmDelete', "Controls whether the explorer should ask for confirmation when deleting a file via the trash."),
395 396
			'default': true
		},
397 398 399 400 401
		'explorer.sortOrder': {
			'type': 'string',
			'enum': [SortOrderConfiguration.DEFAULT, SortOrderConfiguration.MIXED, SortOrderConfiguration.FILES_FIRST, SortOrderConfiguration.TYPE, SortOrderConfiguration.MODIFIED],
			'default': SortOrderConfiguration.DEFAULT,
			'enumDescriptions': [
B
Benjamin Pasero 已提交
402 403 404 405 406
				nls.localize('sortOrder.default', 'Files and folders are sorted by their names, in alphabetical order. Folders are displayed before files.'),
				nls.localize('sortOrder.mixed', 'Files and folders are sorted by their names, in alphabetical order. Files are interwoven with folders.'),
				nls.localize('sortOrder.filesFirst', 'Files and folders are sorted by their names, in alphabetical order. Files are displayed before folders.'),
				nls.localize('sortOrder.type', 'Files and folders are sorted by their extensions, in alphabetical order. Folders are displayed before files.'),
				nls.localize('sortOrder.modified', 'Files and folders are sorted by last modified date, in descending order. Folders are displayed before files.')
407
			],
408
			'description': nls.localize('sortOrder', "Controls sorting order of files and folders in the explorer.")
409
		},
410
		'explorer.decorations.colors': {
411
			type: 'boolean',
R
Rob Lourens 已提交
412
			description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
413
			default: true
414
		},
415
		'explorer.decorations.badges': {
416
			type: 'boolean',
R
Rob Lourens 已提交
417
			description: nls.localize('explorer.decorations.badges', "Controls whether file decorations should use badges."),
418 419
			default: true
		},
I
isidor 已提交
420 421 422 423 424 425 426 427
		'explorer.incrementalNaming': {
			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 已提交
428
		},
J
Joao Moreno 已提交
429
		'explorer.compactFolders': {
J
Joao Moreno 已提交
430
			'type': 'boolean',
J
Joao Moreno 已提交
431
			'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."),
432
			'default': true
J
Joao Moreno 已提交
433
		},
E
Erich Gamma 已提交
434
	}
435
});
436 437 438 439 440 441 442 443 444 445

// View menu
MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, {
	group: '3_views',
	command: {
		id: VIEWLET_ID,
		title: nls.localize({ key: 'miViewExplorer', comment: ['&& denotes a mnemonic'] }, "&&Explorer")
	},
	order: 1
});