commonEditorConfig.ts 37.7 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';
J
Johannes Rieken 已提交
8 9
import Event, { Emitter } from 'vs/base/common/event';
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';
J
Johannes Rieken 已提交
12 13
import { Extensions, IConfigurationRegistry, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/platform';
14
import { DefaultConfig, DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE } from 'vs/editor/common/config/defaultConfig';
A
Alex Dima 已提交
15
import * as editorCommon from 'vs/editor/common/editorCommon';
16
import { EditorLayoutProvider } from 'vs/editor/common/viewLayout/editorLayoutProvider';
J
Johannes Rieken 已提交
17
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
18
import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
19
import { Constants } from 'vs/editor/common/core/uint';
A
Alex Dima 已提交
20
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
21
import * as editorOptions from 'vs/editor/common/config/editorOptions';
E
Erich Gamma 已提交
22

23 24 25 26 27 28 29
/**
 * 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 已提交
30
	onDidChangeTabFocus: Event<boolean>;
31
	getTabFocusMode(): boolean;
J
Johannes Rieken 已提交
32
	setTabFocusMode(tabFocusMode: boolean): void;
33 34 35 36 37 38
}

export const TabFocus: ITabFocus = new class {
	private _tabFocus: boolean = false;

	private _onDidChangeTabFocus: Emitter<boolean> = new Emitter<boolean>();
J
Johannes Rieken 已提交
39
	public onDidChangeTabFocus: Event<boolean> = this._onDidChangeTabFocus.event;
40 41 42 43 44

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

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

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

E
Erich Gamma 已提交
55 56
export class ConfigurationWithDefaults {

57
	private _editor: editorOptions.IEditorOptions;
E
Erich Gamma 已提交
58

59 60
	constructor(options: editorOptions.IEditorOptions) {
		this._editor = <editorOptions.IEditorOptions>objects.clone(DefaultConfig.editor);
E
Erich Gamma 已提交
61 62 63 64

		this._mergeOptionsIn(options);
	}

65
	public getEditorOptions(): editorOptions.IEditorOptions {
E
Erich Gamma 已提交
66 67 68
		return this._editor;
	}

69
	private _mergeOptionsIn(newOptions: editorOptions.IEditorOptions): void {
A
Alex Dima 已提交
70
		this._editor = objects.mixin(this._editor, newOptions || {});
E
Erich Gamma 已提交
71 72
	}

73
	public updateOptions(newOptions: editorOptions.IEditorOptions): void {
E
Erich Gamma 已提交
74 75 76 77 78 79 80 81 82 83 84
		// Apply new options
		this._mergeOptionsIn(newOptions);
	}
}

class InternalEditorOptionsHelper {

	constructor() {
	}

	public static createInternalEditorOptions(
85 86
		outerWidth: number,
		outerHeight: number,
87
		opts: editorOptions.IEditorOptions,
88
		fontInfo: FontInfo,
J
Johannes Rieken 已提交
89 90
		editorClassName: string,
		isDominatedByLongLines: boolean,
91
		lineNumbersDigitCount: number,
92 93
		canUseTranslate3d: boolean,
		pixelRatio: number
94
	): editorOptions.InternalEditorOptions {
E
Erich Gamma 已提交
95

J
Johannes Rieken 已提交
96
		let stopRenderingLineAfter: number;
E
Erich Gamma 已提交
97 98 99 100 101 102
		if (typeof opts.stopRenderingLineAfter !== 'undefined') {
			stopRenderingLineAfter = toInteger(opts.stopRenderingLineAfter, -1);
		} else {
			stopRenderingLineAfter = 10000;
		}

103
		let scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, toFloat(opts.mouseWheelScrollSensitivity, 1));
104
		let minimap = this._sanitizeMinimapOpts(opts.minimap);
E
Erich Gamma 已提交
105 106 107

		let glyphMargin = toBoolean(opts.glyphMargin);
		let lineNumbersMinChars = toInteger(opts.lineNumbersMinChars, 1);
108 109 110 111 112 113 114 115

		let lineDecorationsWidth: number;
		if (typeof opts.lineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(opts.lineDecorationsWidth)) {
			let multiple = parseFloat(opts.lineDecorationsWidth.substr(0, opts.lineDecorationsWidth.length - 2));
			lineDecorationsWidth = multiple * fontInfo.typicalHalfwidthCharacterWidth;
		} else {
			lineDecorationsWidth = toInteger(opts.lineDecorationsWidth, 0);
		}
M
Martin Aeschlimann 已提交
116
		if (opts.folding) {
117
			lineDecorationsWidth += 16;
M
Martin Aeschlimann 已提交
118
		}
119

120
		let renderLineNumbers: boolean;
J
Johannes Rieken 已提交
121
		let renderCustomLineNumbers: (lineNumber: number) => string;
122
		let renderRelativeLineNumbers: boolean;
123 124 125 126 127 128 129 130
		{
			let lineNumbers = opts.lineNumbers;
			// Compatibility with old true or false values
			if (<any>lineNumbers === true) {
				lineNumbers = 'on';
			} else if (<any>lineNumbers === false) {
				lineNumbers = 'off';
			}
131

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
			if (typeof lineNumbers === 'function') {
				renderLineNumbers = true;
				renderCustomLineNumbers = lineNumbers;
				renderRelativeLineNumbers = false;
			} else if (lineNumbers === 'relative') {
				renderLineNumbers = true;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = true;
			} else if (lineNumbers === 'on') {
				renderLineNumbers = true;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = false;
			} else {
				renderLineNumbers = false;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = false;
			}
149 150
		}

E
Erich Gamma 已提交
151 152 153 154
		let layoutInfo = EditorLayoutProvider.compute({
			outerWidth: outerWidth,
			outerHeight: outerHeight,
			showGlyphMargin: glyphMargin,
155
			lineHeight: fontInfo.lineHeight,
156
			showLineNumbers: renderLineNumbers,
E
Erich Gamma 已提交
157
			lineNumbersMinChars: lineNumbersMinChars,
158
			lineNumbersDigitCount: lineNumbersDigitCount,
E
Erich Gamma 已提交
159
			lineDecorationsWidth: lineDecorationsWidth,
A
Alex Dima 已提交
160
			typicalHalfwidthCharacterWidth: fontInfo.typicalHalfwidthCharacterWidth,
161
			maxDigitWidth: fontInfo.maxDigitWidth,
E
Erich Gamma 已提交
162 163 164
			verticalScrollbarWidth: scrollbar.verticalScrollbarSize,
			horizontalScrollbarHeight: scrollbar.horizontalScrollbarSize,
			scrollbarArrowSize: scrollbar.arrowSize,
A
Alex Dima 已提交
165
			verticalScrollbarHasArrows: scrollbar.verticalHasArrows,
166
			minimap: minimap.enabled,
167
			minimapRenderCharacters: minimap.renderCharacters,
A
Alex Dima 已提交
168
			minimapMaxColumn: minimap.maxColumn,
169
			pixelRatio: pixelRatio
E
Erich Gamma 已提交
170 171
		});

172
		let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } = null;
173 174 175
		{
			let wordWrap = opts.wordWrap;
			let wordWrapColumn = toInteger(opts.wordWrapColumn, 1);
176
			let wordWrapMinified = toBoolean(opts.wordWrapMinified);
E
Erich Gamma 已提交
177

178 179 180 181 182 183 184
			// Compatibility with old true or false values
			if (<any>wordWrap === true) {
				wordWrap = 'on';
			} else if (<any>wordWrap === false) {
				wordWrap = 'off';
			}

185
			if (wordWrapMinified && isDominatedByLongLines) {
186 187
				// Force viewport width wrapping if model is dominated by long lines
				bareWrappingInfo = {
188
					isWordWrapMinified: true,
189 190 191 192 193
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
			} else if (wordWrap === 'on') {
				bareWrappingInfo = {
194
					isWordWrapMinified: false,
195 196 197
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
A
Alex Dima 已提交
198
			} else if (wordWrap === 'bounded') {
199
				bareWrappingInfo = {
200
					isWordWrapMinified: false,
201 202 203
					isViewportWrapping: true,
					wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn)
				};
A
Alex Dima 已提交
204
			} else if (wordWrap === 'wordWrapColumn') {
205
				bareWrappingInfo = {
206
					isWordWrapMinified: false,
207 208 209 210 211
					isViewportWrapping: false,
					wrappingColumn: wordWrapColumn
				};
			} else {
				bareWrappingInfo = {
212
					isWordWrapMinified: false,
213 214 215 216
					isViewportWrapping: false,
					wrappingColumn: -1
				};
			}
E
Erich Gamma 已提交
217
		}
218

219
		let wrappingInfo = new editorOptions.EditorWrappingInfo({
A
Alex Dima 已提交
220 221
			inDiffEditor: Boolean(opts.inDiffEditor),
			isDominatedByLongLines: isDominatedByLongLines,
222
			isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
223 224 225 226 227 228 229
			isViewportWrapping: bareWrappingInfo.isViewportWrapping,
			wrappingColumn: bareWrappingInfo.wrappingColumn,
			wrappingIndent: wrappingIndentFromString(opts.wrappingIndent),
			wordWrapBreakBeforeCharacters: String(opts.wordWrapBreakBeforeCharacters),
			wordWrapBreakAfterCharacters: String(opts.wordWrapBreakAfterCharacters),
			wordWrapBreakObtrusiveCharacters: String(opts.wordWrapBreakObtrusiveCharacters),
		});
E
Erich Gamma 已提交
230

231 232
		let readOnly = toBoolean(opts.readOnly);

233
		let tabFocusMode = TabFocus.getTabFocusMode();
234 235 236 237
		if (readOnly) {
			tabFocusMode = true;
		}

238

239 240 241 242 243 244 245 246
		let renderWhitespace = opts.renderWhitespace;
		// Compatibility with old true or false values
		if (<any>renderWhitespace === true) {
			renderWhitespace = 'boundary';
		} else if (<any>renderWhitespace === false) {
			renderWhitespace = 'none';
		}

247 248 249 250 251 252 253 254
		let renderLineHighlight = opts.renderLineHighlight;
		// Compatibility with old true or false values
		if (<any>renderLineHighlight === true) {
			renderLineHighlight = 'line';
		} else if (<any>renderLineHighlight === false) {
			renderLineHighlight = 'none';
		}

255
		let viewInfo = new editorOptions.InternalEditorViewOptions({
256
			theme: opts.theme,
257
			canUseTranslate3d: canUseTranslate3d,
258
			disableMonospaceOptimizations: (toBoolean(opts.disableMonospaceOptimizations) || toBoolean(opts.fontLigatures)),
259 260 261
			experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
			rulers: toSortedIntegerArray(opts.rulers),
			ariaLabel: String(opts.ariaLabel),
262 263 264
			renderLineNumbers: renderLineNumbers,
			renderCustomLineNumbers: renderCustomLineNumbers,
			renderRelativeLineNumbers: renderRelativeLineNumbers,
E
Erich Gamma 已提交
265 266 267 268 269
			selectOnLineNumbers: toBoolean(opts.selectOnLineNumbers),
			glyphMargin: glyphMargin,
			revealHorizontalRightPadding: toInteger(opts.revealHorizontalRightPadding, 0),
			roundedSelection: toBoolean(opts.roundedSelection),
			overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
270
			overviewRulerBorder: toBoolean(opts.overviewRulerBorder),
271
			cursorBlinking: cursorBlinkingStyleFromString(opts.cursorBlinking),
272
			mouseWheelZoom: toBoolean(opts.mouseWheelZoom),
A
Alex Dima 已提交
273
			cursorStyle: cursorStyleFromString(opts.cursorStyle),
E
Erich Gamma 已提交
274 275
			hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
			scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine),
276 277
			editorClassName: editorClassName,
			stopRenderingLineAfter: stopRenderingLineAfter,
278
			renderWhitespace: renderWhitespace,
279
			renderControlCharacters: toBoolean(opts.renderControlCharacters),
280
			fontLigatures: toBoolean(opts.fontLigatures),
281
			renderIndentGuides: toBoolean(opts.renderIndentGuides),
282
			renderLineHighlight: renderLineHighlight,
283
			scrollbar: scrollbar,
284
			minimap: minimap,
J
Joao Moreno 已提交
285
			fixedOverflowWidgets: toBoolean(opts.fixedOverflowWidgets)
286 287
		});

288
		let contribInfo = new editorOptions.EditorContribOptions({
289
			selectionClipboard: toBoolean(opts.selectionClipboard),
E
Erich Gamma 已提交
290 291
			hover: toBoolean(opts.hover),
			contextmenu: toBoolean(opts.contextmenu),
292
			quickSuggestions: typeof opts.quickSuggestions === 'object' ? { other: true, ...opts.quickSuggestions } : toBoolean(opts.quickSuggestions),
E
Erich Gamma 已提交
293
			quickSuggestionsDelay: toInteger(opts.quickSuggestionsDelay),
J
Joao Moreno 已提交
294
			parameterHints: toBoolean(opts.parameterHints),
E
Erich Gamma 已提交
295 296
			iconsInSuggestions: toBoolean(opts.iconsInSuggestions),
			formatOnType: toBoolean(opts.formatOnType),
297
			formatOnPaste: toBoolean(opts.formatOnPaste),
E
Erich Gamma 已提交
298
			suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters),
299
			acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter),
300
			acceptSuggestionOnCommitCharacter: toBoolean(opts.acceptSuggestionOnCommitCharacter),
301
			snippetSuggestions: opts.snippetSuggestions,
302
			emptySelectionClipboard: opts.emptySelectionClipboard,
303
			wordBasedSuggestions: opts.wordBasedSuggestions,
J
Joao Moreno 已提交
304 305
			suggestFontSize: opts.suggestFontSize,
			suggestLineHeight: opts.suggestLineHeight,
E
Erich Gamma 已提交
306
			selectionHighlight: toBoolean(opts.selectionHighlight),
307
			occurrencesHighlight: toBoolean(opts.occurrencesHighlight),
308
			codeLens: opts.referenceInfos && opts.codeLens,
M
Martin Aeschlimann 已提交
309
			folding: toBoolean(opts.folding),
310
			hideFoldIcons: toBoolean(opts.hideFoldIcons),
311
			matchBrackets: toBoolean(opts.matchBrackets),
A
Alex Dima 已提交
312 313
		});

314
		return new editorOptions.InternalEditorOptions({
315 316 317
			lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
			readOnly: readOnly,
			wordSeparators: String(opts.wordSeparators),
A
Alex Dima 已提交
318
			autoClosingBrackets: toBoolean(opts.autoClosingBrackets),
319
			useTabStops: toBoolean(opts.useTabStops),
320
			tabFocusMode: tabFocusMode,
321
			dragAndDrop: toBoolean(opts.dragAndDrop),
E
Erich Gamma 已提交
322
			layoutInfo: layoutInfo,
323
			fontInfo: fontInfo,
324
			viewInfo: viewInfo,
E
Erich Gamma 已提交
325
			wrappingInfo: wrappingInfo,
A
Alex Dima 已提交
326
			contribInfo: contribInfo,
327
		});
E
Erich Gamma 已提交
328 329
	}

330
	private static _sanitizeScrollbarOpts(raw: editorOptions.IEditorScrollbarOptions, mouseWheelScrollSensitivity: number): editorOptions.InternalEditorScrollbarOptions {
A
Alex Dima 已提交
331

A
Alex Dima 已提交
332
		let visibilityFromString = (visibility: string) => {
A
Alex Dima 已提交
333 334 335 336 337 338 339 340 341 342
			switch (visibility) {
				case 'hidden':
					return ScrollbarVisibility.Hidden;
				case 'visible':
					return ScrollbarVisibility.Visible;
				default:
					return ScrollbarVisibility.Auto;
			}
		};

A
Alex Dima 已提交
343 344
		let horizontalScrollbarSize = toIntegerWithDefault(raw.horizontalScrollbarSize, 10);
		let verticalScrollbarSize = toIntegerWithDefault(raw.verticalScrollbarSize, 14);
345
		return new editorOptions.InternalEditorScrollbarOptions({
A
Alex Dima 已提交
346 347
			vertical: visibilityFromString(raw.vertical),
			horizontal: visibilityFromString(raw.horizontal),
E
Erich Gamma 已提交
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362

			arrowSize: toIntegerWithDefault(raw.arrowSize, 11),
			useShadows: toBooleanWithDefault(raw.useShadows, true),

			verticalHasArrows: toBooleanWithDefault(raw.verticalHasArrows, false),
			horizontalHasArrows: toBooleanWithDefault(raw.horizontalHasArrows, false),

			horizontalScrollbarSize: horizontalScrollbarSize,
			horizontalSliderSize: toIntegerWithDefault(raw.horizontalSliderSize, horizontalScrollbarSize),

			verticalScrollbarSize: verticalScrollbarSize,
			verticalSliderSize: toIntegerWithDefault(raw.verticalSliderSize, verticalScrollbarSize),

			handleMouseWheel: toBooleanWithDefault(raw.handleMouseWheel, true),
			mouseWheelScrollSensitivity: mouseWheelScrollSensitivity
A
Alex Dima 已提交
363
		});
E
Erich Gamma 已提交
364
	}
365

366
	private static _sanitizeMinimapOpts(raw: editorOptions.IEditorMinimapOptions): editorOptions.InternalEditorMinimapOptions {
A
Alex Dima 已提交
367 368 369 370
		let maxColumn = toIntegerWithDefault(raw.maxColumn, DefaultConfig.editor.minimap.maxColumn);
		if (maxColumn < 1) {
			maxColumn = 1;
		}
371
		return new editorOptions.InternalEditorMinimapOptions({
A
Alex Dima 已提交
372 373 374
			enabled: toBooleanWithDefault(raw.enabled, DefaultConfig.editor.minimap.enabled),
			renderCharacters: toBooleanWithDefault(raw.renderCharacters, DefaultConfig.editor.minimap.renderCharacters),
			maxColumn: maxColumn,
375 376
		});
	}
E
Erich Gamma 已提交
377 378
}

J
Johannes Rieken 已提交
379
function toBoolean(value: any): boolean {
E
Erich Gamma 已提交
380 381 382
	return value === 'false' ? false : Boolean(value);
}

J
Johannes Rieken 已提交
383
function toBooleanWithDefault(value: any, defaultValue: boolean): boolean {
E
Erich Gamma 已提交
384 385 386 387 388 389 390
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	return toBoolean(value);
}

function toFloat(source: any, defaultValue: number): number {
A
Alex Dima 已提交
391
	let r = parseFloat(source);
E
Erich Gamma 已提交
392 393 394 395 396 397
	if (isNaN(r)) {
		r = defaultValue;
	}
	return r;
}

398
function toInteger(source: any, minimum: number = Constants.MIN_SAFE_SMALL_INTEGER, maximum: number = Constants.MAX_SAFE_SMALL_INTEGER): number {
A
Alex Dima 已提交
399
	let r = parseInt(source, 10);
E
Erich Gamma 已提交
400 401 402
	if (isNaN(r)) {
		r = 0;
	}
403 404 405
	r = Math.max(minimum, r);
	r = Math.min(maximum, r);
	return r | 0;
E
Erich Gamma 已提交
406 407
}

J
Johannes Rieken 已提交
408
function toSortedIntegerArray(source: any): number[] {
409 410 411 412 413 414 415 416 417
	if (!Array.isArray(source)) {
		return [];
	}
	let arrSource = <any[]>source;
	let r = arrSource.map(el => toInteger(el));
	r.sort();
	return r;
}

418
function wrappingIndentFromString(wrappingIndent: string): editorOptions.WrappingIndent {
A
Alex Dima 已提交
419
	if (wrappingIndent === 'indent') {
420
		return editorOptions.WrappingIndent.Indent;
A
Alex Dima 已提交
421
	} else if (wrappingIndent === 'same') {
422
		return editorOptions.WrappingIndent.Same;
A
Alex Dima 已提交
423
	} else {
424
		return editorOptions.WrappingIndent.None;
A
Alex Dima 已提交
425 426 427
	}
}

428
function cursorStyleFromString(cursorStyle: string): editorOptions.TextEditorCursorStyle {
A
Alex Dima 已提交
429
	if (cursorStyle === 'line') {
430
		return editorOptions.TextEditorCursorStyle.Line;
A
Alex Dima 已提交
431
	} else if (cursorStyle === 'block') {
432
		return editorOptions.TextEditorCursorStyle.Block;
A
Alex Dima 已提交
433
	} else if (cursorStyle === 'underline') {
434
		return editorOptions.TextEditorCursorStyle.Underline;
435
	} else if (cursorStyle === 'line-thin') {
436
		return editorOptions.TextEditorCursorStyle.LineThin;
437
	} else if (cursorStyle === 'block-outline') {
438
		return editorOptions.TextEditorCursorStyle.BlockOutline;
439
	} else if (cursorStyle === 'underline-thin') {
440
		return editorOptions.TextEditorCursorStyle.UnderlineThin;
A
Alex Dima 已提交
441
	}
442
	return editorOptions.TextEditorCursorStyle.Line;
A
Alex Dima 已提交
443 444
}

445
function cursorBlinkingStyleFromString(cursorBlinkingStyle: string): editorOptions.TextEditorCursorBlinkingStyle {
446 447
	switch (cursorBlinkingStyle) {
		case 'blink':
448
			return editorOptions.TextEditorCursorBlinkingStyle.Blink;
449
		case 'smooth':
450
			return editorOptions.TextEditorCursorBlinkingStyle.Smooth;
451
		case 'phase':
452
			return editorOptions.TextEditorCursorBlinkingStyle.Phase;
453
		case 'expand':
454
			return editorOptions.TextEditorCursorBlinkingStyle.Expand;
455 456
		case 'visible': // maintain compatibility
		case 'solid':
457
			return editorOptions.TextEditorCursorBlinkingStyle.Solid;
458
	}
459
	return editorOptions.TextEditorCursorBlinkingStyle.Blink;
460 461
}

J
Johannes Rieken 已提交
462
function toIntegerWithDefault(source: any, defaultValue: number): number {
E
Erich Gamma 已提交
463 464 465 466 467 468
	if (typeof source === 'undefined') {
		return defaultValue;
	}
	return toInteger(source);
}

469 470
export interface IElementSizeObserver {
	startObserving(): void;
J
Johannes Rieken 已提交
471
	observe(dimension?: editorCommon.IDimension): void;
472 473 474 475 476
	dispose(): void;
	getWidth(): number;
	getHeight(): number;
}

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

479 480
	public editor: editorOptions.InternalEditorOptions;
	public editorClone: editorOptions.InternalEditorOptions;
E
Erich Gamma 已提交
481

J
Johannes Rieken 已提交
482
	protected _configWithDefaults: ConfigurationWithDefaults;
483
	protected _elementSizeObserver: IElementSizeObserver;
J
Johannes Rieken 已提交
484
	private _isDominatedByLongLines: boolean;
485
	private _lineNumbersDigitCount: number;
E
Erich Gamma 已提交
486

487 488
	private _onDidChange = this._register(new Emitter<editorOptions.IConfigurationChangedEvent>());
	public onDidChange: Event<editorOptions.IConfigurationChangedEvent> = this._onDidChange.event;
A
Alex Dima 已提交
489

490
	constructor(options: editorOptions.IEditorOptions, elementSizeObserver: IElementSizeObserver = null) {
A
Alex Dima 已提交
491
		super();
E
Erich Gamma 已提交
492
		this._configWithDefaults = new ConfigurationWithDefaults(options);
493
		this._elementSizeObserver = elementSizeObserver;
E
Erich Gamma 已提交
494
		this._isDominatedByLongLines = false;
495
		this._lineNumbersDigitCount = 1;
E
Erich Gamma 已提交
496
		this.editor = this._computeInternalOptions();
497
		this.editorClone = this.editor.clone();
498
		this._register(EditorZoom.onDidChangeZoomLevel(_ => this._recomputeOptions()));
499
		this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions()));
E
Erich Gamma 已提交
500 501 502 503 504 505 506
	}

	public dispose(): void {
		super.dispose();
	}

	protected _recomputeOptions(): void {
507 508
		this._setOptions(this._computeInternalOptions());
	}
509

510
	private _setOptions(newOptions: editorOptions.InternalEditorOptions): void {
511 512
		if (this.editor && this.editor.equals(newOptions)) {
			return;
E
Erich Gamma 已提交
513 514
		}

515 516 517 518
		let changeEvent = this.editor.createChangeEvent(newOptions);
		this.editor = newOptions;
		this.editorClone = this.editor.clone();
		this._onDidChange.fire(changeEvent);
E
Erich Gamma 已提交
519 520
	}

521
	public getRawOptions(): editorOptions.IEditorOptions {
E
Erich Gamma 已提交
522 523 524
		return this._configWithDefaults.getEditorOptions();
	}

525
	private _computeInternalOptions(): editorOptions.InternalEditorOptions {
E
Erich Gamma 已提交
526 527
		let opts = this._configWithDefaults.getEditorOptions();

R
rebornix 已提交
528
		let editorClassName = this._getEditorClassName(opts.theme, toBoolean(opts.fontLigatures), opts.mouseStyle);
E
Erich Gamma 已提交
529

530 531 532 533 534 535
		let disableTranslate3d = toBoolean(opts.disableTranslate3d);
		let canUseTranslate3d = this._getCanUseTranslate3d();
		if (disableTranslate3d) {
			canUseTranslate3d = false;
		}

536
		let bareFontInfo = BareFontInfo.createFromRawSettings(opts, this.getZoomLevel());
537

538
		return InternalEditorOptionsHelper.createInternalEditorOptions(
E
Erich Gamma 已提交
539 540 541
			this.getOuterWidth(),
			this.getOuterHeight(),
			opts,
542
			this.readConfiguration(bareFontInfo),
543
			editorClassName,
E
Erich Gamma 已提交
544
			this._isDominatedByLongLines,
545
			this._lineNumbersDigitCount,
546 547
			canUseTranslate3d,
			this._getPixelRatio()
E
Erich Gamma 已提交
548 549 550
		);
	}

551
	public updateOptions(newOptions: editorOptions.IEditorOptions): void {
E
Erich Gamma 已提交
552 553 554 555
		this._configWithDefaults.updateOptions(newOptions);
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
556
	public setIsDominatedByLongLines(isDominatedByLongLines: boolean): void {
E
Erich Gamma 已提交
557 558 559 560
		this._isDominatedByLongLines = isDominatedByLongLines;
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
561
	public setMaxLineNumber(maxLineNumber: number): void {
562 563
		let digitCount = CommonEditorConfiguration.digitCount(maxLineNumber);
		if (this._lineNumbersDigitCount === digitCount) {
A
Alex Dima 已提交
564 565
			return;
		}
566
		this._lineNumbersDigitCount = digitCount;
E
Erich Gamma 已提交
567 568 569
		this._recomputeOptions();
	}

570 571 572 573 574 575 576 577 578
	private static digitCount(n: number): number {
		var r = 0;
		while (n) {
			n = Math.floor(n / 10);
			r++;
		}
		return r ? r : 1;
	}

R
rebornix 已提交
579
	protected abstract _getEditorClassName(theme: string, fontLigatures: boolean, mouseDrag: 'text' | 'default' | 'copy'): string;
E
Erich Gamma 已提交
580

581
	protected abstract getOuterWidth(): number;
E
Erich Gamma 已提交
582

583
	protected abstract getOuterHeight(): number;
E
Erich Gamma 已提交
584

585 586
	protected abstract _getCanUseTranslate3d(): boolean;

587 588
	protected abstract _getPixelRatio(): number;

589
	protected abstract readConfiguration(styling: BareFontInfo): FontInfo;
590 591

	protected abstract getZoomLevel(): number;
E
Erich Gamma 已提交
592 593
}

594 595
const configurationRegistry = <IConfigurationRegistry>Registry.as(Extensions.Configuration);
const editorConfiguration: IConfigurationNode = {
E
Erich Gamma 已提交
596 597 598
	'id': 'editor',
	'order': 5,
	'type': 'object',
599
	'title': nls.localize('editorConfigurationTitle', "Editor"),
600
	'overridable': true,
J
Johannes Rieken 已提交
601 602
	'properties': {
		'editor.fontFamily': {
E
Erich Gamma 已提交
603 604 605 606
			'type': 'string',
			'default': DefaultConfig.editor.fontFamily,
			'description': nls.localize('fontFamily', "Controls the font family.")
		},
J
Johannes Rieken 已提交
607
		'editor.fontWeight': {
608
			'type': 'string',
609
			'enum': ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
610 611 612
			'default': DefaultConfig.editor.fontWeight,
			'description': nls.localize('fontWeight', "Controls the font weight.")
		},
J
Johannes Rieken 已提交
613
		'editor.fontSize': {
E
Erich Gamma 已提交
614 615
			'type': 'number',
			'default': DefaultConfig.editor.fontSize,
616
			'description': nls.localize('fontSize', "Controls the font size in pixels.")
E
Erich Gamma 已提交
617
		},
J
Johannes Rieken 已提交
618
		'editor.lineHeight': {
E
Erich Gamma 已提交
619 620
			'type': 'number',
			'default': DefaultConfig.editor.lineHeight,
621
			'description': nls.localize('lineHeight', "Controls the line height. Use 0 to compute the lineHeight from the fontSize.")
E
Erich Gamma 已提交
622
		},
J
Johannes Rieken 已提交
623
		'editor.lineNumbers': {
624 625
			'type': 'string',
			'enum': ['off', 'on', 'relative'],
E
Erich Gamma 已提交
626
			'default': DefaultConfig.editor.lineNumbers,
627
			'description': nls.localize('lineNumbers', "Controls the display of line numbers. Possible values are 'on', 'off', and 'relative'. 'relative' shows the line count from the current cursor position.")
E
Erich Gamma 已提交
628
		},
J
Johannes Rieken 已提交
629
		'editor.rulers': {
630 631 632 633 634 635 636
			'type': 'array',
			'items': {
				'type': 'number'
			},
			'default': DefaultConfig.editor.rulers,
			'description': nls.localize('rulers', "Columns at which to show vertical rulers")
		},
J
Johannes Rieken 已提交
637
		'editor.wordSeparators': {
A
Alex Dima 已提交
638 639 640 641
			'type': 'string',
			'default': DefaultConfig.editor.wordSeparators,
			'description': nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations")
		},
J
Johannes Rieken 已提交
642
		'editor.tabSize': {
643 644
			'type': 'number',
			'default': DEFAULT_INDENTATION.tabSize,
E
Erich Gamma 已提交
645
			'minimum': 1,
646
			'description': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overriden based on the file contents when `editor.detectIndentation` is on."),
647
			'errorMessage': nls.localize('tabSize.errorMessage', "Expected 'number'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
648
		},
J
Johannes Rieken 已提交
649
		'editor.insertSpaces': {
650 651
			'type': 'boolean',
			'default': DEFAULT_INDENTATION.insertSpaces,
652
			'description': nls.localize('insertSpaces', "Insert spaces when pressing Tab. This setting is overriden based on the file contents when `editor.detectIndentation` is on."),
653
			'errorMessage': nls.localize('insertSpaces.errorMessage', "Expected 'boolean'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
654
		},
J
Johannes Rieken 已提交
655
		'editor.detectIndentation': {
656 657
			'type': 'boolean',
			'default': DEFAULT_INDENTATION.detectIndentation,
A
Alex Dima 已提交
658
			'description': nls.localize('detectIndentation', "When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.")
659
		},
J
Johannes Rieken 已提交
660
		'editor.roundedSelection': {
E
Erich Gamma 已提交
661 662 663 664
			'type': 'boolean',
			'default': DefaultConfig.editor.roundedSelection,
			'description': nls.localize('roundedSelection', "Controls if selections have rounded corners")
		},
J
Johannes Rieken 已提交
665
		'editor.scrollBeyondLastLine': {
E
Erich Gamma 已提交
666 667 668 669
			'type': 'boolean',
			'default': DefaultConfig.editor.scrollBeyondLastLine,
			'description': nls.localize('scrollBeyondLastLine', "Controls if the editor will scroll beyond the last line")
		},
670 671 672 673 674
		'editor.minimap.enabled': {
			'type': 'boolean',
			'default': DefaultConfig.editor.minimap.enabled,
			'description': nls.localize('minimap.enabled', "Controls if the minimap is shown")
		},
675
		'editor.minimap.renderCharacters': {
676
			'type': 'boolean',
677 678
			'default': DefaultConfig.editor.minimap.renderCharacters,
			'description': nls.localize('minimap.renderCharacters', "Render the actual characters on a line (as opposed to color blocks)")
679
		},
A
Alex Dima 已提交
680 681 682 683 684
		'editor.minimap.maxColumn': {
			'type': 'number',
			'default': DefaultConfig.editor.minimap.maxColumn,
			'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns")
		},
J
Johannes Rieken 已提交
685
		'editor.wordWrap': {
686
			'type': 'string',
A
Alex Dima 已提交
687
			'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
688 689 690
			'enumDescriptions': [
				nls.localize('wordWrap.off', "Lines will never wrap."),
				nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
A
Alex Dima 已提交
691 692 693 694 695 696
				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 已提交
697 698 699 700
				nls.localize({
					key: 'wordWrap.bounded',
					comment: [
						'- viewport means the edge of the visible window size.',
A
Alex Dima 已提交
701
						'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
A
Alex Dima 已提交
702 703
					]
				}, "Lines will wrap at the minimum of viewport and `editor.wordWrapColumn`."),
704
			],
705
			'default': DefaultConfig.editor.wordWrap,
A
Alex Dima 已提交
706 707 708 709 710 711 712
			'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`).")
713 714 715 716 717
		},
		'editor.wordWrapColumn': {
			'type': 'integer',
			'default': DefaultConfig.editor.wordWrapColumn,
			'minimum': 1,
A
Alex Dima 已提交
718 719 720 721 722 723 724
			'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'.")
725
		},
J
Johannes Rieken 已提交
726
		'editor.wrappingIndent': {
E
Erich Gamma 已提交
727 728 729 730 731
			'type': 'string',
			'enum': ['none', 'same', 'indent'],
			'default': DefaultConfig.editor.wrappingIndent,
			'description': nls.localize('wrappingIndent', "Controls the indentation of wrapped lines. Can be one of 'none', 'same' or 'indent'.")
		},
J
Johannes Rieken 已提交
732
		'editor.mouseWheelScrollSensitivity': {
E
Erich Gamma 已提交
733 734 735 736
			'type': 'number',
			'default': DefaultConfig.editor.mouseWheelScrollSensitivity,
			'description': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events")
		},
J
Johannes Rieken 已提交
737
		'editor.quickSuggestions': {
738
			'anyOf': [
739 740 741
				{
					type: 'boolean',
				},
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
				{
					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.")
						},
					}
				}
			],
E
Erich Gamma 已提交
763
			'default': DefaultConfig.editor.quickSuggestions,
764
			'description': nls.localize('quickSuggestions', "Controls if suggestions should automatically show up while typing")
E
Erich Gamma 已提交
765
		},
J
Johannes Rieken 已提交
766
		'editor.quickSuggestionsDelay': {
E
Erich Gamma 已提交
767 768 769 770 771
			'type': 'integer',
			'default': DefaultConfig.editor.quickSuggestionsDelay,
			'minimum': 0,
			'description': nls.localize('quickSuggestionsDelay', "Controls the delay in ms after which quick suggestions will show up")
		},
J
Johannes Rieken 已提交
772
		'editor.parameterHints': {
J
Joao Moreno 已提交
773 774 775 776
			'type': 'boolean',
			'default': DefaultConfig.editor.parameterHints,
			'description': nls.localize('parameterHints', "Enables parameter hints")
		},
J
Johannes Rieken 已提交
777
		'editor.autoClosingBrackets': {
E
Erich Gamma 已提交
778 779 780 781
			'type': 'boolean',
			'default': DefaultConfig.editor.autoClosingBrackets,
			'description': nls.localize('autoClosingBrackets', "Controls if the editor should automatically close brackets after opening them")
		},
J
Johannes Rieken 已提交
782
		'editor.formatOnType': {
E
Erich Gamma 已提交
783 784 785 786
			'type': 'boolean',
			'default': DefaultConfig.editor.formatOnType,
			'description': nls.localize('formatOnType', "Controls if the editor should automatically format the line after typing")
		},
787 788 789
		'editor.formatOnPaste': {
			'type': 'boolean',
			'default': DefaultConfig.editor.formatOnPaste,
790
			'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.")
791
		},
J
Johannes Rieken 已提交
792
		'editor.suggestOnTriggerCharacters': {
E
Erich Gamma 已提交
793 794 795 796
			'type': 'boolean',
			'default': DefaultConfig.editor.suggestOnTriggerCharacters,
			'description': nls.localize('suggestOnTriggerCharacters', "Controls if suggestions should automatically show up when typing trigger characters")
		},
J
Johannes Rieken 已提交
797
		'editor.acceptSuggestionOnEnter': {
798 799
			'type': 'boolean',
			'default': DefaultConfig.editor.acceptSuggestionOnEnter,
800 801 802 803 804 805
			'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.")
		},
		'editor.acceptSuggestionOnCommitCharacter': {
			'type': 'boolean',
			'default': DefaultConfig.editor.acceptSuggestionOnCommitCharacter,
			'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.")
806
		},
807
		'editor.snippetSuggestions': {
808
			'type': 'string',
809 810 811
			'enum': ['top', 'bottom', 'inline', 'none'],
			'default': DefaultConfig.editor.snippetSuggestions,
			'description': nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.")
812
		},
813 814 815 816 817
		'editor.emptySelectionClipboard': {
			'type': 'boolean',
			'default': DefaultConfig.editor.emptySelectionClipboard,
			'description': nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.")
		},
818
		'editor.wordBasedSuggestions': {
819
			'type': 'boolean',
820
			'default': DefaultConfig.editor.wordBasedSuggestions,
J
Johannes Rieken 已提交
821
			'description': nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
822
		},
J
Johannes Rieken 已提交
823
		'editor.suggestFontSize': {
J
Joao Moreno 已提交
824 825 826 827 828
			'type': 'integer',
			'default': 0,
			'minimum': 0,
			'description': nls.localize('suggestFontSize', "Font size for the suggest widget")
		},
J
Johannes Rieken 已提交
829
		'editor.suggestLineHeight': {
J
Joao Moreno 已提交
830 831 832 833 834
			'type': 'integer',
			'default': 0,
			'minimum': 0,
			'description': nls.localize('suggestLineHeight', "Line height for the suggest widget")
		},
J
Johannes Rieken 已提交
835
		'editor.selectionHighlight': {
E
Erich Gamma 已提交
836 837 838 839
			'type': 'boolean',
			'default': DefaultConfig.editor.selectionHighlight,
			'description': nls.localize('selectionHighlight', "Controls whether the editor should highlight similar matches to the selection")
		},
840 841 842 843 844
		'editor.occurrencesHighlight': {
			'type': 'boolean',
			'default': DefaultConfig.editor.occurrencesHighlight,
			'description': nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences")
		},
J
Johannes Rieken 已提交
845
		'editor.overviewRulerLanes': {
E
Erich Gamma 已提交
846 847 848 849
			'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")
		},
850
		'editor.overviewRulerBorder': {
851
			'type': 'boolean',
852 853
			'default': DefaultConfig.editor.overviewRulerBorder,
			'description': nls.localize('overviewRulerBorder', "Controls if a border should be drawn around the overview ruler.")
854
		},
J
Johannes Rieken 已提交
855
		'editor.cursorBlinking': {
856
			'type': 'string',
857
			'enum': ['blink', 'smooth', 'phase', 'expand', 'solid'],
858
			'default': DefaultConfig.editor.cursorBlinking,
859
			'description': nls.localize('cursorBlinking', "Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'")
860
		},
861 862 863 864 865
		'editor.mouseWheelZoom': {
			'type': 'boolean',
			'default': DefaultConfig.editor.mouseWheelZoom,
			'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding Ctrl")
		},
J
Johannes Rieken 已提交
866
		'editor.cursorStyle': {
M
markrendle 已提交
867
			'type': 'string',
868
			'enum': ['block', 'block-outline', 'line', 'line-thin', 'underline', 'underline-thin'],
M
markrendle 已提交
869
			'default': DefaultConfig.editor.cursorStyle,
870
			'description': nls.localize('cursorStyle', "Controls the cursor style, accepted values are 'block', 'block-outline', 'line', 'line-thin', 'underline' and 'underline-thin'")
M
markrendle 已提交
871
		},
J
Johannes Rieken 已提交
872
		'editor.fontLigatures': {
873 874 875 876
			'type': 'boolean',
			'default': DefaultConfig.editor.fontLigatures,
			'description': nls.localize('fontLigatures', "Enables font ligatures")
		},
J
Johannes Rieken 已提交
877
		'editor.hideCursorInOverviewRuler': {
E
Erich Gamma 已提交
878 879 880 881 882
			'type': 'boolean',
			'default': DefaultConfig.editor.hideCursorInOverviewRuler,
			'description': nls.localize('hideCursorInOverviewRuler', "Controls if the cursor should be hidden in the overview ruler.")
		},
		'editor.renderWhitespace': {
883 884
			'type': 'string',
			'enum': ['none', 'boundary', 'all'],
E
Erich Gamma 已提交
885
			default: DefaultConfig.editor.renderWhitespace,
886
			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 已提交
887
		},
888 889 890 891 892
		'editor.renderControlCharacters': {
			'type': 'boolean',
			default: DefaultConfig.editor.renderControlCharacters,
			description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters")
		},
893 894 895 896 897
		'editor.renderIndentGuides': {
			'type': 'boolean',
			default: DefaultConfig.editor.renderIndentGuides,
			description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides")
		},
898
		'editor.renderLineHighlight': {
899 900
			'type': 'string',
			'enum': ['none', 'gutter', 'line', 'all'],
901
			default: DefaultConfig.editor.renderLineHighlight,
902
			description: nls.localize('renderLineHighlight', "Controls how the editor should render the current line highlight, possibilities are 'none', 'gutter', 'line', and 'all'.")
903
		},
J
Johannes Rieken 已提交
904
		'editor.codeLens': {
E
Erich Gamma 已提交
905
			'type': 'boolean',
906 907
			'default': DefaultConfig.editor.codeLens,
			'description': nls.localize('codeLens', "Controls if the editor shows code lenses")
E
Erich Gamma 已提交
908
		},
J
Johannes Rieken 已提交
909
		'editor.folding': {
M
Martin Aeschlimann 已提交
910 911
			'type': 'boolean',
			'default': DefaultConfig.editor.folding,
912
			'description': nls.localize('folding', "Controls whether the editor has code folding enabled")
M
Martin Aeschlimann 已提交
913
		},
914 915 916 917 918
		'editor.hideFoldIcons': {
			'type': 'boolean',
			'default': DefaultConfig.editor.hideFoldIcons,
			'description': nls.localize('hideFoldIcons', "Controls whether the fold icons on the gutter are automatically hidden.")
		},
919
		'editor.matchBrackets': {
920
			'type': 'boolean',
921 922
			'default': DefaultConfig.editor.matchBrackets,
			'description': nls.localize('matchBrackets', "Highlight matching brackets when one of them is selected.")
923
		},
I
isidor 已提交
924 925 926 927 928
		'editor.glyphMargin': {
			'type': 'boolean',
			'default': DefaultConfig.editor.glyphMargin,
			'description': nls.localize('glyphMargin', "Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.")
		},
J
Johannes Rieken 已提交
929
		'editor.useTabStops': {
930 931 932 933
			'type': 'boolean',
			'default': DefaultConfig.editor.useTabStops,
			'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops")
		},
J
Johannes Rieken 已提交
934
		'editor.trimAutoWhitespace': {
935
			'type': 'boolean',
936
			'default': DEFAULT_TRIM_AUTO_WHITESPACE,
937 938
			'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace")
		},
J
Johannes Rieken 已提交
939
		'editor.stablePeek': {
940
			'type': 'boolean',
941
			'default': false,
942
			'description': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting Escape.")
943
		},
944
		'editor.dragAndDrop': {
945
			'type': 'boolean',
946 947
			'default': DefaultConfig.editor.dragAndDrop,
			'description': nls.localize('dragAndDrop', "Controls if the editor should allow to move selections via drag and drop.")
948
		},
J
Johannes Rieken 已提交
949
		'diffEditor.renderSideBySide': {
E
Erich Gamma 已提交
950 951 952 953
			'type': 'boolean',
			'default': true,
			'description': nls.localize('sideBySide', "Controls if the diff editor shows the diff side by side or inline")
		},
J
Johannes Rieken 已提交
954
		'diffEditor.ignoreTrimWhitespace': {
E
Erich Gamma 已提交
955 956 957
			'type': 'boolean',
			'default': true,
			'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs")
958 959 960 961 962
		},
		'diffEditor.renderIndicators': {
			'type': 'boolean',
			'default': true,
			'description': nls.localize('renderIndicators', "Controls if the diff editor shows +/- indicators for added/removed changes")
E
Erich Gamma 已提交
963 964
		}
	}
A
Alex Dima 已提交
965 966 967 968 969 970 971 972 973 974
};

if (platform.isLinux) {
	editorConfiguration['properties']['editor.selectionClipboard'] = {
		'type': 'boolean',
		'default': DefaultConfig.editor.selectionClipboard,
		'description': nls.localize('selectionClipboard', "Controls if the Linux primary clipboard should be supported.")
	};
}

975
configurationRegistry.registerConfiguration(editorConfiguration);