commonEditorConfig.ts 25.2 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 8
import * as nls from 'vs/nls';
import Event, {Emitter} from 'vs/base/common/event';
A
Alex Dima 已提交
9 10
import {Disposable} from 'vs/base/common/lifecycle';
import * as objects from 'vs/base/common/objects';
A
Alex Dima 已提交
11 12
import * as platform from 'vs/base/common/platform';
import {Extensions, IConfigurationRegistry, IConfigurationNode} from 'vs/platform/configuration/common/configurationRegistry';
E
Erich Gamma 已提交
13
import {Registry} from 'vs/platform/platform';
14
import {DefaultConfig, DEFAULT_INDENTATION, DEFAULT_TRIM_AUTO_WHITESPACE, GOLDEN_LINE_HEIGHT_RATIO} 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';
A
Alex Dima 已提交
17
import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
E
Erich Gamma 已提交
18

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/**
 * 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;
	}

	public static setValue(value:boolean): void {
		if (this._value === value) {
			return;
		}
		this._value = value;
		this._onChange.fire(this._value);
	}
}

E
Erich Gamma 已提交
41 42
export class ConfigurationWithDefaults {

A
Alex Dima 已提交
43
	private _editor:editorCommon.IEditorOptions;
E
Erich Gamma 已提交
44

A
Alex Dima 已提交
45 46
	constructor(options:editorCommon.IEditorOptions) {
		this._editor = <editorCommon.IEditorOptions>objects.clone(DefaultConfig.editor);
E
Erich Gamma 已提交
47 48 49 50

		this._mergeOptionsIn(options);
	}

A
Alex Dima 已提交
51
	public getEditorOptions(): editorCommon.IEditorOptions {
E
Erich Gamma 已提交
52 53 54
		return this._editor;
	}

A
Alex Dima 已提交
55 56
	private _mergeOptionsIn(newOptions:editorCommon.IEditorOptions): void {
		this._editor = objects.mixin(this._editor, newOptions || {});
E
Erich Gamma 已提交
57 58
	}

A
Alex Dima 已提交
59
	public updateOptions(newOptions:editorCommon.IEditorOptions): void {
E
Erich Gamma 已提交
60 61 62 63 64 65 66 67 68 69 70
		// Apply new options
		this._mergeOptionsIn(newOptions);
	}
}

class InternalEditorOptionsHelper {

	constructor() {
	}

	public static createInternalEditorOptions(
71
		outerWidth:number, outerHeight:number,
A
Alex Dima 已提交
72
		opts:editorCommon.IEditorOptions,
73 74
		fontInfo: editorCommon.FontInfo,
		editorClassName:string,
E
Erich Gamma 已提交
75
		isDominatedByLongLines:boolean,
76 77
		lineCount: number,
		canUseTranslate3d: boolean
78
	): editorCommon.InternalEditorOptions {
E
Erich Gamma 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

		let wrappingColumn = toInteger(opts.wrappingColumn, -1);

		let stopRenderingLineAfter:number;
		if (typeof opts.stopRenderingLineAfter !== 'undefined') {
			stopRenderingLineAfter = toInteger(opts.stopRenderingLineAfter, -1);
		} else if (wrappingColumn >= 0) {
			stopRenderingLineAfter = -1;
		} else {
			stopRenderingLineAfter = 10000;
		}

		let mouseWheelScrollSensitivity = toFloat(opts.mouseWheelScrollSensitivity, 1);
		let scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, mouseWheelScrollSensitivity);

		let glyphMargin = toBoolean(opts.glyphMargin);
		let lineNumbers = opts.lineNumbers;
		let lineNumbersMinChars = toInteger(opts.lineNumbersMinChars, 1);
		let lineDecorationsWidth = toInteger(opts.lineDecorationsWidth, 0);
M
Martin Aeschlimann 已提交
98
		if (opts.folding) {
99
			lineDecorationsWidth += 16;
M
Martin Aeschlimann 已提交
100
		}
E
Erich Gamma 已提交
101 102 103 104
		let layoutInfo = EditorLayoutProvider.compute({
			outerWidth: outerWidth,
			outerHeight: outerHeight,
			showGlyphMargin: glyphMargin,
105
			lineHeight: fontInfo.lineHeight,
E
Erich Gamma 已提交
106 107 108
			showLineNumbers: !!lineNumbers,
			lineNumbersMinChars: lineNumbersMinChars,
			lineDecorationsWidth: lineDecorationsWidth,
109
			maxDigitWidth: fontInfo.maxDigitWidth,
E
Erich Gamma 已提交
110 111 112 113 114 115 116 117 118 119 120 121
			lineCount: lineCount,
			verticalScrollbarWidth: scrollbar.verticalScrollbarSize,
			horizontalScrollbarHeight: scrollbar.horizontalScrollbarSize,
			scrollbarArrowSize: scrollbar.arrowSize,
			verticalScrollbarHasArrows: scrollbar.verticalHasArrows
		});

		if (isDominatedByLongLines && wrappingColumn > 0) {
			// Force viewport width wrapping if model is dominated by long lines
			wrappingColumn = 0;
		}

122
		let bareWrappingInfo: { isViewportWrapping: boolean; wrappingColumn: number; };
E
Erich Gamma 已提交
123 124
		if (wrappingColumn === 0) {
			// If viewport width wrapping is enabled
125
			bareWrappingInfo = {
E
Erich Gamma 已提交
126
				isViewportWrapping: true,
127
				wrappingColumn: Math.max(1, Math.floor((layoutInfo.contentWidth - layoutInfo.verticalScrollbarWidth) / fontInfo.typicalHalfwidthCharacterWidth))
E
Erich Gamma 已提交
128 129 130
			};
		} else if (wrappingColumn > 0) {
			// Wrapping is enabled
131
			bareWrappingInfo = {
E
Erich Gamma 已提交
132 133 134 135
				isViewportWrapping: false,
				wrappingColumn: wrappingColumn
			};
		} else {
136
			bareWrappingInfo = {
E
Erich Gamma 已提交
137 138 139 140
				isViewportWrapping: false,
				wrappingColumn: -1
			};
		}
141 142 143 144 145 146 147 148
		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 已提交
149

150 151 152 153 154 155 156
		let readOnly = toBoolean(opts.readOnly);

		let tabFocusMode = toBoolean(opts.tabFocusMode);
		if (readOnly) {
			tabFocusMode = true;
		}

157
		let viewInfo = new editorCommon.InternalEditorViewOptions({
158
			theme: opts.theme,
159
			canUseTranslate3d: canUseTranslate3d,
160 161 162
			experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
			rulers: toSortedIntegerArray(opts.rulers),
			ariaLabel: String(opts.ariaLabel),
E
Erich Gamma 已提交
163 164 165 166 167 168
			lineNumbers: lineNumbers,
			selectOnLineNumbers: toBoolean(opts.selectOnLineNumbers),
			glyphMargin: glyphMargin,
			revealHorizontalRightPadding: toInteger(opts.revealHorizontalRightPadding, 0),
			roundedSelection: toBoolean(opts.roundedSelection),
			overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
169
			cursorBlinking: opts.cursorBlinking,
A
Alex Dima 已提交
170
			cursorStyle: cursorStyleFromString(opts.cursorStyle),
E
Erich Gamma 已提交
171 172
			hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
			scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine),
173 174 175 176 177 178 179
			editorClassName: editorClassName,
			stopRenderingLineAfter: stopRenderingLineAfter,
			renderWhitespace: toBoolean(opts.renderWhitespace),
			indentGuides: toBoolean(opts.indentGuides),
			scrollbar: scrollbar,
		});

A
Alex Dima 已提交
180
		let contribInfo = new editorCommon.EditorContribOptions({
181
			selectionClipboard: toBoolean(opts.selectionClipboard),
E
Erich Gamma 已提交
182 183 184 185 186 187 188
			hover: toBoolean(opts.hover),
			contextmenu: toBoolean(opts.contextmenu),
			quickSuggestions: toBoolean(opts.quickSuggestions),
			quickSuggestionsDelay: toInteger(opts.quickSuggestionsDelay),
			iconsInSuggestions: toBoolean(opts.iconsInSuggestions),
			formatOnType: toBoolean(opts.formatOnType),
			suggestOnTriggerCharacters: toBoolean(opts.suggestOnTriggerCharacters),
189
			acceptSuggestionOnEnter: toBoolean(opts.acceptSuggestionOnEnter),
E
Erich Gamma 已提交
190 191 192
			selectionHighlight: toBoolean(opts.selectionHighlight),
			outlineMarkers: toBoolean(opts.outlineMarkers),
			referenceInfos: toBoolean(opts.referenceInfos),
M
Martin Aeschlimann 已提交
193
			folding: toBoolean(opts.folding),
A
Alex Dima 已提交
194 195
		});

196 197 198 199
		return new editorCommon.InternalEditorOptions({
			lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
			readOnly: readOnly,
			wordSeparators: String(opts.wordSeparators),
A
Alex Dima 已提交
200
			autoClosingBrackets: toBoolean(opts.autoClosingBrackets),
201
			useTabStops: toBoolean(opts.useTabStops),
202
			tabFocusMode: tabFocusMode,
E
Erich Gamma 已提交
203
			layoutInfo: layoutInfo,
204
			fontInfo: fontInfo,
205
			viewInfo: viewInfo,
E
Erich Gamma 已提交
206
			wrappingInfo: wrappingInfo,
A
Alex Dima 已提交
207
			contribInfo: contribInfo,
208
		});
E
Erich Gamma 已提交
209 210
	}

A
Alex Dima 已提交
211 212 213 214 215 216 217 218 219 220 221 222 223
	private static _sanitizeScrollbarOpts(raw:editorCommon.IEditorScrollbarOptions, mouseWheelScrollSensitivity:number): editorCommon.InternalEditorScrollbarOptions {

		var visibilityFromString = (visibility: string) => {
			switch (visibility) {
				case 'hidden':
					return ScrollbarVisibility.Hidden;
				case 'visible':
					return ScrollbarVisibility.Visible;
				default:
					return ScrollbarVisibility.Auto;
			}
		};

A
Alex Dima 已提交
224 225
		let horizontalScrollbarSize = toIntegerWithDefault(raw.horizontalScrollbarSize, 10);
		let verticalScrollbarSize = toIntegerWithDefault(raw.verticalScrollbarSize, 14);
A
Alex Dima 已提交
226 227 228
		return new editorCommon.InternalEditorScrollbarOptions({
			vertical: visibilityFromString(raw.vertical),
			horizontal: visibilityFromString(raw.horizontal),
E
Erich Gamma 已提交
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243

			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 已提交
244
		});
E
Erich Gamma 已提交
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
	}
}

function toBoolean(value:any): boolean {
	return value === 'false' ? false : Boolean(value);
}

function toBooleanWithDefault(value:any, defaultValue:boolean): boolean {
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	return toBoolean(value);
}

function toFloat(source: any, defaultValue: number): number {
A
Alex Dima 已提交
260
	let r = parseFloat(source);
E
Erich Gamma 已提交
261 262 263 264 265 266 267
	if (isNaN(r)) {
		r = defaultValue;
	}
	return r;
}

function toInteger(source:any, minimum?:number, maximum?:number): number {
A
Alex Dima 已提交
268
	let r = parseInt(source, 10);
E
Erich Gamma 已提交
269 270 271 272 273 274 275 276 277 278 279 280
	if (isNaN(r)) {
		r = 0;
	}
	if (typeof minimum === 'number') {
		r = Math.max(minimum, r);
	}
	if (typeof maximum === 'number') {
		r = Math.min(maximum, r);
	}
	return r;
}

281 282 283 284 285 286 287 288 289 290
function toSortedIntegerArray(source:any): number[] {
	if (!Array.isArray(source)) {
		return [];
	}
	let arrSource = <any[]>source;
	let r = arrSource.map(el => toInteger(el));
	r.sort();
	return r;
}

A
Alex Dima 已提交
291 292 293 294 295 296 297 298 299 300
function wrappingIndentFromString(wrappingIndent:string): editorCommon.WrappingIndent {
	if (wrappingIndent === 'indent') {
		return editorCommon.WrappingIndent.Indent;
	} else if (wrappingIndent === 'same') {
		return editorCommon.WrappingIndent.Same;
	} else {
		return editorCommon.WrappingIndent.None;
	}
}

A
Alex Dima 已提交
301 302 303 304 305 306 307 308 309 310 311
function cursorStyleFromString(cursorStyle:string): editorCommon.TextEditorCursorStyle {
	if (cursorStyle === 'line') {
		return editorCommon.TextEditorCursorStyle.Line;
	} else if (cursorStyle === 'block') {
		return editorCommon.TextEditorCursorStyle.Block;
	} else if (cursorStyle === 'underline') {
		return editorCommon.TextEditorCursorStyle.Underline;
	}
	return editorCommon.TextEditorCursorStyle.Line;
}

E
Erich Gamma 已提交
312 313 314 315 316 317 318 319 320 321 322 323 324 325
function toIntegerWithDefault(source:any, defaultValue:number): number {
	if (typeof source === 'undefined') {
		return defaultValue;
	}
	return toInteger(source);
}

interface IValidatedIndentationOptions {
	tabSizeIsAuto: boolean;
	tabSize: number;
	insertSpacesIsAuto: boolean;
	insertSpaces: boolean;
}

326 327 328 329 330 331 332 333
export interface IElementSizeObserver {
	startObserving(): void;
	observe(dimension?:editorCommon.IDimension): void;
	dispose(): void;
	getWidth(): number;
	getHeight(): number;
}

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

336 337
	public editor:editorCommon.InternalEditorOptions;
	public editorClone:editorCommon.InternalEditorOptions;
E
Erich Gamma 已提交
338 339

	protected _configWithDefaults:ConfigurationWithDefaults;
340
	protected _elementSizeObserver: IElementSizeObserver;
E
Erich Gamma 已提交
341 342 343
	private _isDominatedByLongLines:boolean;
	private _lineCount:number;

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

347
	constructor(options:editorCommon.IEditorOptions, elementSizeObserver: IElementSizeObserver = null) {
A
Alex Dima 已提交
348
		super();
E
Erich Gamma 已提交
349
		this._configWithDefaults = new ConfigurationWithDefaults(options);
350
		this._elementSizeObserver = elementSizeObserver;
E
Erich Gamma 已提交
351 352 353
		this._isDominatedByLongLines = false;
		this._lineCount = 1;
		this.editor = this._computeInternalOptions();
354
		this.editorClone = this.editor.clone();
E
Erich Gamma 已提交
355 356 357 358 359 360 361
	}

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

	protected _recomputeOptions(): void {
362 363
		this._setOptions(this._computeInternalOptions());
	}
364

365 366 367
	private _setOptions(newOptions:editorCommon.InternalEditorOptions): void {
		if (this.editor && this.editor.equals(newOptions)) {
			return;
E
Erich Gamma 已提交
368 369
		}

370 371 372 373
		let changeEvent = this.editor.createChangeEvent(newOptions);
		this.editor = newOptions;
		this.editorClone = this.editor.clone();
		this._onDidChange.fire(changeEvent);
E
Erich Gamma 已提交
374 375
	}

A
Alex Dima 已提交
376
	public getRawOptions(): editorCommon.IEditorOptions {
E
Erich Gamma 已提交
377 378 379
		return this._configWithDefaults.getEditorOptions();
	}

380
	private _computeInternalOptions(): editorCommon.InternalEditorOptions {
E
Erich Gamma 已提交
381 382
		let opts = this._configWithDefaults.getEditorOptions();

383
		let editorClassName = this._getEditorClassName(opts.theme, toBoolean(opts.fontLigatures));
384 385
		let fontFamily = String(opts.fontFamily) || DefaultConfig.editor.fontFamily;
		let fontSize = toInteger(opts.fontSize, 0, 100) || DefaultConfig.editor.fontSize;
E
Erich Gamma 已提交
386

387 388
		let lineHeight = toInteger(opts.lineHeight, 0, 150);
		if (lineHeight === 0) {
389
			lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
E
Erich Gamma 已提交
390 391
		}

392
		return InternalEditorOptionsHelper.createInternalEditorOptions(
E
Erich Gamma 已提交
393 394 395
			this.getOuterWidth(),
			this.getOuterHeight(),
			opts,
A
Alex Dima 已提交
396 397 398 399 400
			this.readConfiguration(new editorCommon.BareFontInfo({
				fontFamily: fontFamily,
				fontSize: fontSize,
				lineHeight: lineHeight
			})),
401
			editorClassName,
E
Erich Gamma 已提交
402
			this._isDominatedByLongLines,
403 404
			this._lineCount,
			this._getCanUseTranslate3d()
E
Erich Gamma 已提交
405 406 407
		);
	}

A
Alex Dima 已提交
408
	public updateOptions(newOptions:editorCommon.IEditorOptions): void {
E
Erich Gamma 已提交
409 410 411 412 413 414 415 416 417 418 419 420 421 422
		this._configWithDefaults.updateOptions(newOptions);
		this._recomputeOptions();
	}

	public setIsDominatedByLongLines(isDominatedByLongLines:boolean): void {
		this._isDominatedByLongLines = isDominatedByLongLines;
		this._recomputeOptions();
	}

	public setLineCount(lineCount:number): void {
		this._lineCount = lineCount;
		this._recomputeOptions();
	}

423
	protected abstract _getEditorClassName(theme:string, fontLigatures:boolean): string;
E
Erich Gamma 已提交
424

425
	protected abstract getOuterWidth(): number;
E
Erich Gamma 已提交
426

427
	protected abstract getOuterHeight(): number;
E
Erich Gamma 已提交
428

429 430
	protected abstract _getCanUseTranslate3d(): boolean;

431
	protected abstract readConfiguration(styling: editorCommon.BareFontInfo): editorCommon.FontInfo;
E
Erich Gamma 已提交
432 433 434 435 436 437 438 439 440 441 442 443
}

/**
 * Helper to update Monaco Editor Settings from configurations service.
 */
export class EditorConfiguration {
	public static EDITOR_SECTION = 'editor';
	public static DIFF_EDITOR_SECTION = 'diffEditor';

	/**
	 * Ask the provided configuration service to apply its configuration to the provided editor.
	 */
A
Alex Dima 已提交
444 445
	public static apply(config:any, editor?:editorCommon.IEditor): void;
	public static apply(config:any, editor?:editorCommon.IEditor[]): void;
E
Erich Gamma 已提交
446 447 448 449 450
	public static apply(config:any, editorOrArray?:any): void {
		if (!config) {
			return;
		}

A
Alex Dima 已提交
451
		let editors:editorCommon.IEditor[] = editorOrArray;
E
Erich Gamma 已提交
452 453 454 455
		if (!Array.isArray(editorOrArray)) {
			editors = [editorOrArray];
		}

A
Alex Dima 已提交
456 457
		for (let i = 0; i < editors.length; i++) {
			let editor = editors[i];
E
Erich Gamma 已提交
458 459 460

			// Editor Settings (Code Editor, Diff, Terminal)
			if (editor && typeof editor.updateOptions === 'function') {
A
Alex Dima 已提交
461
				let type = editor.getEditorType();
A
Alex Dima 已提交
462
				if (type !== editorCommon.EditorType.ICodeEditor && type !== editorCommon.EditorType.IDiffEditor) {
E
Erich Gamma 已提交
463 464 465
					continue;
				}

A
Alex Dima 已提交
466
				let editorConfig = config[EditorConfiguration.EDITOR_SECTION];
A
Alex Dima 已提交
467
				if (type === editorCommon.EditorType.IDiffEditor) {
A
Alex Dima 已提交
468
					let diffEditorConfig = config[EditorConfiguration.DIFF_EDITOR_SECTION];
E
Erich Gamma 已提交
469 470 471 472
					if (diffEditorConfig) {
						if (!editorConfig) {
							editorConfig = diffEditorConfig;
						} else {
A
Alex Dima 已提交
473
							editorConfig = objects.mixin(editorConfig, diffEditorConfig);
E
Erich Gamma 已提交
474 475 476 477 478 479 480 481 482 483 484 485 486
						}
					}
				}

				if (editorConfig) {
					delete editorConfig.readOnly; // Prevent someone from making editor readonly
					editor.updateOptions(editorConfig);
				}
			}
		}
	}
}

A
Alex Dima 已提交
487
let configurationRegistry = <IConfigurationRegistry>Registry.as(Extensions.Configuration);
A
Alex Dima 已提交
488
let editorConfiguration:IConfigurationNode = {
E
Erich Gamma 已提交
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
	'id': 'editor',
	'order': 5,
	'type': 'object',
	'title': nls.localize('editorConfigurationTitle', "Editor configuration"),
	'properties' : {
		'editor.fontFamily' : {
			'type': 'string',
			'default': DefaultConfig.editor.fontFamily,
			'description': nls.localize('fontFamily', "Controls the font family.")
		},
		'editor.fontSize' : {
			'type': 'number',
			'default': DefaultConfig.editor.fontSize,
			'description': nls.localize('fontSize', "Controls the font size.")
		},
		'editor.lineHeight' : {
			'type': 'number',
			'default': DefaultConfig.editor.lineHeight,
			'description': nls.localize('lineHeight', "Controls the line height.")
		},
		'editor.lineNumbers' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.lineNumbers,
			'description': nls.localize('lineNumbers', "Controls visibility of line numbers")
		},
		'editor.glyphMargin' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.glyphMargin,
			'description': nls.localize('glyphMargin', "Controls visibility of the glyph margin")
		},
519 520 521 522 523 524 525 526
		'editor.rulers' : {
			'type': 'array',
			'items': {
				'type': 'number'
			},
			'default': DefaultConfig.editor.rulers,
			'description': nls.localize('rulers', "Columns at which to show vertical rulers")
		},
A
Alex Dima 已提交
527 528 529 530 531
		'editor.wordSeparators' : {
			'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")
		},
E
Erich Gamma 已提交
532
		'editor.tabSize' : {
533 534
			'type': 'number',
			'default': DEFAULT_INDENTATION.tabSize,
E
Erich Gamma 已提交
535
			'minimum': 1,
536 537
			'description': nls.localize('tabSize', "The number of spaces a tab is equal to."),
			'errorMessage': nls.localize('tabSize.errorMessage', "Expected 'number'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
538 539
		},
		'editor.insertSpaces' : {
540 541
			'type': 'boolean',
			'default': DEFAULT_INDENTATION.insertSpaces,
542 543
			'description': nls.localize('insertSpaces', "Insert spaces when pressing Tab."),
			'errorMessage': nls.localize('insertSpaces.errorMessage', "Expected 'boolean'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
E
Erich Gamma 已提交
544
		},
545 546 547
		'editor.detectIndentation' : {
			'type': 'boolean',
			'default': DEFAULT_INDENTATION.detectIndentation,
A
Alex Dima 已提交
548
			'description': nls.localize('detectIndentation', "When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.")
549
		},
E
Erich Gamma 已提交
550 551 552 553 554 555 556 557 558 559 560 561 562 563
		'editor.roundedSelection' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.roundedSelection,
			'description': nls.localize('roundedSelection', "Controls if selections have rounded corners")
		},
		'editor.scrollBeyondLastLine' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.scrollBeyondLastLine,
			'description': nls.localize('scrollBeyondLastLine', "Controls if the editor will scroll beyond the last line")
		},
		'editor.wrappingColumn' : {
			'type': 'integer',
			'default': DefaultConfig.editor.wrappingColumn,
			'minimum': -1,
564
			'description': nls.localize('wrappingColumn', "Controls after how many characters the editor will wrap to the next line. Setting this to 0 turns on viewport width wrapping (word wrapping). Setting this to -1 forces the editor to never wrap.")
E
Erich Gamma 已提交
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
		},
		'editor.wrappingIndent' : {
			'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'.")
		},
		'editor.mouseWheelScrollSensitivity' : {
			'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")
		},
		'editor.quickSuggestions' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.quickSuggestions,
			'description': nls.localize('quickSuggestions', "Controls if quick suggestions should show up or not while typing")
		},
		'editor.quickSuggestionsDelay' : {
			'type': 'integer',
			'default': DefaultConfig.editor.quickSuggestionsDelay,
			'minimum': 0,
			'description': nls.localize('quickSuggestionsDelay', "Controls the delay in ms after which quick suggestions will show up")
		},
		'editor.autoClosingBrackets' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.autoClosingBrackets,
			'description': nls.localize('autoClosingBrackets', "Controls if the editor should automatically close brackets after opening them")
		},
		'editor.formatOnType' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.formatOnType,
			'description': nls.localize('formatOnType', "Controls if the editor should automatically format the line after typing")
		},
		'editor.suggestOnTriggerCharacters' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.suggestOnTriggerCharacters,
			'description': nls.localize('suggestOnTriggerCharacters', "Controls if suggestions should automatically show up when typing trigger characters")
		},
603 604 605 606 607
		'editor.acceptSuggestionOnEnter' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.acceptSuggestionOnEnter,
			'description': nls.localize('acceptSuggestionOnEnter', "Controls if suggestions should be accepted 'Enter' - in addition to 'Tab'. Helps to avoid ambiguity between inserting new lines or accepting suggestions.")
		},
E
Erich Gamma 已提交
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
		'editor.selectionHighlight' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.selectionHighlight,
			'description': nls.localize('selectionHighlight', "Controls whether the editor should highlight similar matches to the selection")
		},
//		'editor.outlineMarkers' : {
//			'type': 'boolean',
//			'default': DefaultConfig.editor.outlineMarkers,
//			'description': nls.localize('outlineMarkers', "Controls whether the editor should draw horizontal lines before classes and methods")
//		},
		'editor.overviewRulerLanes' : {
			'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")
		},
623 624 625 626
		'editor.cursorBlinking' : {
			'type': 'string',
			'enum': ['blink', 'visible', 'hidden'],
			'default': DefaultConfig.editor.cursorBlinking,
C
Chris Dias 已提交
627
			'description': nls.localize('cursorBlinking', "Controls the cursor blinking animation, accepted values are 'blink', 'visible', and 'hidden'")
628
		},
M
markrendle 已提交
629 630 631 632 633 634
		'editor.cursorStyle' : {
			'type': 'string',
			'enum': ['block', 'line'],
			'default': DefaultConfig.editor.cursorStyle,
			'description': nls.localize('cursorStyle', "Controls the cursor style, accepted values are 'block' and 'line'")
		},
635 636 637 638 639
		'editor.fontLigatures' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.fontLigatures,
			'description': nls.localize('fontLigatures', "Enables font ligatures")
		},
E
Erich Gamma 已提交
640 641 642 643 644 645 646 647 648 649
		'editor.hideCursorInOverviewRuler' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.hideCursorInOverviewRuler,
			'description': nls.localize('hideCursorInOverviewRuler', "Controls if the cursor should be hidden in the overview ruler.")
		},
		'editor.renderWhitespace': {
			'type': 'boolean',
			default: DefaultConfig.editor.renderWhitespace,
			description: nls.localize('renderWhitespace', "Controls whether the editor should render whitespace characters")
		},
650 651 652 653 654
		// 'editor.indentGuides': {
		// 	'type': 'boolean',
		// 	default: DefaultConfig.editor.indentGuides,
		// 	description: nls.localize('indentGuides', "Controls whether the editor should render indent guides")
		// },
E
Erich Gamma 已提交
655 656 657 658 659
		'editor.referenceInfos' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.referenceInfos,
			'description': nls.localize('referenceInfos', "Controls if the editor shows reference information for the modes that support it")
		},
M
Martin Aeschlimann 已提交
660 661 662
		'editor.folding' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.folding,
663
			'description': nls.localize('folding', "Controls whether the editor has code folding enabled")
M
Martin Aeschlimann 已提交
664
		},
665 666 667 668 669 670 671
		'editor.useTabStops' : {
			'type': 'boolean',
			'default': DefaultConfig.editor.useTabStops,
			'description': nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops")
		},
		'editor.trimAutoWhitespace' : {
			'type': 'boolean',
672
			'default': DEFAULT_TRIM_AUTO_WHITESPACE,
673 674
			'description': nls.localize('trimAutoWhitespace', "Remove trailing auto inserted whitespace")
		},
675
		'editor.stablePeek' : {
676
			'type': 'boolean',
677
			'default': false,
678
			'description': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting Escape.")
679
		},
E
Erich Gamma 已提交
680 681 682 683 684 685 686 687 688 689 690
		'diffEditor.renderSideBySide' : {
			'type': 'boolean',
			'default': true,
			'description': nls.localize('sideBySide', "Controls if the diff editor shows the diff side by side or inline")
		},
		'diffEditor.ignoreTrimWhitespace' : {
			'type': 'boolean',
			'default': true,
			'description': nls.localize('ignoreTrimWhitespace', "Controls if the diff editor shows changes in leading or trailing whitespace as diffs")
		}
	}
A
Alex Dima 已提交
691 692 693 694 695 696 697 698 699 700 701
};

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

configurationRegistry.registerConfiguration(editorConfiguration);