“dc7d1e9a1c270c0c47b97b263cf0d97dff480f16”上不存在“src/vs/workbench/contrib/files/browser/files.contribution.ts”
files.contribution.ts 23.6 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
		'files.encoding': {
			'type': 'string',
247
			'overridable': true,
E
Erich Gamma 已提交
248 249
			'enum': Object.keys(SUPPORTED_ENCODINGS),
			'default': 'utf8',
250
			'description': nls.localize('encoding', "The default character set encoding to use when reading and writing files. This setting can also be configured per language."),
251
			'scope': ConfigurationScope.RESOURCE,
252 253
			'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
E
Erich Gamma 已提交
254
		},
255
		'files.autoGuessEncoding': {
256
			'type': 'boolean',
257
			'overridable': true,
258
			'default': false,
259
			'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."),
260 261
			'scope': ConfigurationScope.RESOURCE,
			'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
262
		},
263 264
		'files.eol': {
			'type': 'string',
265
			'overridable': true,
266 267
			'enum': [
				'\n',
S
Sandeep Somavarapu 已提交
268 269
				'\r\n',
				'auto'
270
			],
271 272
			'enumDescriptions': [
				nls.localize('eol.LF', "LF"),
S
Sandeep Somavarapu 已提交
273 274
				nls.localize('eol.CRLF', "CRLF"),
				nls.localize('eol.auto', "Uses operating system specific end of line character.")
275
			],
S
Sandeep Somavarapu 已提交
276
			'default': 'auto',
277
			'description': nls.localize('eol', "The default end of line character."),
278
			'scope': ConfigurationScope.RESOURCE
279
		},
B
Benjamin Pasero 已提交
280 281 282 283 284
		'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 已提交
285 286 287
		'files.trimTrailingWhitespace': {
			'type': 'boolean',
			'default': false,
288
			'description': nls.localize('trimTrailingWhitespace', "When enabled, will trim trailing whitespace when saving a file."),
S
Sandeep Somavarapu 已提交
289
			'overridable': true,
S
Sandeep Somavarapu 已提交
290
			'scope': ConfigurationScope.RESOURCE
291 292 293 294
		},
		'files.insertFinalNewline': {
			'type': 'boolean',
			'default': false,
295
			'description': nls.localize('insertFinalNewline', "When enabled, insert a final new line at the end of the file when saving it."),
S
Sandeep Somavarapu 已提交
296
			'overridable': true,
S
Sandeep Somavarapu 已提交
297
			'scope': ConfigurationScope.RESOURCE
298
		},
299 300 301 302 303 304 305
		'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
		},
306 307
		'files.autoSave': {
			'type': 'string',
B
Benjamin Pasero 已提交
308
			'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
309
			'markdownEnumDescriptions': [
310
				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."),
311
				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#`."),
312 313
				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.")
314
			],
B
Benjamin Pasero 已提交
315
			'default': platform.isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
316
			'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)
317
		},
318
		'files.autoSaveDelay': {
319
			'type': 'number',
320
			'default': 1000,
321
			'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)
322 323
		},
		'files.watcherExclude': {
324
			'type': 'object',
325
			'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 已提交
326
			'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 已提交
327
			'scope': ConfigurationScope.RESOURCE
D
Daniel Imms 已提交
328
		},
329
		'files.hotExit': hotExitConfiguration,
330 331 332
		'files.defaultLanguage': {
			'type': 'string',
			'description': nls.localize('defaultLanguage', "The default language mode that is assigned to new files.")
333 334 335 336
		},
		'files.maxMemoryForLargeFilesMB': {
			'type': 'number',
			'default': 4096,
337 338
			'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
339
		},
340 341 342 343 344 345
		'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
		},
346 347 348
		'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."),
349
			'default': false
350 351 352 353 354
		}
	}
});

configurationRegistry.registerConfiguration({
355
	...editorConfigurationBaseNode,
356
	properties: {
357 358 359
		'editor.formatOnSave': {
			'type': 'boolean',
			'default': false,
J
Johannes Rieken 已提交
360
			'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 已提交
361 362
			'overridable': true,
			'scope': ConfigurationScope.RESOURCE
363 364 365 366
		},
		'editor.formatOnSaveTimeout': {
			'type': 'number',
			'default': 750,
367
			'description': nls.localize('formatOnSaveTimeout', "Timeout in milliseconds after which the formatting that is run on file save is cancelled."),
R
Robin 已提交
368
			'overridable': true,
369
			'scope': ConfigurationScope.RESOURCE
E
Erich Gamma 已提交
370 371 372 373 374 375
		}
	}
});

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

// 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
});