commonEditorConfig.ts 35.8 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';
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 34 35 36 37
}

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

	private _onDidChangeTabFocus: Emitter<boolean> = new Emitter<boolean>();
J
Johannes Rieken 已提交
38
	public 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);
	}
};

54 55 56 57 58 59 60 61 62 63 64 65 66
/**
 * Experimental screen reader support toggle
 */
export class GlobalScreenReaderNVDA {

	private static _value = false;
	private static _onChange = new Emitter<boolean>();
	public static onChange: Event<boolean> = GlobalScreenReaderNVDA._onChange.event;

	public static getValue(): boolean {
		return this._value;
	}

J
Johannes Rieken 已提交
67
	public static setValue(value: boolean): void {
68 69 70 71 72 73 74 75
		if (this._value === value) {
			return;
		}
		this._value = value;
		this._onChange.fire(this._value);
	}
}

E
Erich Gamma 已提交
76 77
export class ConfigurationWithDefaults {

J
Johannes Rieken 已提交
78
	private _editor: editorCommon.IEditorOptions;
E
Erich Gamma 已提交
79

J
Johannes Rieken 已提交
80
	constructor(options: editorCommon.IEditorOptions) {
A
Alex Dima 已提交
81
		this._editor = <editorCommon.IEditorOptions>objects.clone(DefaultConfig.editor);
E
Erich Gamma 已提交
82 83 84 85

		this._mergeOptionsIn(options);
	}

A
Alex Dima 已提交
86
	public getEditorOptions(): editorCommon.IEditorOptions {
E
Erich Gamma 已提交
87 88 89
		return this._editor;
	}

J
Johannes Rieken 已提交
90
	private _mergeOptionsIn(newOptions: editorCommon.IEditorOptions): void {
A
Alex Dima 已提交
91
		this._editor = objects.mixin(this._editor, newOptions || {});
E
Erich Gamma 已提交
92 93
	}

J
Johannes Rieken 已提交
94
	public updateOptions(newOptions: editorCommon.IEditorOptions): void {
E
Erich Gamma 已提交
95 96 97 98 99 100 101 102 103 104 105
		// Apply new options
		this._mergeOptionsIn(newOptions);
	}
}

class InternalEditorOptionsHelper {

	constructor() {
	}

	public static createInternalEditorOptions(
106 107
		outerWidth: number,
		outerHeight: number,
J
Johannes Rieken 已提交
108
		opts: editorCommon.IEditorOptions,
109
		fontInfo: FontInfo,
J
Johannes Rieken 已提交
110 111
		editorClassName: string,
		isDominatedByLongLines: boolean,
112
		lineNumbersDigitCount: number,
113 114
		canUseTranslate3d: boolean,
		pixelRatio: number
115
	): editorCommon.InternalEditorOptions {
E
Erich Gamma 已提交
116

J
Johannes Rieken 已提交
117
		let stopRenderingLineAfter: number;
E
Erich Gamma 已提交
118 119 120 121 122 123
		if (typeof opts.stopRenderingLineAfter !== 'undefined') {
			stopRenderingLineAfter = toInteger(opts.stopRenderingLineAfter, -1);
		} else {
			stopRenderingLineAfter = 10000;
		}

124
		let scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, toFloat(opts.mouseWheelScrollSensitivity, 1));
125
		let minimap = this._sanitizeMinimapOpts(opts.minimap);
E
Erich Gamma 已提交
126 127 128

		let glyphMargin = toBoolean(opts.glyphMargin);
		let lineNumbersMinChars = toInteger(opts.lineNumbersMinChars, 1);
129 130 131 132 133 134 135 136

		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 已提交
137
		if (opts.folding) {
138
			lineDecorationsWidth += 16;
M
Martin Aeschlimann 已提交
139
		}
140

141
		let renderLineNumbers: boolean;
J
Johannes Rieken 已提交
142
		let renderCustomLineNumbers: (lineNumber: number) => string;
143
		let renderRelativeLineNumbers: boolean;
144 145 146 147 148 149 150 151
		{
			let lineNumbers = opts.lineNumbers;
			// Compatibility with old true or false values
			if (<any>lineNumbers === true) {
				lineNumbers = 'on';
			} else if (<any>lineNumbers === false) {
				lineNumbers = 'off';
			}
152

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
			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;
			}
170 171
		}

E
Erich Gamma 已提交
172 173 174 175
		let layoutInfo = EditorLayoutProvider.compute({
			outerWidth: outerWidth,
			outerHeight: outerHeight,
			showGlyphMargin: glyphMargin,
176
			lineHeight: fontInfo.lineHeight,
177
			showLineNumbers: renderLineNumbers,
E
Erich Gamma 已提交
178
			lineNumbersMinChars: lineNumbersMinChars,
179
			lineNumbersDigitCount: lineNumbersDigitCount,
E
Erich Gamma 已提交
180
			lineDecorationsWidth: lineDecorationsWidth,
A
Alex Dima 已提交
181
			typicalHalfwidthCharacterWidth: fontInfo.typicalHalfwidthCharacterWidth,
182
			maxDigitWidth: fontInfo.maxDigitWidth,
E
Erich Gamma 已提交
183 184 185
			verticalScrollbarWidth: scrollbar.verticalScrollbarSize,
			horizontalScrollbarHeight: scrollbar.horizontalScrollbarSize,
			scrollbarArrowSize: scrollbar.arrowSize,
A
Alex Dima 已提交
186
			verticalScrollbarHasArrows: scrollbar.verticalHasArrows,
187
			minimap: minimap.enabled,
188
			minimapRenderCharacters: minimap.renderCharacters,
A
Alex Dima 已提交
189
			minimapMaxColumn: minimap.maxColumn,
190
			pixelRatio: pixelRatio
E
Erich Gamma 已提交
191 192
		});

193 194 195 196
		let bareWrappingInfo: { isViewportWrapping: boolean; wrappingColumn: number; } = null;
		{
			let wordWrap = opts.wordWrap;
			let wordWrapColumn = toInteger(opts.wordWrapColumn, 1);
197
			let wordWrapMinified = toBoolean(opts.wordWrapMinified);
E
Erich Gamma 已提交
198

199 200 201 202 203 204 205
			// Compatibility with old true or false values
			if (<any>wordWrap === true) {
				wordWrap = 'on';
			} else if (<any>wordWrap === false) {
				wordWrap = 'off';
			}

206
			if (wordWrapMinified && isDominatedByLongLines) {
207 208 209 210 211 212 213 214 215 216
				// Force viewport width wrapping if model is dominated by long lines
				bareWrappingInfo = {
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
			} else if (wordWrap === 'on') {
				bareWrappingInfo = {
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
A
Alex Dima 已提交
217
			} else if (wordWrap === 'bounded') {
218 219 220 221
				bareWrappingInfo = {
					isViewportWrapping: true,
					wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn)
				};
A
Alex Dima 已提交
222
			} else if (wordWrap === 'wordWrapColumn') {
223 224 225 226 227 228 229 230 231 232
				bareWrappingInfo = {
					isViewportWrapping: false,
					wrappingColumn: wordWrapColumn
				};
			} else {
				bareWrappingInfo = {
					isViewportWrapping: false,
					wrappingColumn: -1
				};
			}
E
Erich Gamma 已提交
233
		}
234

235 236 237 238 239 240 241 242
		let wrappingInfo = new editorCommon.EditorWrappingInfo({
			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 已提交
243

244 245
		let readOnly = toBoolean(opts.readOnly);

246
		let tabFocusMode = TabFocus.getTabFocusMode();
247 248 249 250
		if (readOnly) {
			tabFocusMode = true;
		}

251

252 253 254 255 256 257 258 259
		let renderWhitespace = opts.renderWhitespace;
		// Compatibility with old true or false values
		if (<any>renderWhitespace === true) {
			renderWhitespace = 'boundary';
		} else if (<any>renderWhitespace === false) {
			renderWhitespace = 'none';
		}

260 261 262 263 264 265 266 267
		let renderLineHighlight = opts.renderLineHighlight;
		// Compatibility with old true or false values
		if (<any>renderLineHighlight === true) {
			renderLineHighlight = 'line';
		} else if (<any>renderLineHighlight === false) {
			renderLineHighlight = 'none';
		}

268
		let viewInfo = new editorCommon.InternalEditorViewOptions({
269
			theme: opts.theme,
270
			canUseTranslate3d: canUseTranslate3d,
271
			disableMonospaceOptimizations: (toBoolean(opts.disableMonospaceOptimizations) || toBoolean(opts.fontLigatures)),
272 273 274
			experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
			rulers: toSortedIntegerArray(opts.rulers),
			ariaLabel: String(opts.ariaLabel),
275 276 277
			renderLineNumbers: renderLineNumbers,
			renderCustomLineNumbers: renderCustomLineNumbers,
			renderRelativeLineNumbers: renderRelativeLineNumbers,
E
Erich Gamma 已提交
278 279 280 281 282
			selectOnLineNumbers: toBoolean(opts.selectOnLineNumbers),
			glyphMargin: glyphMargin,
			revealHorizontalRightPadding: toInteger(opts.revealHorizontalRightPadding, 0),
			roundedSelection: toBoolean(opts.roundedSelection),
			overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
283
			hideOverviewRulerBorder: toBoolean(opts.hideOverviewRulerBorder),
284
			cursorBlinking: cursorBlinkingStyleFromString(opts.cursorBlinking),
285
			mouseWheelZoom: toBoolean(opts.mouseWheelZoom),
A
Alex Dima 已提交
286
			cursorStyle: cursorStyleFromString(opts.cursorStyle),
E
Erich Gamma 已提交
287 288
			hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
			scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine),
289 290
			editorClassName: editorClassName,
			stopRenderingLineAfter: stopRenderingLineAfter,
291
			renderWhitespace: renderWhitespace,
292
			renderControlCharacters: toBoolean(opts.renderControlCharacters),
293
			renderIndentGuides: toBoolean(opts.renderIndentGuides),
294
			renderLineHighlight: renderLineHighlight,
295
			scrollbar: scrollbar,
296
			minimap: minimap,
J
Joao Moreno 已提交
297
			fixedOverflowWidgets: toBoolean(opts.fixedOverflowWidgets)
298 299
		});

A
Alex Dima 已提交
300
		let contribInfo = new editorCommon.EditorContribOptions({
301
			selectionClipboard: toBoolean(opts.selectionClipboard),
E
Erich Gamma 已提交
302 303 304 305
			hover: toBoolean(opts.hover),
			contextmenu: toBoolean(opts.contextmenu),
			quickSuggestions: toBoolean(opts.quickSuggestions),
			quickSuggestionsDelay: toInteger(opts.quickSuggestionsDelay),
J
Joao Moreno 已提交
306
			parameterHints: toBoolean(opts.parameterHints),
E
Erich Gamma 已提交
307 308
			iconsInSuggestions: toBoolean(opts.iconsInSuggestions),
			formatOnType: toBoolean(opts.formatOnType),
309
			formatOnPaste: toBoolean(opts.formatOnPaste),
E
Erich Gamma 已提交
310
			suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters),
311
			acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter),
312
			acceptSuggestionOnCommitCharacter: toBoolean(opts.acceptSuggestionOnCommitCharacter),
313
			snippetSuggestions: opts.snippetSuggestions,
314
			emptySelectionClipboard: opts.emptySelectionClipboard,
315
			wordBasedSuggestions: opts.wordBasedSuggestions,
J
Joao Moreno 已提交
316 317
			suggestFontSize: opts.suggestFontSize,
			suggestLineHeight: opts.suggestLineHeight,
E
Erich Gamma 已提交
318
			selectionHighlight: toBoolean(opts.selectionHighlight),
319
			occurrencesHighlight: toBoolean(opts.occurrencesHighlight),
320
			codeLens: opts.referenceInfos && opts.codeLens,
M
Martin Aeschlimann 已提交
321
			folding: toBoolean(opts.folding),
322
			matchBrackets: toBoolean(opts.matchBrackets),
A
Alex Dima 已提交
323 324
		});

325 326 327 328
		return new editorCommon.InternalEditorOptions({
			lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
			readOnly: readOnly,
			wordSeparators: String(opts.wordSeparators),
A
Alex Dima 已提交
329
			autoClosingBrackets: toBoolean(opts.autoClosingBrackets),
330
			useTabStops: toBoolean(opts.useTabStops),
331
			tabFocusMode: tabFocusMode,
332
			dragAndDrop: toBoolean(opts.dragAndDrop),
E
Erich Gamma 已提交
333
			layoutInfo: layoutInfo,
334
			fontInfo: fontInfo,
335
			viewInfo: viewInfo,
E
Erich Gamma 已提交
336
			wrappingInfo: wrappingInfo,
A
Alex Dima 已提交
337
			contribInfo: contribInfo,
338
		});
E
Erich Gamma 已提交
339 340
	}

J
Johannes Rieken 已提交
341
	private static _sanitizeScrollbarOpts(raw: editorCommon.IEditorScrollbarOptions, mouseWheelScrollSensitivity: number): editorCommon.InternalEditorScrollbarOptions {
A
Alex Dima 已提交
342

A
Alex Dima 已提交
343
		let visibilityFromString = (visibility: string) => {
A
Alex Dima 已提交
344 345 346 347 348 349 350 351 352 353
			switch (visibility) {
				case 'hidden':
					return ScrollbarVisibility.Hidden;
				case 'visible':
					return ScrollbarVisibility.Visible;
				default:
					return ScrollbarVisibility.Auto;
			}
		};

A
Alex Dima 已提交
354 355
		let horizontalScrollbarSize = toIntegerWithDefault(raw.horizontalScrollbarSize, 10);
		let verticalScrollbarSize = toIntegerWithDefault(raw.verticalScrollbarSize, 14);
A
Alex Dima 已提交
356 357 358
		return new editorCommon.InternalEditorScrollbarOptions({
			vertical: visibilityFromString(raw.vertical),
			horizontal: visibilityFromString(raw.horizontal),
E
Erich Gamma 已提交
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373

			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 已提交
374
		});
E
Erich Gamma 已提交
375
	}
376 377

	private static _sanitizeMinimapOpts(raw: editorCommon.IEditorMinimapOptions): editorCommon.InternalEditorMinimapOptions {
A
Alex Dima 已提交
378 379 380 381
		let maxColumn = toIntegerWithDefault(raw.maxColumn, DefaultConfig.editor.minimap.maxColumn);
		if (maxColumn < 1) {
			maxColumn = 1;
		}
382
		return new editorCommon.InternalEditorMinimapOptions({
A
Alex Dima 已提交
383 384 385
			enabled: toBooleanWithDefault(raw.enabled, DefaultConfig.editor.minimap.enabled),
			renderCharacters: toBooleanWithDefault(raw.renderCharacters, DefaultConfig.editor.minimap.renderCharacters),
			maxColumn: maxColumn,
386 387
		});
	}
E
Erich Gamma 已提交
388 389
}

J
Johannes Rieken 已提交
390
function toBoolean(value: any): boolean {
E
Erich Gamma 已提交
391 392 393
	return value === 'false' ? false : Boolean(value);
}

J
Johannes Rieken 已提交
394
function toBooleanWithDefault(value: any, defaultValue: boolean): boolean {
E
Erich Gamma 已提交
395 396 397 398 399 400 401
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	return toBoolean(value);
}

function toFloat(source: any, defaultValue: number): number {
A
Alex Dima 已提交
402
	let r = parseFloat(source);
E
Erich Gamma 已提交
403 404 405 406 407 408
	if (isNaN(r)) {
		r = defaultValue;
	}
	return r;
}

409
function toInteger(source: any, minimum: number = Constants.MIN_SAFE_SMALL_INTEGER, maximum: number = Constants.MAX_SAFE_SMALL_INTEGER): number {
A
Alex Dima 已提交
410
	let r = parseInt(source, 10);
E
Erich Gamma 已提交
411 412 413
	if (isNaN(r)) {
		r = 0;
	}
414 415 416
	r = Math.max(minimum, r);
	r = Math.min(maximum, r);
	return r | 0;
E
Erich Gamma 已提交
417 418
}

J
Johannes Rieken 已提交
419
function toSortedIntegerArray(source: any): number[] {
420 421 422 423 424 425 426 427 428
	if (!Array.isArray(source)) {
		return [];
	}
	let arrSource = <any[]>source;
	let r = arrSource.map(el => toInteger(el));
	r.sort();
	return r;
}

J
Johannes Rieken 已提交
429
function wrappingIndentFromString(wrappingIndent: string): editorCommon.WrappingIndent {
A
Alex Dima 已提交
430 431 432 433 434 435 436 437 438
	if (wrappingIndent === 'indent') {
		return editorCommon.WrappingIndent.Indent;
	} else if (wrappingIndent === 'same') {
		return editorCommon.WrappingIndent.Same;
	} else {
		return editorCommon.WrappingIndent.None;
	}
}

J
Johannes Rieken 已提交
439
function cursorStyleFromString(cursorStyle: string): editorCommon.TextEditorCursorStyle {
A
Alex Dima 已提交
440 441 442 443 444 445
	if (cursorStyle === 'line') {
		return editorCommon.TextEditorCursorStyle.Line;
	} else if (cursorStyle === 'block') {
		return editorCommon.TextEditorCursorStyle.Block;
	} else if (cursorStyle === 'underline') {
		return editorCommon.TextEditorCursorStyle.Underline;
446 447 448 449
	} else if (cursorStyle === 'line-thin') {
		return editorCommon.TextEditorCursorStyle.LineThin;
	} else if (cursorStyle === 'block-outline') {
		return editorCommon.TextEditorCursorStyle.BlockOutline;
450 451
	} else if (cursorStyle === 'underline-thin') {
		return editorCommon.TextEditorCursorStyle.UnderlineThin;
A
Alex Dima 已提交
452 453 454 455
	}
	return editorCommon.TextEditorCursorStyle.Line;
}

456
function cursorBlinkingStyleFromString(cursorBlinkingStyle: string): editorCommon.TextEditorCursorBlinkingStyle {
457 458 459 460 461 462 463 464 465 466 467 468
	switch (cursorBlinkingStyle) {
		case 'blink':
			return editorCommon.TextEditorCursorBlinkingStyle.Blink;
		case 'smooth':
			return editorCommon.TextEditorCursorBlinkingStyle.Smooth;
		case 'phase':
			return editorCommon.TextEditorCursorBlinkingStyle.Phase;
		case 'expand':
			return editorCommon.TextEditorCursorBlinkingStyle.Expand;
		case 'visible': // maintain compatibility
		case 'solid':
			return editorCommon.TextEditorCursorBlinkingStyle.Solid;
469 470 471 472
	}
	return editorCommon.TextEditorCursorBlinkingStyle.Blink;
}

J
Johannes Rieken 已提交
473
function toIntegerWithDefault(source: any, defaultValue: number): number {
E
Erich Gamma 已提交
474 475 476 477 478 479
	if (typeof source === 'undefined') {
		return defaultValue;
	}
	return toInteger(source);
}

480 481
export interface IElementSizeObserver {
	startObserving(): void;
J
Johannes Rieken 已提交
482
	observe(dimension?: editorCommon.IDimension): void;
483 484 485 486 487
	dispose(): void;
	getWidth(): number;
	getHeight(): number;
}

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

J
Johannes Rieken 已提交
490 491
	public editor: editorCommon.InternalEditorOptions;
	public editorClone: editorCommon.InternalEditorOptions;
E
Erich Gamma 已提交
492

J
Johannes Rieken 已提交
493
	protected _configWithDefaults: ConfigurationWithDefaults;
494
	protected _elementSizeObserver: IElementSizeObserver;
J
Johannes Rieken 已提交
495
	private _isDominatedByLongLines: boolean;
496
	private _lineNumbersDigitCount: number;
E
Erich Gamma 已提交
497

A
Alex Dima 已提交
498 499
	private _onDidChange = this._register(new Emitter<editorCommon.IConfigurationChangedEvent>());
	public onDidChange: Event<editorCommon.IConfigurationChangedEvent> = this._onDidChange.event;
A
Alex Dima 已提交
500

J
Johannes Rieken 已提交
501
	constructor(options: editorCommon.IEditorOptions, elementSizeObserver: IElementSizeObserver = null) {
A
Alex Dima 已提交
502
		super();
E
Erich Gamma 已提交
503
		this._configWithDefaults = new ConfigurationWithDefaults(options);
504
		this._elementSizeObserver = elementSizeObserver;
E
Erich Gamma 已提交
505
		this._isDominatedByLongLines = false;
506
		this._lineNumbersDigitCount = 1;
E
Erich Gamma 已提交
507
		this.editor = this._computeInternalOptions();
508
		this.editorClone = this.editor.clone();
509
		this._register(EditorZoom.onDidChangeZoomLevel(_ => this._recomputeOptions()));
510
		this._register(TabFocus.onDidChangeTabFocus(_ => this._recomputeOptions()));
E
Erich Gamma 已提交
511 512 513 514 515 516 517
	}

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

	protected _recomputeOptions(): void {
518 519
		this._setOptions(this._computeInternalOptions());
	}
520

J
Johannes Rieken 已提交
521
	private _setOptions(newOptions: editorCommon.InternalEditorOptions): void {
522 523
		if (this.editor && this.editor.equals(newOptions)) {
			return;
E
Erich Gamma 已提交
524 525
		}

526 527 528 529
		let changeEvent = this.editor.createChangeEvent(newOptions);
		this.editor = newOptions;
		this.editorClone = this.editor.clone();
		this._onDidChange.fire(changeEvent);
E
Erich Gamma 已提交
530 531
	}

A
Alex Dima 已提交
532
	public getRawOptions(): editorCommon.IEditorOptions {
E
Erich Gamma 已提交
533 534 535
		return this._configWithDefaults.getEditorOptions();
	}

536
	private _computeInternalOptions(): editorCommon.InternalEditorOptions {
E
Erich Gamma 已提交
537 538
		let opts = this._configWithDefaults.getEditorOptions();

539
		let editorClassName = this._getEditorClassName(opts.theme, toBoolean(opts.fontLigatures));
E
Erich Gamma 已提交
540

541 542 543 544 545 546
		let disableTranslate3d = toBoolean(opts.disableTranslate3d);
		let canUseTranslate3d = this._getCanUseTranslate3d();
		if (disableTranslate3d) {
			canUseTranslate3d = false;
		}

547
		let bareFontInfo = BareFontInfo.createFromRawSettings(opts, this.getZoomLevel());
548

549
		return InternalEditorOptionsHelper.createInternalEditorOptions(
E
Erich Gamma 已提交
550 551 552
			this.getOuterWidth(),
			this.getOuterHeight(),
			opts,
553
			this.readConfiguration(bareFontInfo),
554
			editorClassName,
E
Erich Gamma 已提交
555
			this._isDominatedByLongLines,
556
			this._lineNumbersDigitCount,
557 558
			canUseTranslate3d,
			this._getPixelRatio()
E
Erich Gamma 已提交
559 560 561
		);
	}

J
Johannes Rieken 已提交
562
	public updateOptions(newOptions: editorCommon.IEditorOptions): void {
E
Erich Gamma 已提交
563 564 565 566
		this._configWithDefaults.updateOptions(newOptions);
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
567
	public setIsDominatedByLongLines(isDominatedByLongLines: boolean): void {
E
Erich Gamma 已提交
568 569 570 571
		this._isDominatedByLongLines = isDominatedByLongLines;
		this._recomputeOptions();
	}

J
Johannes Rieken 已提交
572
	public setMaxLineNumber(maxLineNumber: number): void {
573 574
		let digitCount = CommonEditorConfiguration.digitCount(maxLineNumber);
		if (this._lineNumbersDigitCount === digitCount) {
A
Alex Dima 已提交
575 576
			return;
		}
577
		this._lineNumbersDigitCount = digitCount;
E
Erich Gamma 已提交
578 579 580
		this._recomputeOptions();
	}

581 582 583 584 585 586 587 588 589
	private static digitCount(n: number): number {
		var r = 0;
		while (n) {
			n = Math.floor(n / 10);
			r++;
		}
		return r ? r : 1;
	}

J
Johannes Rieken 已提交
590
	protected abstract _getEditorClassName(theme: string, fontLigatures: boolean): string;
E
Erich Gamma 已提交
591

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

594
	protected abstract getOuterHeight(): number;
E
Erich Gamma 已提交
595

596 597
	protected abstract _getCanUseTranslate3d(): boolean;

598 599
	protected abstract _getPixelRatio(): number;

600
	protected abstract readConfiguration(styling: BareFontInfo): FontInfo;
601 602

	protected abstract getZoomLevel(): number;
E
Erich Gamma 已提交
603 604
}

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

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.")
	};
}

934
configurationRegistry.registerConfiguration(editorConfiguration);