files.contribution.ts 23.2 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/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';
28
import { ExplorerViewlet, ExplorerViewletViewsContribution } from 'vs/workbench/contrib/files/browser/explorerViewlet';
29
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
30
import { DataUriEditorInput } from 'vs/workbench/common/editor/dataUriEditorInput';
31
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
32
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
33
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
I
isidor 已提交
34
import { ILabelService } from 'vs/platform/label/common/label';
35
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
I
isidor 已提交
36
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
37
import { ExplorerService } from 'vs/workbench/contrib/files/common/explorerService';
38
import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles';
39
import { Schemas } from 'vs/base/common/network';
B
Benjamin Pasero 已提交
40
import { WorkspaceWatcher } from 'vs/workbench/contrib/files/common/workspaceWatcher';
41
import { editorConfigurationBaseNode } from 'vs/editor/common/config/commonEditorConfig';
42
import { DirtyFilesIndicator } from 'vs/workbench/contrib/files/common/dirtyFilesIndicator';
E
Erich Gamma 已提交
43 44

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

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

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

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

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

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

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

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

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

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

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

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

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

// Register Editor Input Factory
class FileEditorInputFactory implements IEditorInputFactory {

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

		return JSON.stringify(fileInput);
	}

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

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

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

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

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

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

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

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

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

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

M
Matt Bierner 已提交
184
const hotExitConfiguration: IConfigurationPropertySchema = platform.isNative ?
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
	{
		'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 已提交
208 209
configurationRegistry.registerConfiguration({
	'id': 'files',
210
	'order': 9,
211
	'title': nls.localize('filesConfigurationTitle', "Files"),
E
Erich Gamma 已提交
212 213 214 215
	'type': 'object',
	'properties': {
		'files.exclude': {
			'type': 'object',
216
			'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 已提交
217
			'default': { '**/.git': true, '**/.svn': true, '**/.hg': true, '**/CVS': true, '**/.DS_Store': true },
S
Sandeep Somavarapu 已提交
218
			'scope': ConfigurationScope.RESOURCE,
E
Erich Gamma 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231
			'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 已提交
232
								'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 已提交
233 234 235 236 237 238
							}
						}
					}
				]
			}
		},
B
Benjamin Pasero 已提交
239
		'files.associations': {
240
			'type': 'object',
241
			'markdownDescription': nls.localize('associations', "Configure file associations to languages (e.g. `\"*.extension\": \"html\"`). These have precedence over the default associations of the languages installed."),
242
		},
E
Erich Gamma 已提交
243 244
		'files.encoding': {
			'type': 'string',
245
			'overridable': true,
E
Erich Gamma 已提交
246 247
			'enum': Object.keys(SUPPORTED_ENCODINGS),
			'default': 'utf8',
248
			'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),
249
			'scope': ConfigurationScope.RESOURCE,
250 251
			'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
E
Erich Gamma 已提交
252
		},
253
		'files.autoGuessEncoding': {
254
			'type': 'boolean',
255
			'overridable': true,
256
			'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 259
			'scope': ConfigurationScope.RESOURCE,
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
260
		},
261 262
		'files.eol': {
			'type': 'string',
263
			'overridable': true,
264 265
			'enum': [
				'\n',
S
Sandeep Somavarapu 已提交
266 267
				'\r\n',
				'auto'
268
			],
269 270
			'enumDescriptions': [
				nls.localize('eol.LF', "LF"),
S
Sandeep Somavarapu 已提交
271 272
				nls.localize('eol.CRLF', "CRLF"),
				nls.localize('eol.auto', "Uses operating system specific end of line character.")
273
			],
S
Sandeep Somavarapu 已提交
274
			'default': 'auto',
275
			'description': nls.localize('eol', "The default end of line character."),
276
			'scope': ConfigurationScope.RESOURCE
277
		},
B
Benjamin Pasero 已提交
278 279 280 281 282
		'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 已提交
283 284 285
		'files.trimTrailingWhitespace': {
			'type': 'boolean',
			'default': false,
286
			'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
S
Sandeep Somavarapu 已提交
287
			'overridable': true,
S
Sandeep Somavarapu 已提交
288
			'scope': ConfigurationScope.RESOURCE
289 290 291 292
		},
		'files.insertFinalNewline': {
			'type': 'boolean',
			'default': false,
293
			'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
S
Sandeep Somavarapu 已提交
294
			'overridable': true,
S
Sandeep Somavarapu 已提交
295
			'scope': ConfigurationScope.RESOURCE
296
		},
297 298 299 300 301 302 303
		'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."),
			'overridable': true,
			'scope': ConfigurationScope.RESOURCE
		},
304 305
		'files.autoSave': {
			'type': 'string',
B
Benjamin Pasero 已提交
306
			'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
307
			'markdownEnumDescriptions': [
308
				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."),
309
				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#`."),
310 311
				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.")
312
			],
B
Benjamin Pasero 已提交
313
			'default': platform.isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
314
			'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)
315
		},
316
		'files.autoSaveDelay': {
317
			'type': 'number',
318
			'default': 1000,
319
			'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)
320 321
		},
		'files.watcherExclude': {
322
			'type': 'object',
323
			'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 已提交
324
			'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 已提交
325
			'scope': ConfigurationScope.RESOURCE
D
Daniel Imms 已提交
326
		},
327
		'files.hotExit': hotExitConfiguration,
328 329 330
		'files.defaultLanguage': {
			'type': 'string',
			'description': nls.localize('defaultLanguage', "The default language mode that is assigned to new files.")
331 332 333 334
		},
		'files.maxMemoryForLargeFilesMB': {
			'type': 'number',
			'default': 4096,
335 336
			'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
337 338 339 340 341
		},
		'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."),
			'default': false,
342 343 344 345 346
		}
	}
});

configurationRegistry.registerConfiguration({
347
	...editorConfigurationBaseNode,
348
	properties: {
349 350 351
		'editor.formatOnSave': {
			'type': 'boolean',
			'default': false,
J
Johannes Rieken 已提交
352
			'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."),
S
Sandeep Somavarapu 已提交
353 354
			'overridable': true,
			'scope': ConfigurationScope.RESOURCE
355 356 357 358
		},
		'editor.formatOnSaveTimeout': {
			'type': 'number',
			'default': 750,
359
			'description': nls.localize('formatOnSaveTimeout', "Timeout in milliseconds after which the formatting that is run on file save is cancelled."),
R
Robin 已提交
360
			'overridable': true,
361
			'scope': ConfigurationScope.RESOURCE
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
});