editorOptions.ts 79.9 KB
Newer Older
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6 7
import * as nls from 'vs/nls';
import * as platform from 'vs/base/common/platform';
8 9
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
10
import { Constants } from 'vs/editor/common/core/uint';
11
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
12
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
13
import { isObject } from 'vs/base/common/types';
14 15 16 17 18 19 20 21 22 23 24 25 26 27

/**
 * Configuration options for editor scrollbars
 */
export interface IEditorScrollbarOptions {
	/**
	 * The size of arrows (if displayed).
	 * Defaults to 11.
	 */
	arrowSize?: number;
	/**
	 * Render vertical scrollbar.
	 * Defaults to 'auto'.
	 */
A
Alex Dima 已提交
28
	vertical?: 'auto' | 'visible' | 'hidden';
29 30 31 32
	/**
	 * Render horizontal scrollbar.
	 * Defaults to 'auto'.
	 */
A
Alex Dima 已提交
33
	horizontal?: 'auto' | 'visible' | 'hidden';
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
	/**
	 * Cast horizontal and vertical shadows when the content is scrolled.
	 * Defaults to true.
	 */
	useShadows?: boolean;
	/**
	 * Render arrows at the top and bottom of the vertical scrollbar.
	 * Defaults to false.
	 */
	verticalHasArrows?: boolean;
	/**
	 * Render arrows at the left and right of the horizontal scrollbar.
	 * Defaults to false.
	 */
	horizontalHasArrows?: boolean;
	/**
	 * Listen to mouse wheel events and react to them by scrolling.
	 * Defaults to true.
	 */
	handleMouseWheel?: boolean;
	/**
	 * Height in pixels for the horizontal scrollbar.
	 * Defaults to 10 (px).
	 */
	horizontalScrollbarSize?: number;
	/**
	 * Width in pixels for the vertical scrollbar.
	 * Defaults to 10 (px).
	 */
	verticalScrollbarSize?: number;
	/**
	 * Width in pixels for the vertical slider.
	 * Defaults to `verticalScrollbarSize`.
	 */
	verticalSliderSize?: number;
	/**
	 * Height in pixels for the horizontal slider.
	 * Defaults to `horizontalScrollbarSize`.
	 */
	horizontalSliderSize?: number;
}

76 77 78 79
/**
 * Configuration options for editor find widget
 */
export interface IEditorFindOptions {
R
rebornix 已提交
80 81 82
	/**
	 * Controls if we seed search string in the Find Widget with editor selection.
	 */
83
	seedSearchStringFromSelection?: boolean;
R
rebornix 已提交
84 85 86 87
	/**
	 * Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor.
	 */
	autoFindInSelection: boolean;
88 89 90 91
	/*
	 * Controls whether the Find Widget should add extra lines on top of the editor.
	 */
	addExtraSpaceOnTop?: boolean;
92 93 94 95 96
	/**
	 * @internal
	 * Controls if the Find Widget should read or modify the shared find clipboard on macOS
	 */
	globalFindClipboard: boolean;
97 98
}

J
Jackson Kearl 已提交
99
/**
J
Jackson Kearl 已提交
100
 * Configuration options for auto closing quotes and brackets
J
Jackson Kearl 已提交
101
 */
J
Jackson Kearl 已提交
102 103 104 105 106
export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';

/**
 * Configuration options for auto wrapping quotes and brackets
 */
107
export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never';
J
Jackson Kearl 已提交
108

109 110 111 112 113
/**
 * Configuration options for typing over closing quotes or brackets
 */
export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never';

114 115 116 117 118 119
/**
 * Configuration options for editor minimap
 */
export interface IEditorMinimapOptions {
	/**
	 * Enable the rendering of the minimap.
120
	 * Defaults to true.
121 122
	 */
	enabled?: boolean;
123 124 125 126 127
	/**
	 * Control the side of the minimap in editor.
	 * Defaults to 'right'.
	 */
	side?: 'right' | 'left';
128 129 130 131 132
	/**
	 * Control the rendering of the minimap slider.
	 * Defaults to 'mouseover'.
	 */
	showSlider?: 'always' | 'mouseover';
133 134 135 136 137 138 139 140 141 142 143 144
	/**
	 * Render the actual text on a line (as opposed to color blocks).
	 * Defaults to true.
	 */
	renderCharacters?: boolean;
	/**
	 * Limit the width of the minimap to render at most a certain number of columns.
	 * Defaults to 120.
	 */
	maxColumn?: number;
}

145 146 147 148 149 150 151 152 153 154 155
/**
 * Configuration options for editor minimap
 */
export interface IEditorLightbulbOptions {
	/**
	 * Enable the lightbulb code action.
	 * Defaults to true.
	 */
	enabled?: boolean;
}

A
Alex Dima 已提交
156 157 158 159 160 161 162 163 164
/**
 * Configuration options for editor hover
 */
export interface IEditorHoverOptions {
	/**
	 * Enable the hover.
	 * Defaults to true.
	 */
	enabled?: boolean;
165 166 167 168 169
	/**
	 * Delay for showing the hover.
	 * Defaults to 300.
	 */
	delay?: number;
170 171 172 173 174
	/**
	 * Is the hover sticky such that it can be clicked and its contents selected?
	 * Defaults to true.
	 */
	sticky?: boolean;
A
Alex Dima 已提交
175 176
}

177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
/**
 * Configuration options for parameter hints
 */
export interface IEditorParameterHintOptions {
	/**
	 * Enable parameter hints.
	 * Defaults to true.
	 */
	enabled?: boolean;
	/**
	 * Enable cycling of parameter hints.
	 * Defaults to false.
	 */
	cycle?: boolean;
}

193 194 195 196 197
export interface ISuggestOptions {
	/**
	 * Enable graceful matching. Defaults to true.
	 */
	filterGraceful?: boolean;
198 199 200 201
	/**
	 * Prevent quick suggestions when a snippet is active. Defaults to true.
	 */
	snippetsPreventQuickSuggestions?: boolean;
J
Johannes Rieken 已提交
202 203 204 205
	/**
	 * Favours words that appear close to the cursor.
	 */
	localityBonus?: boolean;
206 207 208
	/**
	 * Enable using global storage for remembering suggestions.
	 */
209
	shareSuggestSelections?: boolean;
210 211 212 213 214 215 216
	/**
	 * Enable or disable icons in suggestions. Defaults to true.
	 */
	showIcons?: boolean;
	/**
	 * Max suggestions to show in suggestions. Defaults to 12.
	 */
A
Alex Dima 已提交
217
	maxVisibleSuggestions?: number;
218 219 220 221
	/**
	 * Names of suggestion types to filter.
	 */
	filteredTypes?: Record<string, boolean>;
222 223
}

224 225 226 227
export interface IGotoLocationOptions {
	/**
	 * Control how goto-command work when having multiple results.
	 */
J
Johannes Rieken 已提交
228
	multiple?: 'peek' | 'gotoAndPeek' | 'goto';
229 230
}

A
Alex Dima 已提交
231 232 233 234
export interface IQuickSuggestionsOptions {
	other: boolean;
	comments: boolean;
	strings: boolean;
235 236
}

237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
/**
 * Configuration options for the editor.
 */
export interface IEditorOptions {
	/**
	 * This editor is used inside a diff editor.
	 */
	inDiffEditor?: boolean;
	/**
	 * The aria label for the editor's textarea (when it is focused).
	 */
	ariaLabel?: string;
	/**
	 * Render vertical lines at the specified columns.
	 * Defaults to empty array.
	 */
	rulers?: number[];
	/**
	 * A string containing the word separators used when doing word navigation.
	 * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
	 */
	wordSeparators?: string;
	/**
	 * Enable Linux primary clipboard.
	 * Defaults to true.
	 */
	selectionClipboard?: boolean;
	/**
	 * Control the rendering of line numbers.
	 * If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
	 * Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function).
	 * Otherwise, line numbers will not be rendered.
	 * Defaults to true.
	 */
A
Alex Dima 已提交
271
	lineNumbers?: LineNumbersType;
P
Peng Lyu 已提交
272
	/**
273
	 * Controls the minimal number of visible leading and trailing lines surrounding the cursor.
P
Peng Lyu 已提交
274 275
	 * Defaults to 0.
	*/
276
	cursorSurroundingLines?: number;
A
Alex Dima 已提交
277 278
	/**
	 * Render last line number when the file ends with a newline.
A
Alex Dima 已提交
279
	 * Defaults to true.
280
	*/
A
Alex Dima 已提交
281
	renderFinalNewline?: boolean;
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
	/**
	 * Should the corresponding line be selected when clicking on the line number?
	 * Defaults to true.
	 */
	selectOnLineNumbers?: boolean;
	/**
	 * Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits.
	 * Defaults to 5.
	 */
	lineNumbersMinChars?: number;
	/**
	 * Enable the rendering of the glyph margin.
	 * Defaults to true in vscode and to false in monaco-editor.
	 */
	glyphMargin?: boolean;
	/**
	 * The width reserved for line decorations (in px).
	 * Line decorations are placed between line numbers and the editor content.
	 * You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch.
	 * Defaults to 10.
	 */
	lineDecorationsWidth?: number | string;
	/**
	 * When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle.
	 * This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport.
	 * Defaults to 30 (px).
	 */
	revealHorizontalRightPadding?: number;
	/**
	 * Render the editor selection with rounded borders.
	 * Defaults to true.
	 */
	roundedSelection?: boolean;
	/**
316
	 * Class name to be added to the editor.
317
	 */
318
	extraEditorClassName?: string;
319 320 321 322 323 324 325 326 327 328 329 330 331
	/**
	 * Should the editor be read only.
	 * Defaults to false.
	 */
	readOnly?: boolean;
	/**
	 * Control the behavior and rendering of the scrollbars.
	 */
	scrollbar?: IEditorScrollbarOptions;
	/**
	 * Control the behavior and rendering of the minimap.
	 */
	minimap?: IEditorMinimapOptions;
332 333 334 335
	/**
	 * Control the behavior of the find widget.
	 */
	find?: IEditorFindOptions;
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
	/**
	 * Display overflow widgets as `fixed`.
	 * Defaults to `false`.
	 */
	fixedOverflowWidgets?: boolean;
	/**
	 * The number of vertical lanes the overview ruler should render.
	 * Defaults to 2.
	 */
	overviewRulerLanes?: number;
	/**
	 * Controls if a border should be drawn around the overview ruler.
	 * Defaults to `true`.
	 */
	overviewRulerBorder?: boolean;
	/**
	 * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
	 * Defaults to 'blink'.
	 */
A
Alex Dima 已提交
355
	cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
356 357 358 359 360 361 362 363 364 365
	/**
	 * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
	 * Defaults to false.
	 */
	mouseWheelZoom?: boolean;
	/**
	 * Control the mouse pointer style, either 'text' or 'default' or 'copy'
	 * Defaults to 'text'
	 */
	mouseStyle?: 'text' | 'default' | 'copy';
366 367 368 369 370
	/**
	 * Enable smooth caret animation.
	 * Defaults to false.
	 */
	cursorSmoothCaretAnimation?: boolean;
371 372 373 374
	/**
	 * Control the cursor style, either 'block' or 'line'.
	 * Defaults to 'line'.
	 */
A
Alex Dima 已提交
375
	cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
376 377 378
	/**
	 * Control the width of the cursor when cursorStyle is set to 'line'
	 */
379
	cursorWidth?: number;
380 381 382 383 384 385
	/**
	 * Enable font ligatures.
	 * Defaults to false.
	 */
	fontLigatures?: boolean;
	/**
386 387
	 * Disable the use of `will-change` for the editor margin and lines layers.
	 * The usage of `will-change` acts as a hint for browsers to create an extra layer.
388 389
	 * Defaults to false.
	 */
390
	disableLayerHinting?: boolean;
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
	/**
	 * Disable the optimizations for monospace fonts.
	 * Defaults to false.
	 */
	disableMonospaceOptimizations?: boolean;
	/**
	 * Should the cursor be hidden in the overview ruler.
	 * Defaults to false.
	 */
	hideCursorInOverviewRuler?: boolean;
	/**
	 * Enable that scrolling can go one screen size after the last line.
	 * Defaults to true.
	 */
	scrollBeyondLastLine?: boolean;
406 407 408 409 410
	/**
	 * Enable that scrolling can go beyond the last column by a number of columns.
	 * Defaults to 5.
	 */
	scrollBeyondLastColumn?: number;
411 412
	/**
	 * Enable that the editor animates scrolling to a position.
413
	 * Defaults to false.
414 415
	 */
	smoothScrolling?: boolean;
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
	/**
	 * Enable that the editor will install an interval to check if its container dom node size has changed.
	 * Enabling this might have a severe performance impact.
	 * Defaults to false.
	 */
	automaticLayout?: boolean;
	/**
	 * Control the wrapping of the editor.
	 * When `wordWrap` = "off", the lines will never wrap.
	 * When `wordWrap` = "on", the lines will wrap at the viewport width.
	 * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
	 * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
	 * Defaults to "off".
	 */
	wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
	/**
	 * Control the wrapping of the editor.
	 * When `wordWrap` = "off", the lines will never wrap.
	 * When `wordWrap` = "on", the lines will wrap at the viewport width.
	 * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
	 * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
	 * Defaults to 80.
	 */
	wordWrapColumn?: number;
	/**
	 * Force word wrapping when the text appears to be of a minified/generated file.
	 * Defaults to true.
	 */
	wordWrapMinified?: boolean;
	/**
446
	 * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
447 448
	 * Defaults to 'same' in vscode and to 'none' in monaco-editor.
	 */
A
Alex Dima 已提交
449
	wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
	/**
	 * Configure word wrapping characters. A break will be introduced before these characters.
	 * Defaults to '{([+'.
	 */
	wordWrapBreakBeforeCharacters?: string;
	/**
	 * Configure word wrapping characters. A break will be introduced after these characters.
	 * Defaults to ' \t})]?|&,;'.
	 */
	wordWrapBreakAfterCharacters?: string;
	/**
	 * Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
	 * Defaults to '.'.
	 */
	wordWrapBreakObtrusiveCharacters?: string;

	/**
	 * Performance guard: Stop rendering a line after x characters.
	 * Defaults to 10000.
	 * Use -1 to never stop rendering
	 */
	stopRenderingLineAfter?: number;
	/**
A
Alex Dima 已提交
473
	 * Configure the editor's hover.
474
	 */
A
Alex Dima 已提交
475
	hover?: IEditorHoverOptions;
476 477 478 479 480
	/**
	 * Enable detecting links and making them clickable.
	 * Defaults to true.
	 */
	links?: boolean;
481
	/**
482
	 * Enable inline color decorators and color picker rendering.
483
	 */
R
rebornix 已提交
484
	colorDecorators?: boolean;
485 486 487 488 489 490 491 492 493 494
	/**
	 * Enable custom contextmenu.
	 * Defaults to true.
	 */
	contextmenu?: boolean;
	/**
	 * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
	 * Defaults to 1.
	 */
	mouseWheelScrollSensitivity?: number;
T
Tiago Ribeiro 已提交
495
	/**
496 497
	 * FastScrolling mulitplier speed when pressing `Alt`
	 * Defaults to 5.
T
Tiago Ribeiro 已提交
498 499
	 */
	fastScrollSensitivity?: number;
500 501 502 503
	/**
	 * The modifier to be used to add multiple cursors with the mouse.
	 * Defaults to 'alt'
	 */
504
	multiCursorModifier?: 'ctrlCmd' | 'alt';
505
	/**
A
Alex Dima 已提交
506
	 * Merge overlapping selections.
507 508
	 * Defaults to true
	 */
A
Alex Dima 已提交
509
	multiCursorMergeOverlapping?: boolean;
510 511 512 513 514
	/**
	 * Configure the editor's accessibility support.
	 * Defaults to 'auto'. It is best to leave this to 'auto'.
	 */
	accessibilitySupport?: 'auto' | 'off' | 'on';
515 516 517 518
	/**
	 * Suggest options.
	 */
	suggest?: ISuggestOptions;
519 520 521 522
	/**
	 *
	 */
	gotoLocation?: IGotoLocationOptions;
523 524 525 526
	/**
	 * Enable quick suggestions (shadow suggestions)
	 * Defaults to true.
	 */
A
Alex Dima 已提交
527
	quickSuggestions?: boolean | IQuickSuggestionsOptions;
528 529
	/**
	 * Quick suggestions show delay (in ms)
A
Alex Dima 已提交
530
	 * Defaults to 10 (ms)
531 532 533
	 */
	quickSuggestionsDelay?: number;
	/**
534
	 * Parameter hint options.
535
	 */
536
	parameterHints?: IEditorParameterHintOptions;
537
	/**
538
	 * Options for auto closing brackets.
539
	 * Defaults to language defined behavior.
540
	 */
J
Jackson Kearl 已提交
541
	autoClosingBrackets?: EditorAutoClosingStrategy;
542
	/**
543
	 * Options for auto closing quotes.
544
	 * Defaults to language defined behavior.
J
Jackson Kearl 已提交
545 546
	 */
	autoClosingQuotes?: EditorAutoClosingStrategy;
547 548 549 550
	/**
	 * Options for typing over closing quotes or brackets.
	 */
	autoClosingOvertype?: EditorAutoClosingOvertypeStrategy;
J
Jackson Kearl 已提交
551
	/**
552 553
	 * Options for auto surrounding.
	 * Defaults to always allowing auto surrounding.
554
	 */
555
	autoSurround?: EditorAutoSurroundStrategy;
556 557 558 559 560
	/**
	 * Enable auto indentation adjustment.
	 * Defaults to false.
	 */
	autoIndent?: boolean;
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582
	/**
	 * Enable format on type.
	 * Defaults to false.
	 */
	formatOnType?: boolean;
	/**
	 * Enable format on paste.
	 * Defaults to false.
	 */
	formatOnPaste?: boolean;
	/**
	 * Controls if the editor should allow to move selections via drag and drop.
	 * Defaults to false.
	 */
	dragAndDrop?: boolean;
	/**
	 * Enable the suggestion box to pop-up on trigger characters.
	 * Defaults to true.
	 */
	suggestOnTriggerCharacters?: boolean;
	/**
	 * Accept suggestions on ENTER.
583
	 * Defaults to 'on'.
584
	 */
A
Alex Dima 已提交
585
	acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
586 587 588 589 590 591 592 593 594 595 596 597 598
	/**
	 * Accept suggestions on provider defined characters.
	 * Defaults to true.
	 */
	acceptSuggestionOnCommitCharacter?: boolean;
	/**
	 * Enable snippet suggestions. Default to 'true'.
	 */
	snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none';
	/**
	 * Copying without a selection copies the current line.
	 */
	emptySelectionClipboard?: boolean;
599
	/**
600
	 * Syntax highlighting is copied.
601
	 */
602
	copyWithSyntaxHighlighting?: boolean;
603 604 605
	/**
	 * The history mode for suggestions.
	 */
M
Martin Aeschlimann 已提交
606
	suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
607 608 609 610 611 612 613 614 615 616
	/**
	 * The font size for the suggest widget.
	 * Defaults to the editor font size.
	 */
	suggestFontSize?: number;
	/**
	 * The line height for the suggest widget.
	 * Defaults to the editor line height.
	 */
	suggestLineHeight?: number;
617 618 619
	/**
	 * Enable tab completion.
	 */
A
Alex Dima 已提交
620
	tabCompletion?: 'on' | 'off' | 'onlySnippets';
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
	/**
	 * Enable selection highlight.
	 * Defaults to true.
	 */
	selectionHighlight?: boolean;
	/**
	 * Enable semantic occurrences highlight.
	 * Defaults to true.
	 */
	occurrencesHighlight?: boolean;
	/**
	 * Show code lens
	 * Defaults to true.
	 */
	codeLens?: boolean;
636 637 638 639
	/**
	 * Control the behavior and rendering of the code action lightbulb.
	 */
	lightbulb?: IEditorLightbulbOptions;
640 641 642 643
	/**
	 * Timeout for running code actions on save.
	 */
	codeActionsOnSaveTimeout?: number;
644 645
	/**
	 * Enable code folding
A
Alex Dima 已提交
646
	 * Defaults to true.
647 648
	 */
	folding?: boolean;
649 650 651 652 653
	/**
	 * Selects the folding strategy. 'auto' uses the strategies contributed for the current document, 'indentation' uses the indentation based folding strategy.
	 * Defaults to 'auto'.
	 */
	foldingStrategy?: 'auto' | 'indentation';
654
	/**
655 656
	 * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
	 * Defaults to 'mouseover'.
657
	 */
658
	showFoldingControls?: 'always' | 'mouseover';
659 660 661 662 663 664 665 666 667
	/**
	 * Enable highlighting of matching brackets.
	 * Defaults to true.
	 */
	matchBrackets?: boolean;
	/**
	 * Enable rendering of whitespace.
	 * Defaults to none.
	 */
668
	renderWhitespace?: 'none' | 'boundary' | 'selection' | 'all';
669 670 671 672 673 674 675
	/**
	 * Enable rendering of control characters.
	 * Defaults to false.
	 */
	renderControlCharacters?: boolean;
	/**
	 * Enable rendering of indent guides.
676
	 * Defaults to true.
677 678
	 */
	renderIndentGuides?: boolean;
679
	/**
C
typo  
Coenraad Stijne 已提交
680
	 * Enable highlighting of the active indent guide.
681 682 683
	 * Defaults to true.
	 */
	highlightActiveIndentGuide?: boolean;
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
	/**
	 * Enable rendering of current line highlight.
	 * Defaults to all.
	 */
	renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
	/**
	 * Inserting and deleting whitespace follows tab stops.
	 */
	useTabStops?: boolean;
	/**
	 * The font family
	 */
	fontFamily?: string;
	/**
	 * The font weight
	 */
700
	fontWeight?: string;
701 702 703 704 705 706 707 708
	/**
	 * The font size
	 */
	fontSize?: number;
	/**
	 * The line height
	 */
	lineHeight?: number;
709 710 711 712
	/**
	 * The letter spacing
	 */
	letterSpacing?: number;
713 714 715 716
	/**
	 * Controls fading out of unused variables.
	 */
	showUnused?: boolean;
A
Alex Dima 已提交
717
}
A
Alex Dima 已提交
718

A
Alex Dima 已提交
719
export type IExtendedEditorOptions = IEditorOptions & {
A
Alex Dima 已提交
720
	/**
721
	 * Do not use, this is a computed option.
A
Alex Dima 已提交
722 723
	 */
	editorClassName?: undefined;
A
Alex Dima 已提交
724 725 726 727
	/**
	 * Do not use, this is a computed option.
	 */
	pixelRatio?: undefined;
728 729 730 731
	/**
	 * Do not use, this is a computed option.
	 */
	fontInfo?: undefined;
732
	/**
733
	 * Do not use, this is a computed option.
734 735 736
	 */
	tabFocusMode?: undefined;
	/**
737
	 * Do not use, this is a computed option.
738
	 */
A
Alex Dima 已提交
739
	layoutInfo?: undefined;
740
	/**
741
	 * Do not use, this is a computed option.
742
	 */
A
Alex Dima 已提交
743
	wrappingInfo?: undefined;
A
Alex Dima 已提交
744
};
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776

/**
 * Configuration options for the diff editor.
 */
export interface IDiffEditorOptions extends IEditorOptions {
	/**
	 * Allow the user to resize the diff editor split view.
	 * Defaults to true.
	 */
	enableSplitViewResizing?: boolean;
	/**
	 * Render the differences in two side-by-side editors.
	 * Defaults to true.
	 */
	renderSideBySide?: boolean;
	/**
	 * Compute the diff by ignoring leading/trailing whitespace
	 * Defaults to true.
	 */
	ignoreTrimWhitespace?: boolean;
	/**
	 * Render +/- indicators for added/deleted changes.
	 * Defaults to true.
	 */
	renderIndicators?: boolean;
	/**
	 * Original model should be editable?
	 * Defaults to false.
	 */
	originalEditable?: boolean;
}

777
export const enum RenderMinimap {
778 779 780 781 782 783 784 785 786 787
	None = 0,
	Small = 1,
	Large = 2,
	SmallBlocks = 3,
	LargeBlocks = 4,
}

/**
 * Describes how to indent wrapped lines.
 */
788
export const enum WrappingIndent {
789 790 791 792 793 794 795 796 797
	/**
	 * No indentation => wrapped lines begin at column 1.
	 */
	None = 0,
	/**
	 * Same => wrapped lines get the same indentation as the parent.
	 */
	Same = 1,
	/**
798
	 * Indent => wrapped lines get +1 indentation toward the parent.
799
	 */
800 801 802
	Indent = 2,
	/**
	 * DeepIndent => wrapped lines get +2 indentation toward the parent.
803
	 */
804
	DeepIndent = 3
805 806 807 808 809
}

/**
 * The kind of animation in which the editor's cursor should be rendered.
 */
810
export const enum TextEditorCursorBlinkingStyle {
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
	/**
	 * Hidden
	 */
	Hidden = 0,
	/**
	 * Blinking
	 */
	Blink = 1,
	/**
	 * Blinking with smooth fading
	 */
	Smooth = 2,
	/**
	 * Blinking with prolonged filled state and smooth fading
	 */
	Phase = 3,
	/**
	 * Expand collapse animation on the y axis
	 */
	Expand = 4,
	/**
	 * No-Blinking
	 */
	Solid = 5
}

/**
 * The style in which the editor's cursor should be rendered.
 */
export enum TextEditorCursorStyle {
	/**
	 * As a vertical line (sitting between two characters).
	 */
	Line = 1,
	/**
	 * As a block (sitting on top of a character).
	 */
	Block = 2,
	/**
	 * As a horizontal line (sitting under a character).
	 */
	Underline = 3,
	/**
	 * As a thin vertical line (sitting between two characters).
	 */
	LineThin = 4,
	/**
	 * As an outlined block (sitting on top of a character).
	 */
	BlockOutline = 5,
	/**
	 * As a thin horizontal line (sitting under a character).
	 */
	UnderlineThin = 6
}

/**
 * @internal
 */
A
Alex Dima 已提交
870 871
export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' {
	switch (cursorStyle) {
872 873 874 875 876 877
		case TextEditorCursorStyle.Line: return 'line';
		case TextEditorCursorStyle.Block: return 'block';
		case TextEditorCursorStyle.Underline: return 'underline';
		case TextEditorCursorStyle.LineThin: return 'line-thin';
		case TextEditorCursorStyle.BlockOutline: return 'block-outline';
		case TextEditorCursorStyle.UnderlineThin: return 'underline-thin';
A
Alex Dima 已提交
878 879 880 881 882
	}
}

function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle {
	switch (cursorStyle) {
883 884 885 886 887 888
		case 'line': return TextEditorCursorStyle.Line;
		case 'block': return TextEditorCursorStyle.Block;
		case 'underline': return TextEditorCursorStyle.Underline;
		case 'line-thin': return TextEditorCursorStyle.LineThin;
		case 'block-outline': return TextEditorCursorStyle.BlockOutline;
		case 'underline-thin': return TextEditorCursorStyle.UnderlineThin;
A
Alex Dima 已提交
889 890 891
	}
}

892
/**
893
 * An event describing that the configuration of the editor has changed.
894
 */
895 896
export class ConfigurationChangedEvent {
	private readonly _values: boolean[];
897 898 899
	/**
	 * @internal
	 */
900 901
	constructor(values: boolean[]) {
		this._values = values;
902 903
	}

904 905
	public hasChanged(id: EditorOption): boolean {
		return this._values[id];
906 907 908
	}
}

A
Alex Dima 已提交
909 910 911 912
export interface IEnvironmentalOptions {
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
913
	readonly extraEditorClassName: string;
A
Alex Dima 已提交
914 915
	readonly isDominatedByLongLines: boolean;
	readonly lineNumbersDigitCount: number;
916
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
917 918
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
919
	readonly accessibilitySupport: AccessibilitySupport;
920
}
921

A
Alex Dima 已提交
922
function _boolean(value: any, defaultValue: boolean): boolean {
923 924 925 926 927 928 929 930 931
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	if (value === 'false') {
		// treat the string 'false' as false
		return false;
	}
	return Boolean(value);
}
932

933 934 935 936 937 938
function _string(value: any, defaultValue: string): string {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	return value;
}
939

A
Alex Dima 已提交
940
function _stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: ReadonlyArray<T>): T {
941 942 943 944 945 946
	if (typeof value !== 'string') {
		return defaultValue;
	}
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
	}
M
Martin Aeschlimann 已提交
947
	return value;
948 949
}

950 951 952 953 954 955 956 957 958 959
function _clamp(n: number, min: number, max: number): number {
	if (n < min) {
		return min;
	}
	if (n > max) {
		return max;
	}
	return n;
}

960 961 962 963 964 965 966 967
function _clampedInt(value: any, defaultValue: number, minimum: number, maximum: number): number {
	let r: number;
	if (typeof value === 'undefined') {
		r = defaultValue;
	} else {
		r = parseInt(value, 10);
		if (isNaN(r)) {
			r = defaultValue;
968
		}
969 970 971 972 973 974 975
	}
	r = Math.max(minimum, r);
	r = Math.min(maximum, r);
	return r | 0;
}

function _float(value: any, defaultValue: number): number {
976 977
	if (typeof value === 'number') {
		return value;
978
	}
979 980 981 982 983
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	const r = parseFloat(value);
	return (isNaN(r) ? defaultValue : r);
984 985
}

A
Alex Dima 已提交
986 987 988 989 990 991
function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent {
	switch (wrappingIndent) {
		case 'none': return WrappingIndent.None;
		case 'same': return WrappingIndent.Same;
		case 'indent': return WrappingIndent.Indent;
		case 'deepIndent': return WrappingIndent.DeepIndent;
992 993 994
	}
}

A
Alex Dima 已提交
995
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle {
996
	switch (cursorBlinkingStyle) {
997 998 999 1000 1001
		case 'blink': return TextEditorCursorBlinkingStyle.Blink;
		case 'smooth': return TextEditorCursorBlinkingStyle.Smooth;
		case 'phase': return TextEditorCursorBlinkingStyle.Phase;
		case 'expand': return TextEditorCursorBlinkingStyle.Expand;
		case 'solid': return TextEditorCursorBlinkingStyle.Solid;
1002 1003 1004
	}
}

A
Alex Dima 已提交
1005
function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
1006 1007 1008 1009
	if (typeof visibility !== 'string') {
		return defaultValue;
	}
	switch (visibility) {
1010 1011 1012
		case 'hidden': return ScrollbarVisibility.Hidden;
		case 'visible': return ScrollbarVisibility.Visible;
		default: return ScrollbarVisibility.Auto;
1013 1014 1015 1016 1017 1018 1019
	}
}

/**
 * @internal
 */
export interface IEditorLayoutProviderOpts {
M
Matt Bierner 已提交
1020 1021
	readonly outerWidth: number;
	readonly outerHeight: number;
1022

M
Matt Bierner 已提交
1023 1024
	readonly showGlyphMargin: boolean;
	readonly lineHeight: number;
1025

M
Matt Bierner 已提交
1026 1027 1028
	readonly showLineNumbers: boolean;
	readonly lineNumbersMinChars: number;
	readonly lineNumbersDigitCount: number;
1029

M
Matt Bierner 已提交
1030
	readonly lineDecorationsWidth: number;
1031

M
Matt Bierner 已提交
1032 1033
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
1034

M
Matt Bierner 已提交
1035 1036 1037 1038
	readonly verticalScrollbarWidth: number;
	readonly verticalScrollbarHasArrows: boolean;
	readonly scrollbarArrowSize: number;
	readonly horizontalScrollbarHeight: number;
1039

M
Matt Bierner 已提交
1040 1041 1042 1043 1044
	readonly minimap: boolean;
	readonly minimapSide: string;
	readonly minimapRenderCharacters: boolean;
	readonly minimapMaxColumn: number;
	readonly pixelRatio: number;
1045 1046
}

A
Alex Dima 已提交
1047 1048 1049 1050
const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';

1051 1052 1053
/**
 * @internal
 */
A
Alex Dima 已提交
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
export const EDITOR_FONT_DEFAULTS = {
	fontFamily: (
		platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)
	),
	fontWeight: 'normal',
	fontSize: (
		platform.isMacintosh ? 12 : 14
	),
	lineHeight: 0,
	letterSpacing: 0,
};
1065

A
Alex Dima 已提交
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
	indentSize: 4,
	insertSpaces: true,
	detectIndentation: true,
	trimAutoWhitespace: true,
	largeFileOptimizations: true
};
1077

1078 1079 1080
/**
 * @internal
 */
A
Alex Dima 已提交
1081
export interface IRawEditorOptionsBag extends IExtendedEditorOptions {
1082 1083 1084 1085 1086 1087 1088 1089
	[key: string]: any;
}

/**
 * @internal
 */
export class ValidatedEditorOptions {
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
1090
	public _read<T>(option: EditorOption): T {
1091 1092
		return this._values[option];
	}
A
Alex Dima 已提交
1093 1094 1095
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1096
	public _write<T>(option: EditorOption, value: T): void {
1097 1098 1099 1100
		this._values[option] = value;
	}
}

A
Alex Dima 已提交
1101
export interface IComputedEditorOptions {
A
renames  
Alex Dima 已提交
1102
	get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
A
Alex Dima 已提交
1103 1104
}

1105 1106 1107
/**
 * @internal
 */
A
Alex Dima 已提交
1108
export class ComputedEditorOptions implements IComputedEditorOptions {
1109
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
1110
	public _read<T>(id: EditorOption): T {
1111 1112
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1113
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
A
Alex Dima 已提交
1114 1115
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1116
	public _write<T>(id: EditorOption, value: T): void {
1117 1118 1119 1120
		this._values[id] = value;
	}
}

A
Alex Dima 已提交
1121 1122
//#region IEditorOption

A
Alex Dima 已提交
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136
export interface IEditorOption<K1 extends EditorOption, V> {
	readonly id: K1;
	readonly name: string;
	readonly defaultValue: V;
	/**
	 * @internal
	 */
	validate(input: any): V;
	/**
	 * @internal
	 */
	compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
}

1137 1138 1139
/**
 * @internal
 */
A
Alex Dima 已提交
1140
type PossibleKeyName0<V> = { [K in keyof IExtendedEditorOptions]: IExtendedEditorOptions[K] extends V | undefined ? K : never }[keyof IExtendedEditorOptions];
1141 1142 1143
/**
 * @internal
 */
1144
type PossibleKeyName<V> = NonNullable<PossibleKeyName0<V>>;
1145

A
Alex Dima 已提交
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
/**
 * @internal
 */
abstract class BaseEditorOption<K1 extends EditorOption, K2 extends keyof IExtendedEditorOptions, V> implements IEditorOption<K1, V> {

	public readonly id: K1;
	public readonly name: K2;
	public readonly defaultValue: V;
	public readonly deps: EditorOption[] | null;

	constructor(id: K1, name: K2, defaultValue: V, deps: EditorOption[] | null = null) {
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
		this.deps = deps;
	}

	public abstract validate(input: any): V;

	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
	}
1168 1169
}

1170 1171 1172
/**
 * @internal
 */
A
Alex Dima 已提交
1173
abstract class ComputedEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {
A
Alex Dima 已提交
1174

1175
	public readonly id: K1;
A
Alex Dima 已提交
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
	public readonly name: '_never_';
	public readonly defaultValue: V;
	public readonly deps: EditorOption[] | null;

	constructor(id: K1, deps: EditorOption[] | null = null) {
		this.id = id;
		this.name = '_never_';
		this.defaultValue = <any>undefined;
		this.deps = deps;
	}

	public validate(input: any): V {
		return this.defaultValue;
	}

	public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
}

/**
 * @internal
 */
class SimpleEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {

	public readonly id: K1;
	public readonly name: PossibleKeyName<V>;
	public readonly defaultValue: V;
	public readonly deps: EditorOption[] | null;
1203

A
Alex Dima 已提交
1204
	constructor(id: K1, name: PossibleKeyName<V>, defaultValue: V, deps: EditorOption[] | null = null) {
1205 1206 1207
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
A
Alex Dima 已提交
1208 1209 1210 1211 1212 1213
		this.deps = deps;
	}

	public validate(input: any): V {
		if (typeof input === 'undefined') {
			return this.defaultValue;
A
Alex Dima 已提交
1214
		}
A
Alex Dima 已提交
1215 1216 1217 1218 1219
		return input as any;
	}

	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
1220
	}
A
Alex Dima 已提交
1221
}
1222

A
Alex Dima 已提交
1223 1224
class EditorBooleanOption<K1 extends EditorOption> extends SimpleEditorOption<K1, boolean> {
	public validate(input: any): boolean {
1225 1226
		return _boolean(input, this.defaultValue);
	}
A
Alex Dima 已提交
1227
}
1228

A
Alex Dima 已提交
1229
class EditorIntOption<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
A
Alex Dima 已提交
1230 1231
	public readonly minimum: number;
	public readonly maximum: number;
A
Alex Dima 已提交
1232 1233
	constructor(id: K1, name: PossibleKeyName<number>, defaultValue: number, minimum: number, maximum: number) {
		super(id, name, defaultValue);
A
Alex Dima 已提交
1234 1235 1236
		this.minimum = minimum;
		this.maximum = maximum;
	}
A
Alex Dima 已提交
1237
	public validate(input: any): number {
A
Alex Dima 已提交
1238 1239 1240
		return _clampedInt(input, this.defaultValue, this.minimum, this.maximum);
	}
}
1241

A
Alex Dima 已提交
1242
class EditorFloatOption<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
A
Alex Dima 已提交
1243
	public readonly validationFn: (value: number) => number;
A
Alex Dima 已提交
1244 1245
	constructor(id: K1, name: PossibleKeyName<number>, defaultValue: number, validationFn: (value: number) => number) {
		super(id, name, defaultValue);
A
Alex Dima 已提交
1246 1247
		this.validationFn = validationFn;
	}
A
Alex Dima 已提交
1248
	public validate(input: any): number {
A
Alex Dima 已提交
1249 1250
		return this.validationFn(_float(input, this.defaultValue));
	}
1251 1252
}

A
Alex Dima 已提交
1253 1254
class EditorStringOption<K1 extends EditorOption> extends SimpleEditorOption<K1, string> {
	public validate(input: any): string {
A
Alex Dima 已提交
1255 1256 1257
		return _string(input, this.defaultValue);
	}
}
1258

A
Alex Dima 已提交
1259 1260 1261 1262
class EditorStringEnumOption<K1 extends EditorOption, V extends string> extends SimpleEditorOption<K1, V> {
	public readonly allowedValues: ReadonlyArray<V>;
	constructor(id: K1, name: PossibleKeyName<V>, defaultValue: V, allowedValues: ReadonlyArray<V>) {
		super(id, name, defaultValue);
A
Alex Dima 已提交
1263 1264
		this.allowedValues = allowedValues;
	}
A
Alex Dima 已提交
1265 1266
	public validate(input: any): V {
		return _stringSet<V>(input, this.defaultValue, this.allowedValues);
A
Alex Dima 已提交
1267 1268 1269
	}
}

A
Alex Dima 已提交
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279
class EditorEnumOption<K1 extends EditorOption, T extends string, V> extends BaseEditorOption<K1, PossibleKeyName<T>, V> {
	public readonly allowedValues: T[];
	public readonly convert: (value: T) => V;
	constructor(id: K1, name: PossibleKeyName<T>, defaultValue: V, allowedValues: T[], convert: (value: T) => V, deps: EditorOption[] = []) {
		super(id, name, defaultValue, deps);
		this.allowedValues = allowedValues;
		this.convert = convert;
	}
	public validate(input: any): V {
		if (typeof input !== 'string') {
A
Alex Dima 已提交
1280 1281
			return this.defaultValue;
		}
A
Alex Dima 已提交
1282 1283 1284 1285
		if (this.allowedValues.indexOf(<T>input) === -1) {
			return this.defaultValue;
		}
		return this.convert(<any>input);
A
Alex Dima 已提交
1286 1287
	}
}
A
Alex Dima 已提交
1288

A
Alex Dima 已提交
1289
//#endregion
A
Alex Dima 已提交
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307

//#region renderLineNumbers

export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);

export const enum RenderLineNumbersType {
	Off = 0,
	On = 1,
	Relative = 2,
	Interval = 3,
	Custom = 4
}

export interface InternalEditorRenderLineNumbersOptions {
	readonly renderType: RenderLineNumbersType;
	readonly renderFn: ((lineNumber: number) => string) | null;
}

A
Alex Dima 已提交
1308 1309
class EditorRenderLineNumbersOption<K1 extends EditorOption, K2 extends PossibleKeyName<LineNumbersType>> extends BaseEditorOption<K1, K2, InternalEditorRenderLineNumbersOptions> {
	public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions {
A
Alex Dima 已提交
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
		let renderType: RenderLineNumbersType = this.defaultValue.renderType;
		let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn;

		if (typeof lineNumbers !== 'undefined') {
			if (typeof lineNumbers === 'function') {
				renderType = RenderLineNumbersType.Custom;
				renderFn = lineNumbers;
			} else if (lineNumbers === 'interval') {
				renderType = RenderLineNumbersType.Interval;
			} else if (lineNumbers === 'relative') {
				renderType = RenderLineNumbersType.Relative;
			} else if (lineNumbers === 'on') {
				renderType = RenderLineNumbersType.On;
			} else {
				renderType = RenderLineNumbersType.Off;
			}
		}

		return {
			renderType,
			renderFn
		};
	}
1333 1334
}

A
Alex Dima 已提交
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346
//#endregion

//#region minimap

export interface InternalEditorMinimapOptions {
	readonly enabled: boolean;
	readonly side: 'right' | 'left';
	readonly showSlider: 'always' | 'mouseover';
	readonly renderCharacters: boolean;
	readonly maxColumn: number;
}

A
Alex Dima 已提交
1347 1348 1349
class EditorMinimap<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorMinimapOptions>> extends BaseEditorOption<K1, K2, InternalEditorMinimapOptions> {
	public validate(_input: any): InternalEditorMinimapOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1350 1351
			return this.defaultValue;
		}
A
Alex Dima 已提交
1352
		const input = _input as IEditorMinimapOptions;
A
Alex Dima 已提交
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
		return {
			enabled: _boolean(input.enabled, this.defaultValue.enabled),
			side: _stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']),
			showSlider: _stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
			renderCharacters: _boolean(input.renderCharacters, this.defaultValue.renderCharacters),
			maxColumn: _clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000),
		};
	}
}

//#endregion

A
Alex Dima 已提交
1365 1366 1367 1368 1369 1370 1371 1372 1373
//#region hover

export interface InternalEditorHoverOptions {
	readonly enabled: boolean;
	readonly delay: number;
	readonly sticky: boolean;
}

class EditorHover<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorHoverOptions>> extends BaseEditorOption<K1, K2, InternalEditorHoverOptions> {
A
Alex Dima 已提交
1374 1375
	public validate(_input: any): InternalEditorHoverOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1376 1377
			return this.defaultValue;
		}
A
Alex Dima 已提交
1378
		const input = _input as IEditorHoverOptions;
A
Alex Dima 已提交
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
		return {
			enabled: _boolean(input.enabled, this.defaultValue.enabled),
			delay: _clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
			sticky: _boolean(input.sticky, this.defaultValue.sticky)
		};
	}
}

//#endregion

//#region quickSuggestions

export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;

class EditorQuickSuggestions<K1 extends EditorOption, K2 extends PossibleKeyName<boolean | IQuickSuggestionsOptions>> extends BaseEditorOption<K1, K2, ValidQuickSuggestionsOptions> {
	public readonly defaultValue: Readonly<Required<IQuickSuggestionsOptions>>;
	constructor(id: K1, name: K2, defaultValue: Readonly<Required<IQuickSuggestionsOptions>>) {
		super(id, name, defaultValue);
	}
A
Alex Dima 已提交
1398 1399 1400
	public validate(_input: any): ValidQuickSuggestionsOptions {
		if (typeof _input === 'boolean') {
			return _input;
A
Alex Dima 已提交
1401
		}
A
Alex Dima 已提交
1402 1403
		if (typeof _input === 'object') {
			const input = _input as IQuickSuggestionsOptions;
A
Alex Dima 已提交
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
			return {
				other: _boolean(input.other, this.defaultValue.other),
				comments: _boolean(input.comments, this.defaultValue.comments),
				strings: _boolean(input.strings, this.defaultValue.strings),
			};
		}
		return this.defaultValue;
	}
}

//#endregion

A
Alex Dima 已提交
1416 1417
//#region accessibilitySupport

A
Alex Dima 已提交
1418 1419 1420 1421 1422 1423 1424 1425
class EditorAccessibilitySupportOption<K1 extends EditorOption, K2 extends PossibleKeyName<'auto' | 'off' | 'on'>> extends BaseEditorOption<K1, K2, AccessibilitySupport> {
	public validate(input: any): AccessibilitySupport {
		switch (input) {
			case 'auto': return AccessibilitySupport.Unknown;
			case 'off': return AccessibilitySupport.Disabled;
			case 'on': return AccessibilitySupport.Enabled;
		}
		return this.defaultValue;
A
Alex Dima 已提交
1426
	}
A
Alex Dima 已提交
1427 1428
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: AccessibilitySupport): AccessibilitySupport {
		if (value === AccessibilitySupport.Unknown) {
A
Alex Dima 已提交
1429 1430 1431
			// The editor reads the `accessibilitySupport` from the environment
			return env.accessibilitySupport;
		}
A
Alex Dima 已提交
1432
		return value;
A
Alex Dima 已提交
1433 1434 1435 1436 1437
	}
}

//#endregion

A
Alex Dima 已提交
1438 1439
//#region rulers

A
Alex Dima 已提交
1440 1441
class EditorRulers<K1 extends EditorOption> extends SimpleEditorOption<K1, number[]> {
	public validate(input: any): number[] {
A
Alex Dima 已提交
1442 1443
		if (Array.isArray(input)) {
			let rulers: number[] = [];
1444
			for (let value of input) {
A
Alex Dima 已提交
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
				rulers.push(_clampedInt(value, 0, 0, 10000));
			}
			rulers.sort();
			return rulers;
		}
		return this.defaultValue;
	}
}

//#endregion

A
Alex Dima 已提交
1456 1457
//#region ariaLabel

A
Alex Dima 已提交
1458 1459
class EditorAriaLabel<K1 extends EditorOption> extends SimpleEditorOption<K1, string> {
	public validate(input: any): string {
A
Alex Dima 已提交
1460 1461 1462
		return _string(input, this.defaultValue);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string {
A
renames  
Alex Dima 已提交
1463
		const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
A
Alex Dima 已提交
1464 1465 1466 1467 1468 1469 1470 1471 1472
		if (accessibilitySupport === AccessibilitySupport.Disabled) {
			return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.");
		}
		return value;
	}
}

//#endregion

A
Alex Dima 已提交
1473 1474
//#region disableMonospaceOptimizations

A
Alex Dima 已提交
1475 1476
class EditorDisableMonospaceOptimizations<K1 extends EditorOption> extends SimpleEditorOption<K1, boolean> {
	public validate(input: any): boolean {
A
Alex Dima 已提交
1477 1478 1479
		return _boolean(input, this.defaultValue);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
A
Alex Dima 已提交
1480
		return (value || options.get(EditorOption.fontLigatures));
A
Alex Dima 已提交
1481 1482 1483 1484 1485 1486 1487
	}
}

//#endregion

//#region editorClassName

A
Alex Dima 已提交
1488 1489
class EditorClassName<K1 extends EditorOption> extends ComputedEditorOption<K1, string> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string {
A
Alex Dima 已提交
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
		let className = 'monaco-editor';
		if (options.get(EditorOption.extraEditorClassName)) {
			className += ' ' + options.get(EditorOption.extraEditorClassName);
		}
		if (env.extraEditorClassName) {
			className += ' ' + env.extraEditorClassName;
		}
		if (options.get(EditorOption.fontLigatures)) {
			className += ' enable-ligatures';
		}
		if (options.get(EditorOption.mouseStyle) === 'default') {
			className += ' mouse-default';
		} else if (options.get(EditorOption.mouseStyle) === 'copy') {
			className += ' mouse-copy';
		}
		return className;
	}
}

//#endregion

1511 1512
//#region tabFocusMode

A
Alex Dima 已提交
1513 1514
class EditorTabFocusMode<K1 extends EditorOption> extends ComputedEditorOption<K1, boolean> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: boolean): boolean {
A
renames  
Alex Dima 已提交
1515
		const readOnly = options.get(EditorOption.readOnly);
1516 1517 1518 1519 1520 1521
		return (readOnly ? true : env.tabFocusMode);
	}
}

//#endregion

A
Alex Dima 已提交
1522 1523
//#region pixelRatio

A
Alex Dima 已提交
1524 1525
class EditorPixelRatio<K1 extends EditorOption> extends ComputedEditorOption<K1, number> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number {
A
Alex Dima 已提交
1526 1527 1528 1529 1530 1531 1532 1533
		return env.pixelRatio;
	}
}

//#endregion

//#region lineHeight

A
Alex Dima 已提交
1534
class EditorLineHeight<K1 extends EditorOption, K2 extends PossibleKeyName<number>> extends EditorIntOption<K1> {
A
Alex Dima 已提交
1535
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
A
Alex Dima 已提交
1536 1537 1538
		// The lineHeight is computed from the fontSize if it is 0.
		// Moreover, the final lineHeight respects the editor zoom level.
		// So take the result from env.fontInfo
A
Alex Dima 已提交
1539 1540 1541 1542 1543 1544
		return env.fontInfo.lineHeight;
	}
}

//#endregion

A
Alex Dima 已提交
1545 1546
//#region fontSize

A
Alex Dima 已提交
1547 1548
class EditorFontSize<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
	public validate(input: any): number {
A
Alex Dima 已提交
1549 1550 1551 1552 1553 1554 1555
		let r = _float(input, this.defaultValue);
		if (r === 0) {
			return EDITOR_FONT_DEFAULTS.fontSize;
		}
		return _clamp(r, 8, 100);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
A
Alex Dima 已提交
1556 1557 1558
		// The final fontSize respects the editor zoom level.
		// So take the result from env.fontInfo
		return env.fontInfo.fontSize;
A
Alex Dima 已提交
1559 1560 1561 1562 1563
	}
}

//#endregion

1564 1565
//#region fontInfo

A
Alex Dima 已提交
1566 1567
class EditorFontInfo<K1 extends EditorOption> extends ComputedEditorOption<K1, FontInfo> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo {
1568 1569 1570 1571 1572 1573
		return env.fontInfo;
	}
}

//#endregion

A
Alex Dima 已提交
1574
//#region emptySelectionClipboard
A
Alex Dima 已提交
1575

A
Alex Dima 已提交
1576
class EditorEmptySelectionClipboard<K1 extends EditorOption> extends EditorBooleanOption<K1> {
A
Alex Dima 已提交
1577 1578 1579 1580 1581 1582 1583
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
		return value && env.emptySelectionClipboard;
	}
}

//#endregion

A
Alex Dima 已提交
1584 1585 1586 1587 1588
//#region lightbulb

export type ValidEditorLightbulbOptions = Required<IEditorLightbulbOptions>;

class EditorLightbulb<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorLightbulbOptions>> extends BaseEditorOption<K1, K2, ValidEditorLightbulbOptions> {
A
Alex Dima 已提交
1589 1590
	public validate(_input: any): ValidEditorLightbulbOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1591 1592
			return this.defaultValue;
		}
A
Alex Dima 已提交
1593
		const input = _input as IEditorLightbulbOptions;
A
Alex Dima 已提交
1594 1595 1596 1597 1598 1599 1600 1601
		return {
			enabled: _boolean(input.enabled, this.defaultValue.enabled)
		};
	}
}

//#endregion

A
Alex Dima 已提交
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617
//#region scrollbar

export interface InternalEditorScrollbarOptions {
	readonly arrowSize: number;
	readonly vertical: ScrollbarVisibility;
	readonly horizontal: ScrollbarVisibility;
	readonly useShadows: boolean;
	readonly verticalHasArrows: boolean;
	readonly horizontalHasArrows: boolean;
	readonly handleMouseWheel: boolean;
	readonly horizontalScrollbarSize: number;
	readonly horizontalSliderSize: number;
	readonly verticalScrollbarSize: number;
	readonly verticalSliderSize: number;
}

A
Alex Dima 已提交
1618 1619 1620
class EditorScrollbar<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorScrollbarOptions>> extends BaseEditorOption<K1, K2, InternalEditorScrollbarOptions> {
	public validate(_input: any): InternalEditorScrollbarOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1621 1622
			return this.defaultValue;
		}
A
Alex Dima 已提交
1623
		const input = _input as IEditorScrollbarOptions;
A
Alex Dima 已提交
1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643
		const horizontalScrollbarSize = _clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000);
		const verticalScrollbarSize = _clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000);
		return {
			arrowSize: _clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000),
			vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical),
			horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal),
			useShadows: _boolean(input.useShadows, this.defaultValue.useShadows),
			verticalHasArrows: _boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows),
			horizontalHasArrows: _boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows),
			handleMouseWheel: _boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel),
			horizontalScrollbarSize: horizontalScrollbarSize,
			horizontalSliderSize: _clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),
			verticalScrollbarSize: verticalScrollbarSize,
			verticalSliderSize: _clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000),
		};
	}
}

//#endregion

A
Alex Dima 已提交
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
//#region suggest

export interface InternalSuggestOptions {
	readonly filterGraceful: boolean;
	readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
	readonly snippetsPreventQuickSuggestions: boolean;
	readonly localityBonus: boolean;
	readonly shareSuggestSelections: boolean;
	readonly showIcons: boolean;
	readonly maxVisibleSuggestions: number;
	readonly filteredTypes: Record<string, boolean>;
}

A
Alex Dima 已提交
1657 1658 1659
class EditorSuggest<K1 extends EditorOption, K2 extends PossibleKeyName<ISuggestOptions>> extends BaseEditorOption<K1, K2, InternalSuggestOptions> {
	public validate(_input: any): InternalSuggestOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1660 1661
			return this.defaultValue;
		}
A
Alex Dima 已提交
1662
		const input = _input as ISuggestOptions;
A
Alex Dima 已提交
1663 1664
		return {
			filterGraceful: _boolean(input.filterGraceful, this.defaultValue.filterGraceful),
A
Alex Dima 已提交
1665
			snippets: EditorOptions.snippetSuggestions.defaultValue,
A
Alex Dima 已提交
1666 1667 1668 1669 1670 1671 1672 1673
			snippetsPreventQuickSuggestions: _boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
			localityBonus: _boolean(input.localityBonus, this.defaultValue.localityBonus),
			shareSuggestSelections: _boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
			showIcons: _boolean(input.showIcons, this.defaultValue.showIcons),
			maxVisibleSuggestions: _clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15),
			filteredTypes: isObject(input.filteredTypes) ? input.filteredTypes : Object.create(null)
		};
	}
A
Alex Dima 已提交
1674
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalSuggestOptions): InternalSuggestOptions {
A
Alex Dima 已提交
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698
		const snippetSuggestions = options.get(EditorOption.snippetSuggestions);
		return {
			filterGraceful: value.filterGraceful,
			snippets: snippetSuggestions,
			snippetsPreventQuickSuggestions: value.snippetsPreventQuickSuggestions,
			localityBonus: value.localityBonus,
			shareSuggestSelections: value.shareSuggestSelections,
			showIcons: value.showIcons,
			maxVisibleSuggestions: value.maxVisibleSuggestions,
			filteredTypes: value.filteredTypes,
		};
	}
}

//#endregion

//#region parameterHints

export interface InternalParameterHintOptions {
	readonly enabled: boolean;
	readonly cycle: boolean;
}

class EditorParameterHints<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorParameterHintOptions>> extends BaseEditorOption<K1, K2, InternalParameterHintOptions> {
A
Alex Dima 已提交
1699 1700
	public validate(_input: any): InternalParameterHintOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1701 1702
			return this.defaultValue;
		}
A
Alex Dima 已提交
1703
		const input = _input as IEditorParameterHintOptions;
A
Alex Dima 已提交
1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
		return {
			enabled: _boolean(input.enabled, this.defaultValue.enabled),
			cycle: _boolean(input.cycle, this.defaultValue.cycle)
		};
	}
}

//#endregion

//#region find

export interface InternalEditorFindOptions {
	readonly seedSearchStringFromSelection: boolean;
	readonly autoFindInSelection: boolean;
	readonly addExtraSpaceOnTop: boolean;
	/**
	 * @internal
	 */
	readonly globalFindClipboard: boolean;
}

class EditorFind<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorFindOptions>> extends BaseEditorOption<K1, K2, InternalEditorFindOptions> {
A
Alex Dima 已提交
1726 1727
	public validate(_input: any): InternalEditorFindOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1728 1729
			return this.defaultValue;
		}
A
Alex Dima 已提交
1730
		const input = _input as IEditorFindOptions;
A
Alex Dima 已提交
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
		return {
			seedSearchStringFromSelection: _boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection),
			autoFindInSelection: _boolean(input.autoFindInSelection, this.defaultValue.autoFindInSelection),
			globalFindClipboard: _boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
			addExtraSpaceOnTop: _boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop)
		};
	}
}

//#endregion

//#region gotoLocation

export interface InternalGoToLocationOptions {
	readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
}

class EditorGoToLocation<K1 extends EditorOption, K2 extends PossibleKeyName<IGotoLocationOptions>> extends BaseEditorOption<K1, K2, InternalGoToLocationOptions> {
A
Alex Dima 已提交
1749 1750
	public validate(_input: any): InternalGoToLocationOptions {
		if (typeof _input !== 'object') {
A
Alex Dima 已提交
1751 1752
			return this.defaultValue;
		}
A
Alex Dima 已提交
1753
		const input = _input as IGotoLocationOptions;
A
Alex Dima 已提交
1754 1755 1756 1757 1758 1759 1760 1761
		return {
			multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto'])
		};
	}
}

//#endregion

A
Alex Dima 已提交
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888
//#region layoutInfo

/**
 * A description for the overview ruler position.
 */
export interface OverviewRulerPosition {
	/**
	 * Width of the overview ruler
	 */
	readonly width: number;
	/**
	 * Height of the overview ruler
	 */
	readonly height: number;
	/**
	 * Top position for the overview ruler
	 */
	readonly top: number;
	/**
	 * Right position for the overview ruler
	 */
	readonly right: number;
}

/**
 * The internal layout details of the editor.
 */
export interface EditorLayoutInfo {

	/**
	 * Full editor width.
	 */
	readonly width: number;
	/**
	 * Full editor height.
	 */
	readonly height: number;

	/**
	 * Left position for the glyph margin.
	 */
	readonly glyphMarginLeft: number;
	/**
	 * The width of the glyph margin.
	 */
	readonly glyphMarginWidth: number;
	/**
	 * The height of the glyph margin.
	 */
	readonly glyphMarginHeight: number;

	/**
	 * Left position for the line numbers.
	 */
	readonly lineNumbersLeft: number;
	/**
	 * The width of the line numbers.
	 */
	readonly lineNumbersWidth: number;
	/**
	 * The height of the line numbers.
	 */
	readonly lineNumbersHeight: number;

	/**
	 * Left position for the line decorations.
	 */
	readonly decorationsLeft: number;
	/**
	 * The width of the line decorations.
	 */
	readonly decorationsWidth: number;
	/**
	 * The height of the line decorations.
	 */
	readonly decorationsHeight: number;

	/**
	 * Left position for the content (actual text)
	 */
	readonly contentLeft: number;
	/**
	 * The width of the content (actual text)
	 */
	readonly contentWidth: number;
	/**
	 * The height of the content (actual height)
	 */
	readonly contentHeight: number;

	/**
	 * The position for the minimap
	 */
	readonly minimapLeft: number;
	/**
	 * The width of the minimap
	 */
	readonly minimapWidth: number;

	/**
	 * Minimap render type
	 */
	readonly renderMinimap: RenderMinimap;

	/**
	 * The number of columns (of typical characters) fitting on a viewport line.
	 */
	readonly viewportColumn: number;

	/**
	 * The width of the vertical scrollbar.
	 */
	readonly verticalScrollbarWidth: number;
	/**
	 * The height of the horizontal scrollbar.
	 */
	readonly horizontalScrollbarHeight: number;

	/**
	 * The position of the overview ruler.
	 */
	readonly overviewRuler: OverviewRulerPosition;
}

/**
 * @internal
 */
A
Alex Dima 已提交
1889 1890
export class EditorLayoutInfoComputer<K1 extends EditorOption> extends ComputedEditorOption<K1, EditorLayoutInfo> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorLayoutInfo): EditorLayoutInfo {
A
renames  
Alex Dima 已提交
1891 1892 1893 1894 1895 1896
		const glyphMargin = options.get(EditorOption.glyphMargin);
		const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars);
		const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth);
		const folding = options.get(EditorOption.folding);
		const minimap = options.get(EditorOption.minimap);
		const scrollbar = options.get(EditorOption.scrollbar);
A
Alex Dima 已提交
1897
		const lineNumbers = options.get(EditorOption.lineNumbers);
A
Alex Dima 已提交
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914

		let lineDecorationsWidth: number;
		if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) {
			const multiple = parseFloat(rawLineDecorationsWidth.substr(0, rawLineDecorationsWidth.length - 2));
			lineDecorationsWidth = multiple * env.fontInfo.typicalHalfwidthCharacterWidth;
		} else {
			lineDecorationsWidth = _clampedInt(rawLineDecorationsWidth, 0, 0, 1000);
		}
		if (folding) {
			lineDecorationsWidth += 16;
		}

		return EditorLayoutInfoComputer.compute({
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
			showGlyphMargin: glyphMargin,
			lineHeight: env.fontInfo.lineHeight,
A
Alex Dima 已提交
1915
			showLineNumbers: (lineNumbers.renderType !== RenderLineNumbersType.Off),
A
Alex Dima 已提交
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076
			lineNumbersMinChars: lineNumbersMinChars,
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			lineDecorationsWidth: lineDecorationsWidth,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
			verticalScrollbarWidth: scrollbar.verticalScrollbarSize,
			horizontalScrollbarHeight: scrollbar.horizontalScrollbarSize,
			scrollbarArrowSize: scrollbar.arrowSize,
			verticalScrollbarHasArrows: scrollbar.verticalHasArrows,
			minimap: minimap.enabled,
			minimapSide: minimap.side,
			minimapRenderCharacters: minimap.renderCharacters,
			minimapMaxColumn: minimap.maxColumn,
			pixelRatio: env.pixelRatio
		});
	}

	public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo {
		const outerWidth = _opts.outerWidth | 0;
		const outerHeight = _opts.outerHeight | 0;
		const showGlyphMargin = _opts.showGlyphMargin;
		const lineHeight = _opts.lineHeight | 0;
		const showLineNumbers = _opts.showLineNumbers;
		const lineNumbersMinChars = _opts.lineNumbersMinChars | 0;
		const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0;
		const lineDecorationsWidth = _opts.lineDecorationsWidth | 0;
		const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth;
		const maxDigitWidth = _opts.maxDigitWidth;
		const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0;
		const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows;
		const scrollbarArrowSize = _opts.scrollbarArrowSize | 0;
		const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0;
		const minimap = _opts.minimap;
		const minimapSide = _opts.minimapSide;
		const minimapRenderCharacters = _opts.minimapRenderCharacters;
		const minimapMaxColumn = _opts.minimapMaxColumn | 0;
		const pixelRatio = _opts.pixelRatio;

		let lineNumbersWidth = 0;
		if (showLineNumbers) {
			const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars);
			lineNumbersWidth = Math.round(digitCount * maxDigitWidth);
		}

		let glyphMarginWidth = 0;
		if (showGlyphMargin) {
			glyphMarginWidth = lineHeight;
		}

		let glyphMarginLeft = 0;
		let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
		let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
		let contentLeft = decorationsLeft + lineDecorationsWidth;

		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;

		let renderMinimap: RenderMinimap;
		let minimapLeft: number;
		let minimapWidth: number;
		let contentWidth: number;
		if (!minimap) {
			minimapLeft = 0;
			minimapWidth = 0;
			renderMinimap = RenderMinimap.None;
			contentWidth = remainingWidth;
		} else {
			let minimapCharWidth: number;
			if (pixelRatio >= 2) {
				renderMinimap = minimapRenderCharacters ? RenderMinimap.Large : RenderMinimap.LargeBlocks;
				minimapCharWidth = 2 / pixelRatio;
			} else {
				renderMinimap = minimapRenderCharacters ? RenderMinimap.Small : RenderMinimap.SmallBlocks;
				minimapCharWidth = 1 / pixelRatio;
			}

			// Given:
			// (leaving 2px for the cursor to have space after the last character)
			// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
			// minimapWidth = viewportColumn * minimapCharWidth
			// contentWidth = remainingWidth - minimapWidth
			// What are good values for contentWidth and minimapWidth ?

			// minimapWidth = ((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth) * minimapCharWidth
			// typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth - 2) * minimapCharWidth
			// typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth - 2) * minimapCharWidth
			// (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth
			// minimapWidth = ((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)

			minimapWidth = Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)));
			let minimapColumns = minimapWidth / minimapCharWidth;
			if (minimapColumns > minimapMaxColumn) {
				minimapWidth = Math.floor(minimapMaxColumn * minimapCharWidth);
			}
			contentWidth = remainingWidth - minimapWidth;

			if (minimapSide === 'left') {
				minimapLeft = 0;
				glyphMarginLeft += minimapWidth;
				lineNumbersLeft += minimapWidth;
				decorationsLeft += minimapWidth;
				contentLeft += minimapWidth;
			} else {
				minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth;
			}
		}

		// (leaving 2px for the cursor to have space after the last character)
		const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth));

		const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);

		return {
			width: outerWidth,
			height: outerHeight,

			glyphMarginLeft: glyphMarginLeft,
			glyphMarginWidth: glyphMarginWidth,
			glyphMarginHeight: outerHeight,

			lineNumbersLeft: lineNumbersLeft,
			lineNumbersWidth: lineNumbersWidth,
			lineNumbersHeight: outerHeight,

			decorationsLeft: decorationsLeft,
			decorationsWidth: lineDecorationsWidth,
			decorationsHeight: outerHeight,

			contentLeft: contentLeft,
			contentWidth: contentWidth,
			contentHeight: outerHeight,

			renderMinimap: renderMinimap,
			minimapLeft: minimapLeft,
			minimapWidth: minimapWidth,

			viewportColumn: viewportColumn,

			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

			overviewRuler: {
				top: verticalArrowSize,
				width: verticalScrollbarWidth,
				height: (outerHeight - 2 * verticalArrowSize),
				right: 0
			}
		};
	}
}

//#endregion

//#region wrappingInfo

export interface EditorWrappingInfo {
	readonly isDominatedByLongLines: boolean;
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;
}

A
Alex Dima 已提交
2077 2078
class EditorWrappingInfoComputer<K1 extends EditorOption> extends ComputedEditorOption<K1, EditorWrappingInfo> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorWrappingInfo): EditorWrappingInfo {
A
renames  
Alex Dima 已提交
2079 2080 2081 2082 2083
		const wordWrap = options.get(EditorOption.wordWrap);
		const wordWrapColumn = options.get(EditorOption.wordWrapColumn);
		const wordWrapMinified = options.get(EditorOption.wordWrapMinified);
		const layoutInfo = options.get(EditorOption.layoutInfo);
		const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
A
Alex Dima 已提交
2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141

		let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null;
		{
			if (accessibilitySupport === AccessibilitySupport.Enabled) {
				// See https://github.com/Microsoft/vscode/issues/27766
				// Never enable wrapping when a screen reader is attached
				// because arrow down etc. will not move the cursor in the way
				// a screen reader expects.
				bareWrappingInfo = {
					isWordWrapMinified: false,
					isViewportWrapping: false,
					wrappingColumn: -1
				};
			} else if (wordWrapMinified && env.isDominatedByLongLines) {
				// Force viewport width wrapping if model is dominated by long lines
				bareWrappingInfo = {
					isWordWrapMinified: true,
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
			} else if (wordWrap === 'on') {
				bareWrappingInfo = {
					isWordWrapMinified: false,
					isViewportWrapping: true,
					wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
				};
			} else if (wordWrap === 'bounded') {
				bareWrappingInfo = {
					isWordWrapMinified: false,
					isViewportWrapping: true,
					wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn)
				};
			} else if (wordWrap === 'wordWrapColumn') {
				bareWrappingInfo = {
					isWordWrapMinified: false,
					isViewportWrapping: false,
					wrappingColumn: wordWrapColumn
				};
			} else {
				bareWrappingInfo = {
					isWordWrapMinified: false,
					isViewportWrapping: false,
					wrappingColumn: -1
				};
			}
		}

		return {
			isDominatedByLongLines: env.isDominatedByLongLines,
			isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
			isViewportWrapping: bareWrappingInfo.isViewportWrapping,
			wrappingColumn: bareWrappingInfo.wrappingColumn,
		};
	}
}

//#endregion

A
Alex Dima 已提交
2142 2143 2144 2145 2146 2147 2148
function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): 'altKey' | 'metaKey' | 'ctrlKey' {
	if (multiCursorModifier === 'ctrlCmd') {
		return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
	}
	return 'altKey';
}

A
Alex Dima 已提交
2149 2150 2151 2152 2153
/**
 * @internal
 */
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];

A
Alex Dima 已提交
2154
function registerEditorOption<K1 extends EditorOption, V>(option: IEditorOption<K1, V>): IEditorOption<K1, V> {
A
Alex Dima 已提交
2155 2156 2157 2158
	editorOptionsRegistry[option.id] = option;
	return option;
}

A
renames  
Alex Dima 已提交
2159
export const enum EditorOption {
A
Alex Dima 已提交
2160 2161
	acceptSuggestionOnCommitCharacter,
	acceptSuggestionOnEnter,
A
Alex Dima 已提交
2162
	accessibilitySupport,
A
Alex Dima 已提交
2163 2164 2165 2166 2167 2168
	autoClosingBrackets,
	autoClosingOvertype,
	autoClosingQuotes,
	autoIndent,
	automaticLayout,
	autoSurround,
A
Alex Dima 已提交
2169 2170 2171
	codeLens,
	colorDecorators,
	contextmenu,
A
Alex Dima 已提交
2172 2173 2174 2175 2176 2177 2178 2179 2180 2181
	copyWithSyntaxHighlighting,
	cursorBlinking,
	cursorSmoothCaretAnimation,
	cursorStyle,
	cursorSurroundingLines,
	cursorWidth,
	disableLayerHinting,
	dragAndDrop,
	emptySelectionClipboard,
	extraEditorClassName,
A
Alex Dima 已提交
2182
	fastScrollSensitivity,
A
Alex Dima 已提交
2183
	find,
A
Alex Dima 已提交
2184
	fixedOverflowWidgets,
A
Alex Dima 已提交
2185
	folding,
A
Alex Dima 已提交
2186
	foldingStrategy,
2187 2188
	fontFamily,
	fontInfo,
A
Alex Dima 已提交
2189
	fontLigatures,
2190 2191
	fontSize,
	fontWeight,
A
Alex Dima 已提交
2192 2193
	formatOnPaste,
	formatOnType,
A
Alex Dima 已提交
2194
	glyphMargin,
A
Alex Dima 已提交
2195
	gotoLocation,
A
Alex Dima 已提交
2196 2197
	hideCursorInOverviewRuler,
	highlightActiveIndentGuide,
A
Alex Dima 已提交
2198
	hover,
A
Alex Dima 已提交
2199
	inDiffEditor,
2200
	letterSpacing,
A
Alex Dima 已提交
2201
	lightbulb,
A
Alex Dima 已提交
2202
	lineDecorationsWidth,
A
Alex Dima 已提交
2203
	lineHeight,
A
Alex Dima 已提交
2204
	lineNumbers,
A
Alex Dima 已提交
2205
	lineNumbersMinChars,
A
Alex Dima 已提交
2206 2207
	links,
	matchBrackets,
A
Alex Dima 已提交
2208
	minimap,
A
Alex Dima 已提交
2209
	mouseStyle,
A
Alex Dima 已提交
2210
	mouseWheelScrollSensitivity,
A
Alex Dima 已提交
2211 2212 2213
	mouseWheelZoom,
	multiCursorMergeOverlapping,
	multiCursorModifier,
A
Alex Dima 已提交
2214
	occurrencesHighlight,
A
Alex Dima 已提交
2215 2216
	overviewRulerBorder,
	overviewRulerLanes,
A
Alex Dima 已提交
2217 2218
	parameterHints,
	quickSuggestions,
A
Alex Dima 已提交
2219
	quickSuggestionsDelay,
2220
	readOnly,
A
Alex Dima 已提交
2221 2222
	renderControlCharacters,
	renderIndentGuides,
A
Alex Dima 已提交
2223
	renderFinalNewline,
A
Alex Dima 已提交
2224 2225 2226 2227 2228
	renderLineHighlight,
	renderWhitespace,
	revealHorizontalRightPadding,
	roundedSelection,
	rulers,
A
Alex Dima 已提交
2229
	scrollbar,
A
Alex Dima 已提交
2230 2231
	scrollBeyondLastColumn,
	scrollBeyondLastLine,
A
Alex Dima 已提交
2232
	selectionClipboard,
A
Alex Dima 已提交
2233
	selectionHighlight,
A
Alex Dima 已提交
2234
	selectOnLineNumbers,
A
Alex Dima 已提交
2235
	showFoldingControls,
A
Alex Dima 已提交
2236
	showUnused,
A
Alex Dima 已提交
2237
	snippetSuggestions,
A
Alex Dima 已提交
2238 2239
	smoothScrolling,
	stopRenderingLineAfter,
A
Alex Dima 已提交
2240 2241
	suggestFontSize,
	suggestLineHeight,
A
Alex Dima 已提交
2242
	suggestOnTriggerCharacters,
A
Alex Dima 已提交
2243 2244
	suggestSelection,
	tabCompletion,
A
Alex Dima 已提交
2245 2246
	useTabStops,
	wordSeparators,
A
Alex Dima 已提交
2247 2248 2249 2250 2251 2252 2253 2254
	wordWrap,
	wordWrapBreakAfterCharacters,
	wordWrapBreakBeforeCharacters,
	wordWrapBreakObtrusiveCharacters,
	wordWrapColumn,
	wordWrapMinified,
	wrappingIndent,

A
Alex Dima 已提交
2255 2256 2257
	ariaLabel,
	disableMonospaceOptimizations,
	editorClassName,
A
Alex Dima 已提交
2258
	pixelRatio,
A
Alex Dima 已提交
2259
	tabFocusMode,
A
Alex Dima 已提交
2260
	suggest,
A
Alex Dima 已提交
2261 2262
	layoutInfo,
	wrappingInfo,
2263 2264
}

A
renames  
Alex Dima 已提交
2265
export const EditorOptions = {
A
Alex Dima 已提交
2266
	acceptSuggestionOnCommitCharacter: registerEditorOption(new EditorBooleanOption(EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true)),
A
Alex Dima 已提交
2267 2268 2269 2270 2271
	acceptSuggestionOnEnter: registerEditorOption(new EditorStringEnumOption(EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter', 'on' as 'on' | 'smart' | 'off', ['on', 'smart', 'off'] as const)),
	accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', AccessibilitySupport.Unknown)),
	autoClosingBrackets: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingBrackets, 'autoClosingBrackets', 'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never', ['always', 'languageDefined', 'beforeWhitespace', 'never'] as const)),
	autoClosingOvertype: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto' as 'always' | 'auto' | 'never', ['always', 'auto', 'never'] as const)),
	autoClosingQuotes: registerEditorOption(new EditorStringEnumOption(EditorOption.autoClosingQuotes, 'autoClosingQuotes', 'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never', ['always', 'languageDefined', 'beforeWhitespace', 'never'] as const)),
A
Alex Dima 已提交
2272 2273
	autoIndent: registerEditorOption(new EditorBooleanOption(EditorOption.autoIndent, 'autoIndent', true)),
	automaticLayout: registerEditorOption(new EditorBooleanOption(EditorOption.automaticLayout, 'automaticLayout', false)),
A
Alex Dima 已提交
2274
	autoSurround: registerEditorOption(new EditorStringEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined' as 'languageDefined' | 'quotes' | 'brackets' | 'never', ['languageDefined', 'quotes', 'brackets', 'never'] as const)),
A
Alex Dima 已提交
2275 2276 2277
	codeLens: registerEditorOption(new EditorBooleanOption(EditorOption.codeLens, 'codeLens', true)),
	colorDecorators: registerEditorOption(new EditorBooleanOption(EditorOption.colorDecorators, 'colorDecorators', true)),
	contextmenu: registerEditorOption(new EditorBooleanOption(EditorOption.contextmenu, 'contextmenu', true)),
A
Alex Dima 已提交
2278
	copyWithSyntaxHighlighting: registerEditorOption(new EditorBooleanOption(EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true)),
A
Alex Dima 已提交
2279
	cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', TextEditorCursorBlinkingStyle.Blink, ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)),
A
Alex Dima 已提交
2280
	cursorSmoothCaretAnimation: registerEditorOption(new EditorBooleanOption(EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false)),
A
Alex Dima 已提交
2281
	cursorStyle: registerEditorOption(new EditorEnumOption(EditorOption.cursorStyle, 'cursorStyle', TextEditorCursorStyle.Line, ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString)),
A
Alex Dima 已提交
2282 2283 2284 2285 2286 2287
	cursorSurroundingLines: registerEditorOption(new EditorIntOption(EditorOption.cursorSurroundingLines, 'cursorSurroundingLines', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
	cursorWidth: registerEditorOption(new EditorIntOption(EditorOption.cursorWidth, 'cursorWidth', 0, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
	disableLayerHinting: registerEditorOption(new EditorBooleanOption(EditorOption.disableLayerHinting, 'disableLayerHinting', false)),
	dragAndDrop: registerEditorOption(new EditorBooleanOption(EditorOption.dragAndDrop, 'dragAndDrop', true)),
	emptySelectionClipboard: registerEditorOption(new EditorEmptySelectionClipboard(EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true)),
	extraEditorClassName: registerEditorOption(new EditorStringOption(EditorOption.extraEditorClassName, 'extraEditorClassName', '')),
A
renames  
Alex Dima 已提交
2288
	fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))),
A
Alex Dima 已提交
2289 2290 2291 2292 2293 2294
	find: registerEditorOption(new EditorFind(EditorOption.find, 'find', {
		seedSearchStringFromSelection: true,
		autoFindInSelection: false,
		globalFindClipboard: false,
		addExtraSpaceOnTop: true
	})),
A
Alex Dima 已提交
2295
	fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)),
A
renames  
Alex Dima 已提交
2296
	folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)),
A
Alex Dima 已提交
2297
	foldingStrategy: registerEditorOption(new EditorStringEnumOption(EditorOption.foldingStrategy, 'foldingStrategy', 'auto' as 'auto' | 'indentation', ['auto', 'indentation'] as const)),
2298
	fontFamily: registerEditorOption(new EditorStringOption(EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily)),
A
Alex Dima 已提交
2299
	fontInfo: registerEditorOption(new EditorFontInfo(EditorOption.fontInfo)),
A
Alex Dima 已提交
2300
	fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)),
A
Alex Dima 已提交
2301
	fontSize: registerEditorOption(new EditorFontSize(EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize)),
2302
	fontWeight: registerEditorOption(new EditorStringOption(EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight)),
A
Alex Dima 已提交
2303 2304
	formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)),
	formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)),
A
renames  
Alex Dima 已提交
2305
	glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)),
A
Alex Dima 已提交
2306 2307 2308
	gotoLocation: registerEditorOption(new EditorGoToLocation(EditorOption.gotoLocation, 'gotoLocation', {
		multiple: 'peek'
	})),
A
Alex Dima 已提交
2309 2310
	hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)),
	highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)),
A
Alex Dima 已提交
2311 2312 2313 2314 2315
	hover: registerEditorOption(new EditorHover(EditorOption.hover, 'hover', {
		enabled: true,
		delay: 300,
		sticky: true
	})),
A
renames  
Alex Dima 已提交
2316
	inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)),
2317
	letterSpacing: registerEditorOption(new EditorFloatOption(EditorOption.letterSpacing, 'letterSpacing', EDITOR_FONT_DEFAULTS.letterSpacing, x => _clamp(x, -5, 20))),
A
Alex Dima 已提交
2318 2319 2320
	lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', {
		enabled: true
	})),
A
Alex Dima 已提交
2321
	lineDecorationsWidth: registerEditorOption(new SimpleEditorOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10 as number | string)),
2322
	lineHeight: registerEditorOption(new EditorLineHeight(EditorOption.lineHeight, 'lineHeight', EDITOR_FONT_DEFAULTS.lineHeight, 0, 150)),
A
Alex Dima 已提交
2323
	lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })),
A
renames  
Alex Dima 已提交
2324
	lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)),
A
Alex Dima 已提交
2325 2326 2327
	links: registerEditorOption(new EditorBooleanOption(EditorOption.links, 'links', true)),
	matchBrackets: registerEditorOption(new EditorBooleanOption(EditorOption.matchBrackets, 'matchBrackets', true)),
	minimap: registerEditorOption(new EditorMinimap(EditorOption.minimap, 'minimap', {
A
Alex Dima 已提交
2328 2329 2330 2331 2332 2333
		enabled: true,
		side: 'right',
		showSlider: 'mouseover',
		renderCharacters: true,
		maxColumn: 120,
	})),
A
Alex Dima 已提交
2334
	mouseStyle: registerEditorOption(new EditorStringEnumOption(EditorOption.mouseStyle, 'mouseStyle', 'text' as 'text' | 'default' | 'copy', ['text', 'default', 'copy'] as const)),
A
renames  
Alex Dima 已提交
2335
	mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))),
A
Alex Dima 已提交
2336 2337
	mouseWheelZoom: registerEditorOption(new EditorBooleanOption(EditorOption.mouseWheelZoom, 'mouseWheelZoom', false)),
	multiCursorMergeOverlapping: registerEditorOption(new EditorBooleanOption(EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true)),
A
Alex Dima 已提交
2338
	multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'altKey', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)),
A
Alex Dima 已提交
2339
	occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)),
A
Alex Dima 已提交
2340 2341
	overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)),
	overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)),
A
Alex Dima 已提交
2342 2343 2344 2345 2346 2347 2348 2349 2350
	parameterHints: registerEditorOption(new EditorParameterHints(EditorOption.parameterHints, 'parameterHints', {
		enabled: true,
		cycle: false
	})),
	quickSuggestions: registerEditorOption(new EditorQuickSuggestions(EditorOption.quickSuggestions, 'quickSuggestions', {
		other: true,
		comments: false,
		strings: false
	})),
A
Alex Dima 已提交
2351
	quickSuggestionsDelay: registerEditorOption(new EditorIntOption(EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay', 10, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
A
renames  
Alex Dima 已提交
2352
	readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)),
A
Alex Dima 已提交
2353 2354
	renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)),
	renderIndentGuides: registerEditorOption(new EditorBooleanOption(EditorOption.renderIndentGuides, 'renderIndentGuides', true)),
A
renames  
Alex Dima 已提交
2355
	renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOption.renderFinalNewline, 'renderFinalNewline', true)),
A
Alex Dima 已提交
2356 2357
	renderLineHighlight: registerEditorOption(new EditorStringEnumOption(EditorOption.renderLineHighlight, 'renderLineHighlight', 'line' as 'none' | 'gutter' | 'line' | 'all', ['none', 'gutter', 'line', 'all'] as const)),
	renderWhitespace: registerEditorOption(new EditorStringEnumOption(EditorOption.renderWhitespace, 'renderWhitespace', 'none' as 'none' | 'boundary' | 'selection' | 'all', ['none', 'boundary', 'selection', 'all'] as const)),
A
Alex Dima 已提交
2358 2359 2360
	revealHorizontalRightPadding: registerEditorOption(new EditorIntOption(EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding', 30, 0, 1000)),
	roundedSelection: registerEditorOption(new EditorBooleanOption(EditorOption.roundedSelection, 'roundedSelection', true)),
	rulers: registerEditorOption(new EditorRulers(EditorOption.rulers, 'rulers', [])),
A
Alex Dima 已提交
2361
	scrollbar: registerEditorOption(new EditorScrollbar(EditorOption.scrollbar, 'scrollbar', {
A
Alex Dima 已提交
2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373
		vertical: ScrollbarVisibility.Auto,
		horizontal: ScrollbarVisibility.Auto,
		arrowSize: 11,
		useShadows: true,
		verticalHasArrows: false,
		horizontalHasArrows: false,
		horizontalScrollbarSize: 10,
		horizontalSliderSize: 10,
		verticalScrollbarSize: 14,
		verticalSliderSize: 14,
		handleMouseWheel: true,
	})),
A
Alex Dima 已提交
2374 2375
	scrollBeyondLastColumn: registerEditorOption(new EditorIntOption(EditorOption.scrollBeyondLastColumn, 'scrollBeyondLastColumn', 5, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
	scrollBeyondLastLine: registerEditorOption(new EditorBooleanOption(EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true)),
A
renames  
Alex Dima 已提交
2376
	selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)),
A
Alex Dima 已提交
2377
	selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)),
A
renames  
Alex Dima 已提交
2378
	selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)),
A
Alex Dima 已提交
2379
	showFoldingControls: registerEditorOption(new EditorStringEnumOption(EditorOption.showFoldingControls, 'showFoldingControls', 'mouseover' as 'always' | 'mouseover', ['always', 'mouseover'] as const)),
A
Alex Dima 已提交
2380
	showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)),
A
Alex Dima 已提交
2381
	snippetSuggestions: registerEditorOption(new EditorStringEnumOption(EditorOption.snippetSuggestions, 'snippetSuggestions', 'inline' as 'top' | 'bottom' | 'inline' | 'none', ['top', 'bottom', 'inline', 'none'] as const)),
A
Alex Dima 已提交
2382 2383
	smoothScrolling: registerEditorOption(new EditorBooleanOption(EditorOption.smoothScrolling, 'smoothScrolling', false)),
	stopRenderingLineAfter: registerEditorOption(new EditorIntOption(EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter', 10000, -1, Constants.MAX_SAFE_SMALL_INTEGER)),
A
Alex Dima 已提交
2384 2385
	suggestFontSize: registerEditorOption(new EditorIntOption(EditorOption.suggestFontSize, 'suggestFontSize', 0, 0, 1000)),
	suggestLineHeight: registerEditorOption(new EditorIntOption(EditorOption.suggestLineHeight, 'suggestLineHeight', 0, 0, 1000)),
A
Alex Dima 已提交
2386
	suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)),
A
Alex Dima 已提交
2387 2388
	suggestSelection: registerEditorOption(new EditorStringEnumOption(EditorOption.suggestSelection, 'suggestSelection', 'recentlyUsed' as 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'] as const)),
	tabCompletion: registerEditorOption(new EditorStringEnumOption(EditorOption.tabCompletion, 'tabCompletion', 'off' as 'on' | 'off' | 'onlySnippets', ['on', 'off', 'onlySnippets'] as const)),
A
Alex Dima 已提交
2389 2390
	useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)),
	wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)),
A
Alex Dima 已提交
2391
	wordWrap: registerEditorOption(new EditorStringEnumOption(EditorOption.wordWrap, 'wordWrap', 'off' as 'off' | 'on' | 'wordWrapColumn' | 'bounded', ['off', 'on', 'wordWrapColumn', 'bounded'] as const)),
A
renames  
Alex Dima 已提交
2392 2393 2394
	wordWrapBreakAfterCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters', ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')),
	wordWrapBreakBeforeCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')),
	wordWrapBreakObtrusiveCharacters: registerEditorOption(new EditorStringOption(EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters', '.')),
A
Alex Dima 已提交
2395
	wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)),
A
renames  
Alex Dima 已提交
2396
	wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)),
A
Alex Dima 已提交
2397
	wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', WrappingIndent.Same, ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)),
A
Alex Dima 已提交
2398

A
Alex Dima 已提交
2399
	// Leave these at the end (because they have dependencies!)
A
Alex Dima 已提交
2400 2401
	ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])),
	disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])),
A
Alex Dima 已提交
2402 2403 2404
	editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])),
	pixelRatio: registerEditorOption(new EditorPixelRatio(EditorOption.pixelRatio)),
	tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, [EditorOption.readOnly])),
A
Alex Dima 已提交
2405 2406
	suggest: registerEditorOption(new EditorSuggest(EditorOption.suggest, 'suggest', {
		filterGraceful: true,
A
Alex Dima 已提交
2407
		snippets: 'inline',
A
Alex Dima 已提交
2408 2409 2410 2411 2412 2413 2414
		snippetsPreventQuickSuggestions: true,
		localityBonus: false,
		shareSuggestSelections: false,
		showIcons: true,
		maxVisibleSuggestions: 12,
		filteredTypes: Object.create(null)
	}, [EditorOption.snippetSuggestions])),
A
Alex Dima 已提交
2415 2416
	layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])),
	wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])),
2417
};
A
Alex Dima 已提交
2418

A
renames  
Alex Dima 已提交
2419 2420
export type EditorOptionsType = typeof EditorOptions;
export type FindEditorOptionsKeyById<T extends EditorOption> = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType];
A
Alex Dima 已提交
2421
export type ComputedEditorOptionValue<T extends IEditorOption<any, any>> = T extends IEditorOption<any, infer R> ? R : never;
2422
export type FindComputedEditorOptionValueById<T extends EditorOption> = NonNullable<ComputedEditorOptionValue<EditorOptionsType[FindEditorOptionsKeyById<T>]>>;