commonEditorConfig.ts 32.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

A
Alex Dima 已提交
7
import * as nls from 'vs/nls';
M
Matt Bierner 已提交
8
import { Event, Emitter } from 'vs/base/common/event';
J
Johannes Rieken 已提交
9
import { Disposable } from 'vs/base/common/lifecycle';
A
Alex Dima 已提交
10
import * as objects from 'vs/base/common/objects';
A
Alex Dima 已提交
11
import * as platform from 'vs/base/common/platform';
12
import { Extensions, IConfigurationRegistry, IConfigurationNode, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
13
import { Registry } from 'vs/platform/registry/common/platform';
A
Alex Dima 已提交
14
import * as editorCommon from 'vs/editor/common/editorCommon';
15
import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
A
Alex Dima 已提交
16
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
17
import * as editorOptions from 'vs/editor/common/config/editorOptions';
18 19 20
import EDITOR_DEFAULTS = editorOptions.EDITOR_DEFAULTS;
import EDITOR_FONT_DEFAULTS = editorOptions.EDITOR_FONT_DEFAULTS;
import EDITOR_MODEL_DEFAULTS = editorOptions.EDITOR_MODEL_DEFAULTS;
E
Erich Gamma 已提交
21

22 23 24 25 26 27 28
/**
 * Control what pressing Tab does.
 * If it is false, pressing Tab or Shift-Tab will be handled by the editor.
 * If it is true, pressing Tab or Shift-Tab will move the browser focus.
 * Defaults to false.
 */
export interface ITabFocus {
J
Johannes Rieken 已提交
29
	onDidChangeTabFocus: Event<boolean>;
30
	getTabFocusMode(): boolean;
J
Johannes Rieken 已提交
31
	setTabFocusMode(tabFocusMode: boolean): void;
32 33
}

A
Alex Dima 已提交
34
export const TabFocus: ITabFocus = new class implements ITabFocus {
35 36
	private _tabFocus: boolean = false;

M
Matt Bierner 已提交
37
	private readonly _onDidChangeTabFocus: Emitter<boolean> = new Emitter<boolean>();
38
	public readonly onDidChangeTabFocus: Event<boolean> = this._onDidChangeTabFocus.event;
39 40 41 42 43

	public getTabFocusMode(): boolean {
		return this._tabFocus;
	}

J
Johannes Rieken 已提交
44
	public setTabFocusMode(tabFocusMode: boolean): void {
45 46 47 48 49 50 51 52 53
		if (this._tabFocus === tabFocusMode) {
			return;
		}

		this._tabFocus = tabFocusMode;
		this._onDidChangeTabFocus.fire(this._tabFocus);
	}
};

A
Alex Dima 已提交
54 55 56 57
export interface IEnvConfiguration {
	extraEditorClassName: string;
	outerWidth: number;
	outerHeight: number;
58
	emptySelectionClipboard: boolean;
A
Alex Dima 已提交
59 60
	pixelRatio: number;
	zoomLevel: number;
61
	accessibilitySupport: platform.AccessibilitySupport;
62 63
}

A
Alex Dima 已提交
64
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
E
Erich Gamma 已提交
65

66 67
	protected _rawOptions: editorOptions.IEditorOptions;
	protected _validatedOptions: editorOptions.IValidatedEditorOptions;
68
	public editor: editorOptions.InternalEditorOptions;
J
Johannes Rieken 已提交
69
	private _isDominatedByLongLines: boolean;
70
	private _lineNumbersDigitCount: number;
E
Erich Gamma 已提交
71

72
	private _onDidChange = this._register(new Emitter<editorOptions.IConfigurationChangedEvent>());
73
	public readonly onDidChange: Event<editorOptions.IConfigurationChangedEvent> = this._onDidChange.event;
A
Alex Dima 已提交
74

A
Alex Dima 已提交
75
	constructor(options: editorOptions.IEditorOptions) {
A
Alex Dima 已提交
76
		super();
77

78 79 80 81 82 83
		// Do a "deep clone of sorts" on the incoming options
		this._rawOptions = objects.mixin({}, options || {});
		this._rawOptions.scrollbar = objects.mixin({}, this._rawOptions.scrollbar || {});
		this._rawOptions.minimap = objects.mixin({}, this._rawOptions.minimap || {});
		this._rawOptions.find = objects.mixin({}, this._rawOptions.find || {});

84
		this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
A
Alex Dima 已提交
85
		this.editor = null;
E
Erich Gamma 已提交
86
		this._isDominatedByLongLines = false;
87
		this._lineNumbersDigitCount = 1;
A
Alex Dima 已提交
88

89
		this._register(EditorZoom.onDidChangeZoomLevel(_ => this._recomputeOptions()));
90
		this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions()));
E
Erich Gamma 已提交
91 92
	}

A
Alex Dima 已提交
93 94 95
	public observeReferenceElement(dimension?: editorCommon.IDimension): void {
	}

E
Erich Gamma 已提交
96 97 98 99 100
	public dispose(): void {
		super.dispose();
	}

	protected _recomputeOptions(): void {
A
Alex Dima 已提交
101 102
		const oldOptions = this.editor;
		const newOptions = this._computeInternalOptions();
103

A
Alex Dima 已提交
104
		if (oldOptions && oldOptions.equals(newOptions)) {
105
			return;
E
Erich Gamma 已提交
106 107
		}

108
		this.editor = newOptions;
E
Erich Gamma 已提交
109

A
Alex Dima 已提交
110 111
		if (oldOptions) {
			this._onDidChange.fire(oldOptions.createChangeEvent(newOptions));
112
		}
E
Erich Gamma 已提交
113
	}
114

115
	public getRawOptions(): editorOptions.IEditorOptions {
116
		return this._rawOptions;
E
Erich Gamma 已提交
117
	}
118

119
	private _computeInternalOptions(): editorOptions.InternalEditorOptions {
120
		const opts = this._validatedOptions;
A
Alex Dima 已提交
121 122
		const partialEnv = this._getEnvConfiguration();
		const bareFontInfo = BareFontInfo.createFromRawSettings(this._rawOptions, partialEnv.zoomLevel);
A
Alex Dima 已提交
123
		const env: editorOptions.IEnvironmentalOptions = {
A
Alex Dima 已提交
124 125
			outerWidth: partialEnv.outerWidth,
			outerHeight: partialEnv.outerHeight,
126
			fontInfo: this.readConfiguration(bareFontInfo),
127
			extraEditorClassName: partialEnv.extraEditorClassName,
128 129
			isDominatedByLongLines: this._isDominatedByLongLines,
			lineNumbersDigitCount: this._lineNumbersDigitCount,
130
			emptySelectionClipboard: partialEnv.emptySelectionClipboard,
A
Alex Dima 已提交
131
			pixelRatio: partialEnv.pixelRatio,
132 133
			tabFocusMode: TabFocus.getTabFocusMode(),
			accessibilitySupport: partialEnv.accessibilitySupport
A
Alex Dima 已提交
134
		};
135
		return editorOptions.InternalEditorOptionsFactory.createInternalEditorOptions(env, opts);
E
Erich Gamma 已提交
136 137
	}

138
	public updateOptions(newOptions: editorOptions.IEditorOptions): void {
139
		this._rawOptions = objects.mixin(this._rawOptions, newOptions || {});
140
		this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
E
Erich Gamma 已提交
141 142 143
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
144
	public setIsDominatedByLongLines(isDominatedByLongLines: boolean): void {
E
Erich Gamma 已提交
145 146 147 148
		this._isDominatedByLongLines = isDominatedByLongLines;
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
149
	public setMaxLineNumber(maxLineNumber: number): void {
150
		let digitCount = CommonEditorConfiguration._digitCount(maxLineNumber);
151
		if (this._lineNumbersDigitCount === digitCount) {
A
Alex Dima 已提交
152 153
			return;
		}
154
		this._lineNumbersDigitCount = digitCount;
E
Erich Gamma 已提交
155 156 157
		this._recomputeOptions();
	}

158
	private static _digitCount(n: number): number {
A
Alex Dima 已提交
159
		let r = 0;
160 161 162 163 164 165
		while (n) {
			n = Math.floor(n / 10);
			r++;
		}
		return r ? r : 1;
	}
A
Alex Dima 已提交
166
	protected abstract _getEnvConfiguration(): IEnvConfiguration;
167

168
	protected abstract readConfiguration(styling: BareFontInfo): FontInfo;
169

E
Erich Gamma 已提交
170 171
}

172
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
173
const editorConfiguration: IConfigurationNode = {
E
Erich Gamma 已提交
174 175 176
	'id': 'editor',
	'order': 5,
	'type': 'object',
177
	'title': nls.localize('editorConfigurationTitle', "Editor"),
178
	'overridable': true,
S
Sandeep Somavarapu 已提交
179
	'scope': ConfigurationScope.RESOURCE,
J
Johannes Rieken 已提交
180 181
	'properties': {
		'editor.fontFamily': {
E
Erich Gamma 已提交
182
			'type': 'string',
183
			'default': EDITOR_FONT_DEFAULTS.fontFamily,
E
Erich Gamma 已提交
184 185
			'description': nls.localize('fontFamily', "Controls the font family.")
		},
J
Johannes Rieken 已提交
186
		'editor.fontWeight': {
187
			'type': 'string',
188
			'enum': ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
189
			'default': EDITOR_FONT_DEFAULTS.fontWeight,
190 191
			'description': nls.localize('fontWeight', "Controls the font weight.")
		},
J
Johannes Rieken 已提交
192
		'editor.fontSize': {
E
Erich Gamma 已提交
193
			'type': 'number',
194
			'default': EDITOR_FONT_DEFAULTS.fontSize,
195
			'description': nls.localize('fontSize', "Controls the font size in pixels.")
E
Erich Gamma 已提交
196
		},
J
Johannes Rieken 已提交
197
		'editor.lineHeight': {
E
Erich Gamma 已提交
198
			'type': 'number',
199
			'default': EDITOR_FONT_DEFAULTS.lineHeight,
200
			'description': nls.localize('lineHeight', "Controls the line height. Use 0 to compute the lineHeight from the fontSize.")
E
Erich Gamma 已提交
201
		},
202 203
		'editor.letterSpacing': {
			'type': 'number',
204
			'default': EDITOR_FONT_DEFAULTS.letterSpacing,
205 206
			'description': nls.localize('letterSpacing', "Controls the letter spacing in pixels.")
		},
J
Johannes Rieken 已提交
207
		'editor.lineNumbers': {
208
			'type': 'string',
209
			'enum': ['off', 'on', 'relative', 'interval'],
210 211 212
			'enumDescriptions': [
				nls.localize('lineNumbers.off', "Line numbers are not rendered."),
				nls.localize('lineNumbers.on', "Line numbers are rendered as absolute number."),
213 214
				nls.localize('lineNumbers.relative', "Line numbers are rendered as distance in lines to cursor position."),
				nls.localize('lineNumbers.interval', "Line numbers are rendered every 10 lines.")
215
			],
216
			'default': 'on',
A
Alex Dima 已提交
217
			'description': nls.localize('lineNumbers', "Controls the display of line numbers.")
E
Erich Gamma 已提交
218
		},
J
Johannes Rieken 已提交
219
		'editor.rulers': {
220 221 222 223
			'type': 'array',
			'items': {
				'type': 'number'
			},
A
Alex Dima 已提交
224
			'default': EDITOR_DEFAULTS.viewInfo.rulers,
225
			'description': nls.localize('rulers', "Render vertical rulers after a certain number of monospace characters. Use multiple values for multiple rulers. No rulers are drawn if array is empty")
226
		},
J
Johannes Rieken 已提交
227
		'editor.wordSeparators': {
A
Alex Dima 已提交
228
			'type': 'string',
229
			'default': EDITOR_DEFAULTS.wordSeparators,
A
Alex Dima 已提交
230 231
			'description': nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations")
		},
J
Johannes Rieken 已提交
232
		'editor.tabSize': {
233
			'type': 'number',
234
			'default': EDITOR_MODEL_DEFAULTS.tabSize,
E
Erich Gamma 已提交
235
			'minimum': 1,
236
			'description': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when `editor.detectIndentation` is on."),
237
			'errorMessage': nls.localize('tabSize.errorMessage', "Expected 'number'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
238
		},
J
Johannes Rieken 已提交
239
		'editor.insertSpaces': {
240
			'type': 'boolean',
241
			'default': EDITOR_MODEL_DEFAULTS.insertSpaces,
242
			'description': nls.localize('insertSpaces', "Insert spaces when pressing Tab. This setting is overridden based on the file contents when `editor.detectIndentation` is on."),
243
			'errorMessage': nls.localize('insertSpaces.errorMessage', "Expected 'boolean'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
244
		},
J
Johannes Rieken 已提交
245
		'editor.detectIndentation': {
246
			'type': 'boolean',
247
			'default': EDITOR_MODEL_DEFAULTS.detectIndentation,
A
Alex Dima 已提交
248
			'description': nls.localize('detectIndentation', "When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.")
249
		},
J
Johannes Rieken 已提交
250
		'editor.roundedSelection': {
E
Erich Gamma 已提交
251
			'type': 'boolean',
A
Alex Dima 已提交
252
			'default': EDITOR_DEFAULTS.viewInfo.roundedSelection,
E
Erich Gamma 已提交
253 254
			'description': nls.localize('roundedSelection', "Controls if selections have rounded corners")
		},
J
Johannes Rieken 已提交
255
		'editor.scrollBeyondLastLine': {
E
Erich Gamma 已提交
256
			'type': 'boolean',
A
Alex Dima 已提交
257
			'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastLine,
E
Erich Gamma 已提交
258 259
			'description': nls.localize('scrollBeyondLastLine', "Controls if the editor will scroll beyond the last line")
		},
260 261 262
		'editor.scrollBeyondLastColumn': {
			'type': 'number',
			'default': EDITOR_DEFAULTS.viewInfo.scrollBeyondLastColumn,
A
Alex Dima 已提交
263
			'description': nls.localize('scrollBeyondLastColumn', "Controls the number of extra characters beyond which the editor will scroll horizontally")
264
		},
265 266 267 268 269
		'editor.smoothScrolling': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.viewInfo.smoothScrolling,
			'description': nls.localize('smoothScrolling', "Controls if the editor will scroll using an animation")
		},
270 271
		'editor.minimap.enabled': {
			'type': 'boolean',
A
Alex Dima 已提交
272
			'default': EDITOR_DEFAULTS.viewInfo.minimap.enabled,
273 274
			'description': nls.localize('minimap.enabled', "Controls if the minimap is shown")
		},
275 276 277 278
		'editor.minimap.side': {
			'type': 'string',
			'enum': ['left', 'right'],
			'default': EDITOR_DEFAULTS.viewInfo.minimap.side,
A
Alex Dima 已提交
279
			'description': nls.localize('minimap.side', "Controls the side where to render the minimap.")
280
		},
281 282 283 284
		'editor.minimap.showSlider': {
			'type': 'string',
			'enum': ['always', 'mouseover'],
			'default': EDITOR_DEFAULTS.viewInfo.minimap.showSlider,
A
Alex Dima 已提交
285
			'description': nls.localize('minimap.showSlider', "Controls whether the minimap slider is automatically hidden.")
286
		},
287
		'editor.minimap.renderCharacters': {
288
			'type': 'boolean',
A
Alex Dima 已提交
289
			'default': EDITOR_DEFAULTS.viewInfo.minimap.renderCharacters,
290
			'description': nls.localize('minimap.renderCharacters', "Render the actual characters on a line (as opposed to color blocks)")
291
		},
A
Alex Dima 已提交
292 293
		'editor.minimap.maxColumn': {
			'type': 'number',
A
Alex Dima 已提交
294
			'default': EDITOR_DEFAULTS.viewInfo.minimap.maxColumn,
A
Alex Dima 已提交
295 296
			'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns")
		},
297 298 299
		'editor.find.seedSearchStringFromSelection': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection,
300
			'description': nls.localize('find.seedSearchStringFromSelection', "Controls if we seed the search string in Find Widget from editor selection")
301
		},
R
rebornix 已提交
302 303 304 305 306
		'editor.find.autoFindInSelection': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.contribInfo.find.autoFindInSelection,
			'description': nls.localize('find.autoFindInSelection', "Controls if Find in Selection flag is turned on when multiple characters or lines of text are selected in the editor")
		},
307 308 309
		'editor.find.globalFindClipboard': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.contribInfo.find.globalFindClipboard,
310 311
			'description': nls.localize('find.globalFindClipboard', "Controls if the Find Widget should read or modify the shared find clipboard on macOS"),
			'included': platform.isMacintosh
312
		},
J
Johannes Rieken 已提交
313
		'editor.wordWrap': {
314
			'type': 'string',
A
Alex Dima 已提交
315
			'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
316 317 318
			'enumDescriptions': [
				nls.localize('wordWrap.off', "Lines will never wrap."),
				nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
A
Alex Dima 已提交
319 320 321 322 323 324
				nls.localize({
					key: 'wordWrap.wordWrapColumn',
					comment: [
						'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
					]
				}, "Lines will wrap at `editor.wordWrapColumn`."),
A
Alex Dima 已提交
325 326 327 328
				nls.localize({
					key: 'wordWrap.bounded',
					comment: [
						'- viewport means the edge of the visible window size.',
A
Alex Dima 已提交
329
						'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
A
Alex Dima 已提交
330 331
					]
				}, "Lines will wrap at the minimum of viewport and `editor.wordWrapColumn`."),
332
			],
333
			'default': EDITOR_DEFAULTS.wordWrap,
A
Alex Dima 已提交
334 335 336 337 338 339 340
			'description': nls.localize({
				key: 'wordWrap',
				comment: [
					'- \'off\', \'on\', \'wordWrapColumn\' and \'bounded\' refer to values the setting can take and should not be localized.',
					'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
				]
			}, "Controls how lines should wrap. Can be:\n - 'off' (disable wrapping),\n - 'on' (viewport wrapping),\n - 'wordWrapColumn' (wrap at `editor.wordWrapColumn`) or\n - 'bounded' (wrap at minimum of viewport and `editor.wordWrapColumn`).")
341 342 343
		},
		'editor.wordWrapColumn': {
			'type': 'integer',
344
			'default': EDITOR_DEFAULTS.wordWrapColumn,
345
			'minimum': 1,
A
Alex Dima 已提交
346 347 348 349 350 351 352
			'description': nls.localize({
				key: 'wordWrapColumn',
				comment: [
					'- `editor.wordWrap` refers to a different setting and should not be localized.',
					'- \'wordWrapColumn\' and \'bounded\' refer to values the different setting can take and should not be localized.'
				]
			}, "Controls the wrapping column of the editor when `editor.wordWrap` is 'wordWrapColumn' or 'bounded'.")
353
		},
J
Johannes Rieken 已提交
354
		'editor.wrappingIndent': {
E
Erich Gamma 已提交
355
			'type': 'string',
356
			'enum': ['none', 'same', 'indent', 'deepIndent'],
357
			'default': 'same',
358
			'description': nls.localize('wrappingIndent', "Controls the indentation of wrapped lines. Can be one of 'none', 'same', 'indent' or 'deepIndent'.")
E
Erich Gamma 已提交
359
		},
J
Johannes Rieken 已提交
360
		'editor.mouseWheelScrollSensitivity': {
E
Erich Gamma 已提交
361
			'type': 'number',
A
Alex Dima 已提交
362
			'default': EDITOR_DEFAULTS.viewInfo.scrollbar.mouseWheelScrollSensitivity,
E
Erich Gamma 已提交
363 364
			'description': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events")
		},
365
		'editor.multiCursorModifier': {
366
			'type': 'string',
367 368
			'enum': ['ctrlCmd', 'alt'],
			'enumDescriptions': [
369 370
				nls.localize('multiCursorModifier.ctrlCmd', "Maps to `Control` on Windows and Linux and to `Command` on macOS."),
				nls.localize('multiCursorModifier.alt', "Maps to `Alt` on Windows and Linux and to `Option` on macOS.")
371
			],
372
			'default': 'alt',
373 374 375 376 377 378
			'description': nls.localize({
				key: 'multiCursorModifier',
				comment: [
					'- `ctrlCmd` refers to a value the setting can take and should not be localized.',
					'- `Control` and `Command` refer to the modifier keys Ctrl or Cmd on the keyboard and can be localized.'
				]
379
			}, "The modifier to be used to add multiple cursors with the mouse. `ctrlCmd` maps to `Control` on Windows and Linux and to `Command` on macOS. The Go To Definition and Open Link mouse gestures will adapt such that they do not conflict with the multicursor modifier.")
380
		},
A
Alex Dima 已提交
381
		'editor.multiCursorMergeOverlapping': {
382
			'type': 'boolean',
A
Alex Dima 已提交
383 384
			'default': EDITOR_DEFAULTS.multiCursorMergeOverlapping,
			'description': nls.localize('multiCursorMergeOverlapping', "Merge multiple cursors when they are overlapping.")
385
		},
J
Johannes Rieken 已提交
386
		'editor.quickSuggestions': {
387
			'anyOf': [
388 389 390
				{
					type: 'boolean',
				},
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
				{
					type: 'object',
					properties: {
						strings: {
							type: 'boolean',
							default: false,
							description: nls.localize('quickSuggestions.strings', "Enable quick suggestions inside strings.")
						},
						comments: {
							type: 'boolean',
							default: false,
							description: nls.localize('quickSuggestions.comments', "Enable quick suggestions inside comments.")
						},
						other: {
							type: 'boolean',
							default: true,
							description: nls.localize('quickSuggestions.other', "Enable quick suggestions outside of strings and comments.")
						},
					}
				}
			],
A
Alex Dima 已提交
412
			'default': EDITOR_DEFAULTS.contribInfo.quickSuggestions,
413
			'description': nls.localize('quickSuggestions', "Controls if suggestions should automatically show up while typing")
E
Erich Gamma 已提交
414
		},
J
Johannes Rieken 已提交
415
		'editor.quickSuggestionsDelay': {
E
Erich Gamma 已提交
416
			'type': 'integer',
A
Alex Dima 已提交
417
			'default': EDITOR_DEFAULTS.contribInfo.quickSuggestionsDelay,
E
Erich Gamma 已提交
418 419 420
			'minimum': 0,
			'description': nls.localize('quickSuggestionsDelay', "Controls the delay in ms after which quick suggestions will show up")
		},
J
Johannes Rieken 已提交
421
		'editor.parameterHints': {
J
Joao Moreno 已提交
422
			'type': 'boolean',
A
Alex Dima 已提交
423
			'default': EDITOR_DEFAULTS.contribInfo.parameterHints,
424
			'description': nls.localize('parameterHints', "Enables pop-up that shows parameter documentation and type information as you type")
J
Joao Moreno 已提交
425
		},
J
Johannes Rieken 已提交
426
		'editor.autoClosingBrackets': {
E
Erich Gamma 已提交
427
			'type': 'boolean',
428
			'default': EDITOR_DEFAULTS.autoClosingBrackets,
E
Erich Gamma 已提交
429 430
			'description': nls.localize('autoClosingBrackets', "Controls if the editor should automatically close brackets after opening them")
		},
J
Johannes Rieken 已提交
431
		'editor.formatOnType': {
E
Erich Gamma 已提交
432
			'type': 'boolean',
A
Alex Dima 已提交
433
			'default': EDITOR_DEFAULTS.contribInfo.formatOnType,
E
Erich Gamma 已提交
434 435
			'description': nls.localize('formatOnType', "Controls if the editor should automatically format the line after typing")
		},
436 437
		'editor.formatOnPaste': {
			'type': 'boolean',
A
Alex Dima 已提交
438
			'default': EDITOR_DEFAULTS.contribInfo.formatOnPaste,
439
			'description': nls.localize('formatOnPaste', "Controls if the editor should automatically format the pasted content. A formatter must be available and the formatter should be able to format a range in a document.")
440
		},
441 442 443
		'editor.autoIndent': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.autoIndent,
G
Guangcong Luo 已提交
444
			'description': nls.localize('autoIndent', "Controls if the editor should automatically adjust the indentation when users type, paste or move lines. Indentation rules of the language must be available.")
445
		},
J
Johannes Rieken 已提交
446
		'editor.suggestOnTriggerCharacters': {
E
Erich Gamma 已提交
447
			'type': 'boolean',
A
Alex Dima 已提交
448
			'default': EDITOR_DEFAULTS.contribInfo.suggestOnTriggerCharacters,
E
Erich Gamma 已提交
449 450
			'description': nls.localize('suggestOnTriggerCharacters', "Controls if suggestions should automatically show up when typing trigger characters")
		},
J
Johannes Rieken 已提交
451
		'editor.acceptSuggestionOnEnter': {
452 453
			'type': 'string',
			'enum': ['on', 'smart', 'off'],
A
Alex Dima 已提交
454
			'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnEnter,
455
			'description': nls.localize('acceptSuggestionOnEnter', "Controls if suggestions should be accepted on 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions. The value 'smart' means only accept a suggestion with Enter when it makes a textual change")
456 457 458
		},
		'editor.acceptSuggestionOnCommitCharacter': {
			'type': 'boolean',
A
Alex Dima 已提交
459
			'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnCommitCharacter,
460
			'description': nls.localize('acceptSuggestionOnCommitCharacter', "Controls if suggestions should be accepted on commit characters. For instance in JavaScript the semi-colon (';') can be a commit character that accepts a suggestion and types that character.")
461
		},
462
		'editor.snippetSuggestions': {
463
			'type': 'string',
464
			'enum': ['top', 'bottom', 'inline', 'none'],
J
Johannes Rieken 已提交
465 466 467 468 469 470
			'enumDescriptions': [
				nls.localize('snippetSuggestions.top', "Show snippet suggestions on top of other suggestions."),
				nls.localize('snippetSuggestions.bottom', "Show snippet suggestions below other suggestions."),
				nls.localize('snippetSuggestions.inline', "Show snippets suggestions with other suggestions."),
				nls.localize('snippetSuggestions.none', "Do not show snippet suggestions."),
			],
A
Alex Dima 已提交
471
			'default': EDITOR_DEFAULTS.contribInfo.snippetSuggestions,
472
			'description': nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.")
473
		},
474 475
		'editor.emptySelectionClipboard': {
			'type': 'boolean',
476
			'default': EDITOR_DEFAULTS.emptySelectionClipboard,
477 478
			'description': nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.")
		},
479
		'editor.wordBasedSuggestions': {
480
			'type': 'boolean',
A
Alex Dima 已提交
481
			'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions,
J
Johannes Rieken 已提交
482
			'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
483
		},
J
Johannes Rieken 已提交
484
		'editor.suggestSelection': {
485
			'type': 'string',
J
Johannes Rieken 已提交
486
			'enum': ['first', 'recentlyUsed', 'recentlyUsedByPrefix'],
J
Johannes Rieken 已提交
487
			'enumDescriptions': [
J
Johannes Rieken 已提交
488 489 490
				nls.localize('suggestSelection.first', "Always select the first suggestion."),
				nls.localize('suggestSelection.recentlyUsed', "Select recent suggestions unless further typing selects one, e.g. `console.| -> console.log` because `log` has been completed recently."),
				nls.localize('suggestSelection.recentlyUsedByPrefix', "Select suggestions based on previous prefixes that have completed those suggestions, e.g. `co -> console` and `con -> const`."),
J
Johannes Rieken 已提交
491
			],
J
Johannes Rieken 已提交
492 493
			'default': 'recentlyUsed',
			'description': nls.localize('suggestSelection', "Controls how suggestions are pre-selected when showing the suggest list.")
494
		},
J
Johannes Rieken 已提交
495
		'editor.suggestFontSize': {
J
Joao Moreno 已提交
496 497 498 499 500
			'type': 'integer',
			'default': 0,
			'minimum': 0,
			'description': nls.localize('suggestFontSize', "Font size for the suggest widget")
		},
J
Johannes Rieken 已提交
501
		'editor.suggestLineHeight': {
J
Joao Moreno 已提交
502 503 504 505 506
			'type': 'integer',
			'default': 0,
			'minimum': 0,
			'description': nls.localize('suggestLineHeight', "Line height for the suggest widget")
		},
J
Johannes Rieken 已提交
507
		'editor.selectionHighlight': {
E
Erich Gamma 已提交
508
			'type': 'boolean',
A
Alex Dima 已提交
509
			'default': EDITOR_DEFAULTS.contribInfo.selectionHighlight,
E
Erich Gamma 已提交
510 511
			'description': nls.localize('selectionHighlight', "Controls whether the editor should highlight similar matches to the selection")
		},
512 513
		'editor.occurrencesHighlight': {
			'type': 'boolean',
A
Alex Dima 已提交
514
			'default': EDITOR_DEFAULTS.contribInfo.occurrencesHighlight,
515 516
			'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences")
		},
J
Johannes Rieken 已提交
517
		'editor.overviewRulerLanes': {
E
Erich Gamma 已提交
518 519 520 521
			'type': 'integer',
			'default': 3,
			'description': nls.localize('overviewRulerLanes', "Controls the number of decorations that can show up at the same position in the overview ruler")
		},
522
		'editor.overviewRulerBorder': {
523
			'type': 'boolean',
A
Alex Dima 已提交
524
			'default': EDITOR_DEFAULTS.viewInfo.overviewRulerBorder,
525
			'description': nls.localize('overviewRulerBorder', "Controls if a border should be drawn around the overview ruler.")
526
		},
J
Johannes Rieken 已提交
527
		'editor.cursorBlinking': {
528
			'type': 'string',
529
			'enum': ['blink', 'smooth', 'phase', 'expand', 'solid'],
530
			'default': editorOptions.blinkingStyleToString(EDITOR_DEFAULTS.viewInfo.cursorBlinking),
A
Alex Dima 已提交
531
			'description': nls.localize('cursorBlinking', "Control the cursor animation style.")
532
		},
533 534
		'editor.mouseWheelZoom': {
			'type': 'boolean',
A
Alex Dima 已提交
535
			'default': EDITOR_DEFAULTS.viewInfo.mouseWheelZoom,
536 537
			'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding Ctrl")
		},
J
Johannes Rieken 已提交
538
		'editor.cursorStyle': {
M
markrendle 已提交
539
			'type': 'string',
540
			'enum': ['block', 'block-outline', 'line', 'line-thin', 'underline', 'underline-thin'],
541
			'default': editorOptions.cursorStyleToString(EDITOR_DEFAULTS.viewInfo.cursorStyle),
542
			'description': nls.localize('cursorStyle', "Controls the cursor style, accepted values are 'block', 'block-outline', 'line', 'line-thin', 'underline' and 'underline-thin'")
M
markrendle 已提交
543
		},
544
		'editor.cursorWidth': {
545
			'type': 'integer',
546 547
			'default': EDITOR_DEFAULTS.viewInfo.cursorWidth,
			'description': nls.localize('cursorWidth', "Controls the width of the cursor when editor.cursorStyle is set to 'line'")
548
		},
J
Johannes Rieken 已提交
549
		'editor.fontLigatures': {
550
			'type': 'boolean',
A
Alex Dima 已提交
551
			'default': EDITOR_DEFAULTS.viewInfo.fontLigatures,
552 553
			'description': nls.localize('fontLigatures', "Enables font ligatures")
		},
J
Johannes Rieken 已提交
554
		'editor.hideCursorInOverviewRuler': {
E
Erich Gamma 已提交
555
			'type': 'boolean',
A
Alex Dima 已提交
556
			'default': EDITOR_DEFAULTS.viewInfo.hideCursorInOverviewRuler,
E
Erich Gamma 已提交
557 558 559
			'description': nls.localize('hideCursorInOverviewRuler', "Controls if the cursor should be hidden in the overview ruler.")
		},
		'editor.renderWhitespace': {
560 561
			'type': 'string',
			'enum': ['none', 'boundary', 'all'],
A
Alex Dima 已提交
562
			default: EDITOR_DEFAULTS.viewInfo.renderWhitespace,
563
			description: nls.localize('renderWhitespace', "Controls how the editor should render whitespace characters, possibilities are 'none', 'boundary', and 'all'. The 'boundary' option does not render single spaces between words.")
E
Erich Gamma 已提交
564
		},
565 566
		'editor.renderControlCharacters': {
			'type': 'boolean',
A
Alex Dima 已提交
567
			default: EDITOR_DEFAULTS.viewInfo.renderControlCharacters,
568 569
			description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters")
		},
570 571
		'editor.renderIndentGuides': {
			'type': 'boolean',
A
Alex Dima 已提交
572
			default: EDITOR_DEFAULTS.viewInfo.renderIndentGuides,
573 574
			description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides")
		},
575
		'editor.renderLineHighlight': {
576 577
			'type': 'string',
			'enum': ['none', 'gutter', 'line', 'all'],
A
Alex Dima 已提交
578
			default: EDITOR_DEFAULTS.viewInfo.renderLineHighlight,
579
			description: nls.localize('renderLineHighlight', "Controls how the editor should render the current line highlight, possibilities are 'none', 'gutter', 'line', and 'all'.")
580
		},
J
Johannes Rieken 已提交
581
		'editor.codeLens': {
E
Erich Gamma 已提交
582
			'type': 'boolean',
A
Alex Dima 已提交
583
			'default': EDITOR_DEFAULTS.contribInfo.codeLens,
J
Johannes Rieken 已提交
584
			'description': nls.localize('codeLens', "Controls if the editor shows CodeLens")
E
Erich Gamma 已提交
585
		},
J
Johannes Rieken 已提交
586
		'editor.folding': {
M
Martin Aeschlimann 已提交
587
			'type': 'boolean',
A
Alex Dima 已提交
588
			'default': EDITOR_DEFAULTS.contribInfo.folding,
589
			'description': nls.localize('folding', "Controls whether the editor has code folding enabled")
M
Martin Aeschlimann 已提交
590
		},
591 592 593 594
		'editor.foldingStrategy': {
			'type': 'string',
			'enum': ['auto', 'indentation'],
			'enumDescriptions': [
A
Alex Dima 已提交
595
				nls.localize('foldingStrategyAuto', 'If available, use a language specific folding strategy, otherwise falls back to the indentation based strategy.'),
596 597 598 599 600
				nls.localize('foldingStrategyIndentation', 'Always use the indentation based folding strategy')
			],
			'default': EDITOR_DEFAULTS.contribInfo.foldingStrategy,
			'description': nls.localize('foldingStrategy', "Controls the way folding ranges are computed. 'auto' picks uses a language specific folding strategy, if available. 'indentation' forces that the indentation based folding strategy is used.")
		},
601 602 603 604 605
		'editor.showFoldingControls': {
			'type': 'string',
			'enum': ['always', 'mouseover'],
			'default': EDITOR_DEFAULTS.contribInfo.showFoldingControls,
			'description': nls.localize('showFoldingControls', "Controls whether the fold controls on the gutter are automatically hidden.")
606
		},
607
		'editor.matchBrackets': {
608
			'type': 'boolean',
A
Alex Dima 已提交
609
			'default': EDITOR_DEFAULTS.contribInfo.matchBrackets,
610
			'description': nls.localize('matchBrackets', "Highlight matching brackets when one of them is selected.")
611
		},
I
isidor 已提交
612 613
		'editor.glyphMargin': {
			'type': 'boolean',
A
Alex Dima 已提交
614
			'default': EDITOR_DEFAULTS.viewInfo.glyphMargin,
I
isidor 已提交
615 616
			'description': nls.localize('glyphMargin', "Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.")
		},
J
Johannes Rieken 已提交
617
		'editor.useTabStops': {
618
			'type': 'boolean',
619
			'default': EDITOR_DEFAULTS.useTabStops,
620 621
			'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops")
		},
J
Johannes Rieken 已提交
622
		'editor.trimAutoWhitespace': {
623
			'type': 'boolean',
624
			'default': EDITOR_MODEL_DEFAULTS.trimAutoWhitespace,
625 626
			'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace")
		},
J
Johannes Rieken 已提交
627
		'editor.stablePeek': {
628
			'type': 'boolean',
629
			'default': false,
630
			'description': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting Escape.")
631
		},
632
		'editor.dragAndDrop': {
633
			'type': 'boolean',
634
			'default': EDITOR_DEFAULTS.dragAndDrop,
635
			'description': nls.localize('dragAndDrop', "Controls if the editor should allow to move selections via drag and drop.")
636
		},
637 638 639 640 641 642 643 644 645 646 647
		'editor.accessibilitySupport': {
			'type': 'string',
			'enum': ['auto', 'on', 'off'],
			'enumDescriptions': [
				nls.localize('accessibilitySupport.auto', "The editor will use platform APIs to detect when a Screen Reader is attached."),
				nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader."),
				nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."),
			],
			'default': EDITOR_DEFAULTS.accessibilitySupport,
			'description': nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers.")
		},
648
		'editor.links': {
649
			'type': 'boolean',
650 651
			'default': EDITOR_DEFAULTS.contribInfo.links,
			'description': nls.localize('links', "Controls whether the editor should detect links and make them clickable")
652
		},
R
rebornix 已提交
653
		'editor.colorDecorators': {
654
			'type': 'boolean',
R
rebornix 已提交
655
			'default': EDITOR_DEFAULTS.contribInfo.colorDecorators,
656
			'description': nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators and color picker.")
657
		},
658 659 660 661 662
		'editor.lightbulb.enabled': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.contribInfo.lightbulbEnabled,
			'description': nls.localize('codeActions', "Enables the code action lightbulb")
		},
663 664 665 666 667 668 669 670 671 672 673 674
		'editor.codeActionsOnSave': {
			'type': 'object',
			'properties': {
				'source.organizeImports': {
					'type': 'boolean',
					'description': nls.localize('codeActionsOnSave.organizeImports', "Run organize imports on save?")
				}
			},
			'additionalProperties': {
				'type': 'boolean'
			},
			'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSave,
M
Matt Bierner 已提交
675
			'description': nls.localize('codeActionsOnSave', "Code action kinds to be run on save.")
676 677 678 679 680 681
		},
		'editor.codeActionsOnSaveTimeout': {
			'type': 'number',
			'default': EDITOR_DEFAULTS.contribInfo.codeActionsOnSaveTimeout,
			'description': nls.localize('codeActionsOnSaveTimeout', "Timeout for code actions run on save.")
		},
682 683 684 685
		'editor.selectionClipboard': {
			'type': 'boolean',
			'default': EDITOR_DEFAULTS.contribInfo.selectionClipboard,
			'description': nls.localize('selectionClipboard', "Controls if the Linux primary clipboard should be supported."),
686
			'included': platform.isLinux
687
		},
J
Johannes Rieken 已提交
688
		'diffEditor.renderSideBySide': {
E
Erich Gamma 已提交
689 690 691 692
			'type': 'boolean',
			'default': true,
			'description': nls.localize('sideBySide', "Controls if the diff editor shows the diff side by side or inline")
		},
J
Johannes Rieken 已提交
693
		'diffEditor.ignoreTrimWhitespace': {
E
Erich Gamma 已提交
694 695 696
			'type': 'boolean',
			'default': true,
			'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs")
697
		},
698 699 700 701
		'editor.largeFileOptimizations': {
			'type': 'boolean',
			'default': EDITOR_MODEL_DEFAULTS.largeFileOptimizations,
			'description': nls.localize('largeFileOptimizations', "Special handling for large files to disable certain memory intensive features.")
702
		},
703 704 705 706
		'diffEditor.renderIndicators': {
			'type': 'boolean',
			'default': true,
			'description': nls.localize('renderIndicators', "Controls if the diff editor shows +/- indicators for added/removed changes")
E
Erich Gamma 已提交
707 708
		}
	}
A
Alex Dima 已提交
709 710
};

711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
let cachedEditorConfigurationKeys: { [key: string]: boolean; } = null;
function getEditorConfigurationKeys(): { [key: string]: boolean; } {
	if (cachedEditorConfigurationKeys === null) {
		cachedEditorConfigurationKeys = Object.create(null);
		Object.keys(editorConfiguration.properties).forEach((prop) => {
			cachedEditorConfigurationKeys[prop] = true;
		});
	}
	return cachedEditorConfigurationKeys;
}

export function isEditorConfigurationKey(key: string): boolean {
	const editorConfigurationKeys = getEditorConfigurationKeys();
	return (editorConfigurationKeys[`editor.${key}`] || false);
}
export function isDiffEditorConfigurationKey(key: string): boolean {
	const editorConfigurationKeys = getEditorConfigurationKeys();
	return (editorConfigurationKeys[`diffEditor.${key}`] || false);
}

731
configurationRegistry.registerConfiguration(editorConfiguration);