editorOptions.ts 87.6 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
import * as nls from 'vs/nls';
A
Alex Dima 已提交
7
import * as assert from 'vs/base/common/assert';
A
Alex Dima 已提交
8 9
import * as arrays from 'vs/base/common/arrays';
import * as objects from 'vs/base/common/objects';
10
import * as platform from 'vs/base/common/platform';
11 12
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
13
import { Constants } from 'vs/editor/common/core/uint';
14
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
15
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
16
import { isObject } from 'vs/base/common/types';
17 18 19 20 21 22 23 24 25 26 27 28 29 30

/**
 * 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 已提交
31
	vertical?: 'auto' | 'visible' | 'hidden';
32 33 34 35
	/**
	 * Render horizontal scrollbar.
	 * Defaults to 'auto'.
	 */
A
Alex Dima 已提交
36
	horizontal?: 'auto' | 'visible' | 'hidden';
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 76 77 78
	/**
	 * 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;
}

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

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

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

112 113 114 115 116
/**
 * Configuration options for typing over closing quotes or brackets
 */
export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never';

117 118 119 120 121 122
/**
 * Configuration options for editor minimap
 */
export interface IEditorMinimapOptions {
	/**
	 * Enable the rendering of the minimap.
123
	 * Defaults to true.
124 125
	 */
	enabled?: boolean;
126 127 128 129 130
	/**
	 * Control the side of the minimap in editor.
	 * Defaults to 'right'.
	 */
	side?: 'right' | 'left';
131 132 133 134 135
	/**
	 * Control the rendering of the minimap slider.
	 * Defaults to 'mouseover'.
	 */
	showSlider?: 'always' | 'mouseover';
136 137 138 139 140 141 142 143 144 145 146 147
	/**
	 * 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;
}

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

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

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
/**
 * 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;
}

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

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

234 235 236 237 238 239 240
/**
 * Configuration map for codeActionsOnSave
 */
export interface ICodeActionsOnSaveOptions {
	[kind: string]: boolean;
}

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 271 272 273 274 275
/**
 * Configuration options for the editor.
 */
export interface IEditorOptions {
	/**
	 * This editor is used inside a diff editor.
	 * @internal
	 */
	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 已提交
276
	lineNumbers?: LineNumbersType;
P
Peng Lyu 已提交
277
	/**
278
	 * Controls the minimal number of visible leading and trailing lines surrounding the cursor.
P
Peng Lyu 已提交
279 280
	 * Defaults to 0.
	*/
281
	cursorSurroundingLines?: number;
A
Alex Dima 已提交
282 283
	/**
	 * Render last line number when the file ends with a newline.
A
Alex Dima 已提交
284
	 * Defaults to true.
285
	*/
A
Alex Dima 已提交
286
	renderFinalNewline?: boolean;
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 316 317 318 319 320
	/**
	 * 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;
	/**
321
	 * Class name to be added to the editor.
322
	 */
323
	extraEditorClassName?: string;
324 325 326 327 328 329 330 331 332 333 334 335 336
	/**
	 * 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;
337 338 339 340
	/**
	 * Control the behavior of the find widget.
	 */
	find?: IEditorFindOptions;
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
	/**
	 * 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 已提交
360
	cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
361 362 363 364 365 366 367 368 369 370 371
	/**
	 * 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'
	 * @internal
	 */
	mouseStyle?: 'text' | 'default' | 'copy';
372 373 374 375 376
	/**
	 * Enable smooth caret animation.
	 * Defaults to false.
	 */
	cursorSmoothCaretAnimation?: boolean;
377 378 379 380
	/**
	 * Control the cursor style, either 'block' or 'line'.
	 * Defaults to 'line'.
	 */
A
Alex Dima 已提交
381
	cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
382 383 384
	/**
	 * Control the width of the cursor when cursorStyle is set to 'line'
	 */
385
	cursorWidth?: number;
386 387 388 389 390 391
	/**
	 * Enable font ligatures.
	 * Defaults to false.
	 */
	fontLigatures?: boolean;
	/**
392 393
	 * 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.
394 395
	 * Defaults to false.
	 */
396
	disableLayerHinting?: boolean;
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
	/**
	 * 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;
412 413 414 415 416
	/**
	 * Enable that scrolling can go beyond the last column by a number of columns.
	 * Defaults to 5.
	 */
	scrollBeyondLastColumn?: number;
417 418
	/**
	 * Enable that the editor animates scrolling to a position.
419
	 * Defaults to false.
420 421
	 */
	smoothScrolling?: boolean;
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
	/**
	 * 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;
	/**
452
	 * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
453 454
	 * Defaults to 'same' in vscode and to 'none' in monaco-editor.
	 */
A
Alex Dima 已提交
455
	wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
	/**
	 * 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 已提交
479
	 * Configure the editor's hover.
480
	 */
A
Alex Dima 已提交
481
	hover?: IEditorHoverOptions;
482 483 484 485 486
	/**
	 * Enable detecting links and making them clickable.
	 * Defaults to true.
	 */
	links?: boolean;
487
	/**
488
	 * Enable inline color decorators and color picker rendering.
489
	 */
R
rebornix 已提交
490
	colorDecorators?: boolean;
491 492 493 494 495 496 497 498 499 500
	/**
	 * 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 已提交
501
	/**
502 503
	 * FastScrolling mulitplier speed when pressing `Alt`
	 * Defaults to 5.
T
Tiago Ribeiro 已提交
504 505
	 */
	fastScrollSensitivity?: number;
506 507 508 509
	/**
	 * The modifier to be used to add multiple cursors with the mouse.
	 * Defaults to 'alt'
	 */
510
	multiCursorModifier?: 'ctrlCmd' | 'alt';
511
	/**
A
Alex Dima 已提交
512
	 * Merge overlapping selections.
513 514
	 * Defaults to true
	 */
A
Alex Dima 已提交
515
	multiCursorMergeOverlapping?: boolean;
516 517 518 519 520
	/**
	 * Configure the editor's accessibility support.
	 * Defaults to 'auto'. It is best to leave this to 'auto'.
	 */
	accessibilitySupport?: 'auto' | 'off' | 'on';
521 522 523 524
	/**
	 * Suggest options.
	 */
	suggest?: ISuggestOptions;
525 526 527 528
	/**
	 *
	 */
	gotoLocation?: IGotoLocationOptions;
529 530 531 532 533 534 535
	/**
	 * Enable quick suggestions (shadow suggestions)
	 * Defaults to true.
	 */
	quickSuggestions?: boolean | { other: boolean, comments: boolean, strings: boolean };
	/**
	 * Quick suggestions show delay (in ms)
A
Alex Dima 已提交
536
	 * Defaults to 10 (ms)
537 538 539
	 */
	quickSuggestionsDelay?: number;
	/**
540
	 * Parameter hint options.
541
	 */
542
	parameterHints?: IEditorParameterHintOptions;
543
	/**
544
	 * Options for auto closing brackets.
545
	 * Defaults to language defined behavior.
546
	 */
J
Jackson Kearl 已提交
547
	autoClosingBrackets?: EditorAutoClosingStrategy;
548
	/**
549
	 * Options for auto closing quotes.
550
	 * Defaults to language defined behavior.
J
Jackson Kearl 已提交
551 552
	 */
	autoClosingQuotes?: EditorAutoClosingStrategy;
553 554 555 556
	/**
	 * Options for typing over closing quotes or brackets.
	 */
	autoClosingOvertype?: EditorAutoClosingOvertypeStrategy;
J
Jackson Kearl 已提交
557
	/**
558 559
	 * Options for auto surrounding.
	 * Defaults to always allowing auto surrounding.
560
	 */
561
	autoSurround?: EditorAutoSurroundStrategy;
562 563 564 565 566
	/**
	 * Enable auto indentation adjustment.
	 * Defaults to false.
	 */
	autoIndent?: boolean;
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
	/**
	 * 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.
589
	 * Defaults to 'on'.
590
	 */
A
Alex Dima 已提交
591
	acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
592 593 594 595 596 597 598 599 600 601 602 603 604
	/**
	 * 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;
605
	/**
606
	 * Syntax highlighting is copied.
607
	 */
608
	copyWithSyntaxHighlighting?: boolean;
609 610 611 612
	/**
	 * Enable word based suggestions. Defaults to 'true'
	 */
	wordBasedSuggestions?: boolean;
613 614 615
	/**
	 * The history mode for suggestions.
	 */
M
Martin Aeschlimann 已提交
616
	suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
617 618 619 620 621 622 623 624 625 626
	/**
	 * 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;
627 628 629
	/**
	 * Enable tab completion.
	 */
630
	tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets';
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
	/**
	 * 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;
646 647 648 649
	/**
	 * Control the behavior and rendering of the code action lightbulb.
	 */
	lightbulb?: IEditorLightbulbOptions;
650 651 652 653 654 655 656 657
	/**
	 * Code action kinds to be run on save.
	 */
	codeActionsOnSave?: ICodeActionsOnSaveOptions;
	/**
	 * Timeout for running code actions on save.
	 */
	codeActionsOnSaveTimeout?: number;
658 659
	/**
	 * Enable code folding
A
Alex Dima 已提交
660
	 * Defaults to true.
661 662
	 */
	folding?: boolean;
663 664 665 666 667
	/**
	 * 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';
668
	/**
669 670
	 * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
	 * Defaults to 'mouseover'.
671
	 */
672
	showFoldingControls?: 'always' | 'mouseover';
673 674 675 676 677 678 679 680 681
	/**
	 * Enable highlighting of matching brackets.
	 * Defaults to true.
	 */
	matchBrackets?: boolean;
	/**
	 * Enable rendering of whitespace.
	 * Defaults to none.
	 */
682
	renderWhitespace?: 'none' | 'boundary' | 'selection' | 'all';
683 684 685 686 687 688 689
	/**
	 * Enable rendering of control characters.
	 * Defaults to false.
	 */
	renderControlCharacters?: boolean;
	/**
	 * Enable rendering of indent guides.
690
	 * Defaults to true.
691 692
	 */
	renderIndentGuides?: boolean;
693
	/**
C
typo  
Coenraad Stijne 已提交
694
	 * Enable highlighting of the active indent guide.
695 696 697
	 * Defaults to true.
	 */
	highlightActiveIndentGuide?: boolean;
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
	/**
	 * 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
	 */
	fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
	/**
	 * The font size
	 */
	fontSize?: number;
	/**
	 * The line height
	 */
	lineHeight?: number;
723 724 725 726
	/**
	 * The letter spacing
	 */
	letterSpacing?: number;
727 728 729 730
	/**
	 * Controls fading out of unused variables.
	 */
	showUnused?: boolean;
A
Alex Dima 已提交
731

A
Alex Dima 已提交
732 733 734 735 736
	/**
	 * Do not use.
	 * @internal
	 */
	editorClassName?: undefined;
737 738 739 740 741 742 743 744 745
	/**
	 * Do not use.
	 * @internal
	 */
	tabFocusMode?: undefined;
	/**
	 * Do not use.
	 * @internal
	 */
A
Alex Dima 已提交
746
	layoutInfo?: undefined;
747 748 749 750
	/**
	 * Do not use.
	 * @internal
	 */
A
Alex Dima 已提交
751
	wrappingInfo?: undefined;
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 777 778 779 780 781 782 783 784
}

/**
 * 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;
}

785
export const enum RenderMinimap {
786 787 788 789 790 791 792 793 794 795
	None = 0,
	Small = 1,
	Large = 2,
	SmallBlocks = 3,
	LargeBlocks = 4,
}

/**
 * Describes how to indent wrapped lines.
 */
796
export const enum WrappingIndent {
797 798 799 800 801 802 803 804 805
	/**
	 * No indentation => wrapped lines begin at column 1.
	 */
	None = 0,
	/**
	 * Same => wrapped lines get the same indentation as the parent.
	 */
	Same = 1,
	/**
806
	 * Indent => wrapped lines get +1 indentation toward the parent.
807
	 */
808 809 810
	Indent = 2,
	/**
	 * DeepIndent => wrapped lines get +2 indentation toward the parent.
811
	 */
812
	DeepIndent = 3
813 814 815 816 817
}

/**
 * The kind of animation in which the editor's cursor should be rendered.
 */
818
export const enum TextEditorCursorBlinkingStyle {
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 870 871 872 873 874 875 876 877
	/**
	 * 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 已提交
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' {
	switch (cursorStyle) {
		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';
	}
}

function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle {
	switch (cursorStyle) {
		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 已提交
909 910 911
	}
}

912 913
export interface InternalEditorFindOptions {
	readonly seedSearchStringFromSelection: boolean;
R
rebornix 已提交
914
	readonly autoFindInSelection: boolean;
915
	readonly addExtraSpaceOnTop: boolean;
916 917 918 919
	/**
	 * @internal
	 */
	readonly globalFindClipboard: boolean;
920 921
}

A
Alex Dima 已提交
922 923
export interface InternalEditorHoverOptions {
	readonly enabled: boolean;
924
	readonly delay: number;
925
	readonly sticky: boolean;
A
Alex Dima 已提交
926 927
}

928
export interface InternalGoToLocationOptions {
J
Johannes Rieken 已提交
929
	readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
930 931
}

932 933
export interface InternalSuggestOptions {
	readonly filterGraceful: boolean;
934
	readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
935
	readonly snippetsPreventQuickSuggestions: boolean;
J
Johannes Rieken 已提交
936
	readonly localityBonus: boolean;
J
Johannes Rieken 已提交
937
	readonly shareSuggestSelections: boolean;
938
	readonly showIcons: boolean;
J
Johannes Rieken 已提交
939
	readonly maxVisibleSuggestions: number;
940
	readonly filteredTypes: Record<string, boolean>;
941 942
}

943 944 945 946 947
export interface InternalParameterHintOptions {
	readonly enabled: boolean;
	readonly cycle: boolean;
}

A
Alex Dima 已提交
948
export interface EditorContribOptions {
A
Alex Dima 已提交
949
	readonly hover: InternalEditorHoverOptions;
950
	readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
951
	readonly parameterHints: InternalParameterHintOptions;
B
Benas Svipas 已提交
952
	readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
953 954
	readonly suggestFontSize: number;
	readonly suggestLineHeight: number;
955
	readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
956
	readonly suggest: InternalSuggestOptions;
957
	readonly gotoLocation: InternalGoToLocationOptions;
958
	readonly foldingStrategy: 'auto' | 'indentation';
959
	readonly showFoldingControls: 'always' | 'mouseover';
960
	readonly find: InternalEditorFindOptions;
961 962
	readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
	readonly codeActionsOnSaveTimeout: number;
963 964
}

965 966 967 968 969 970 971 972 973
/**
 * Validated configuration options for the editor.
 * This is a 1 to 1 validated/parsed version of IEditorOptions merged on top of the defaults.
 * @internal
 */
export interface IValidatedEditorOptions {
	readonly contribInfo: EditorContribOptions;
}

974 975 976 977 978 979
/**
 * Internal configuration options (transformed or computed) for the editor.
 */
export class InternalEditorOptions {
	readonly _internalEditorOptionsBrand: void;

980
	readonly pixelRatio: number;
A
Alex Dima 已提交
981
	readonly lineHeight: number;
A
Alex Dima 已提交
982

983 984 985 986 987 988 989 990
	// ---- grouped options
	readonly fontInfo: FontInfo;
	readonly contribInfo: EditorContribOptions;

	/**
	 * @internal
	 */
	constructor(source: {
991
		pixelRatio: number;
992 993 994 995
		lineHeight: number;
		fontInfo: FontInfo;
		contribInfo: EditorContribOptions;
	}) {
996
		this.pixelRatio = source.pixelRatio;
997
		this.lineHeight = source.lineHeight | 0;
998 999
		this.fontInfo = source.fontInfo;
		this.contribInfo = source.contribInfo;
1000 1001 1002 1003 1004 1005 1006
	}

	/**
	 * @internal
	 */
	public equals(other: InternalEditorOptions): boolean {
		return (
A
Alex Dima 已提交
1007
			this.pixelRatio === other.pixelRatio
A
Alex Dima 已提交
1008
			&& this.lineHeight === other.lineHeight
1009
			&& this.fontInfo.equals(other.fontInfo)
A
Alex Dima 已提交
1010
			&& InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo)
1011 1012 1013 1014 1015 1016
		);
	}

	/**
	 * @internal
	 */
1017
	public createChangeEvent(newOpts: InternalEditorOptions, changeEvent: ChangedEditorOptions | null): IConfigurationChangedEvent {
1018
		return {
A
renames  
Alex Dima 已提交
1019
			hasChanged: (id: EditorOption) => {
1020 1021 1022 1023 1024
				if (!changeEvent) {
					return false;
				}
				return changeEvent.get(id);
			},
1025
			pixelRatio: (this.pixelRatio !== newOpts.pixelRatio),
1026 1027
			lineHeight: (this.lineHeight !== newOpts.lineHeight),
			fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
1028
			contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo))
1029 1030 1031
		};
	}

1032 1033 1034 1035 1036 1037
	/**
	 * @internal
	 */
	private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
		return (
			a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
R
rebornix 已提交
1038
			&& a.autoFindInSelection === b.autoFindInSelection
1039
			&& a.globalFindClipboard === b.globalFindClipboard
1040
			&& a.addExtraSpaceOnTop === b.addExtraSpaceOnTop
1041 1042 1043
		);
	}

1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
	/**
	 * @internal
	 */
	private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
		return (
			a.enabled === b.enabled
			&& a.cycle === b.cycle
		);
	}

A
Alex Dima 已提交
1054 1055 1056 1057 1058 1059
	/**
	 * @internal
	 */
	private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
		return (
			a.enabled === b.enabled
1060
			&& a.delay === b.delay
1061
			&& a.sticky === b.sticky
A
Alex Dima 已提交
1062 1063 1064
		);
	}

1065 1066 1067
	/**
	 * @internal
	 */
1068
	private static _equalsSuggestOptions(a: InternalSuggestOptions, b: InternalSuggestOptions): any {
1069 1070 1071 1072 1073
		if (a === b) {
			return true;
		} else if (!a || !b) {
			return false;
		} else {
1074 1075
			return a.filterGraceful === b.filterGraceful
				&& a.snippets === b.snippets
J
Johannes Rieken 已提交
1076
				&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
1077
				&& a.localityBonus === b.localityBonus
1078 1079
				&& a.shareSuggestSelections === b.shareSuggestSelections
				&& a.showIcons === b.showIcons
J
Johannes Rieken 已提交
1080 1081
				&& a.maxVisibleSuggestions === b.maxVisibleSuggestions
				&& objects.equals(a.filteredTypes, b.filteredTypes);
1082 1083 1084
		}
	}

1085 1086 1087 1088 1089 1090
	private static _equalsGotoLocationOptions(a: InternalGoToLocationOptions | undefined, b: InternalGoToLocationOptions | undefined): boolean {
		if (a === b) {
			return true;
		} else if (!a || !b) {
			return false;
		} else {
J
Johannes Rieken 已提交
1091
			return a.multiple === b.multiple;
1092 1093 1094
		}
	}

1095 1096 1097
	/**
	 * @internal
	 */
A
Alex Dima 已提交
1098 1099
	private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
		return (
A
Alex Dima 已提交
1100
			this._equalsHoverOptions(a.hover, b.hover)
A
Alex Dima 已提交
1101
			&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
1102
			&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
J
Johannes Rieken 已提交
1103
			&& a.suggestSelection === b.suggestSelection
A
Alex Dima 已提交
1104 1105
			&& a.suggestFontSize === b.suggestFontSize
			&& a.suggestLineHeight === b.suggestLineHeight
1106
			&& a.tabCompletion === b.tabCompletion
1107
			&& this._equalsSuggestOptions(a.suggest, b.suggest)
1108
			&& InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation)
1109
			&& a.foldingStrategy === b.foldingStrategy
1110
			&& a.showFoldingControls === b.showFoldingControls
1111
			&& this._equalFindOptions(a.find, b.find)
1112 1113
			&& objects.equals(a.codeActionsOnSave, b.codeActionsOnSave)
			&& a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout
A
Alex Dima 已提交
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
		);
	}

	private static _equalsQuickSuggestions(a: boolean | { other: boolean, comments: boolean, strings: boolean }, b: boolean | { other: boolean, comments: boolean, strings: boolean }): boolean {
		if (typeof a === 'boolean') {
			if (typeof b !== 'boolean') {
				return false;
			}
			return a === b;
		}
		if (typeof b === 'boolean') {
			return false;
		}
1127
		return (
A
Alex Dima 已提交
1128 1129 1130
			a.comments === b.comments
			&& a.other === b.other
			&& a.strings === b.strings
1131 1132 1133 1134 1135 1136 1137 1138
		);
	}
}

/**
 * An event describing that the configuration of the editor has changed.
 */
export interface IConfigurationChangedEvent {
A
renames  
Alex Dima 已提交
1139
	hasChanged(id: EditorOption): boolean;
1140
	readonly pixelRatio: boolean;
1141 1142 1143 1144
	readonly lineHeight: boolean;
	readonly fontInfo: boolean;
	readonly contribInfo: boolean;
}
1145

A
Alex Dima 已提交
1146 1147 1148 1149
export interface IEnvironmentalOptions {
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
1150
	readonly extraEditorClassName: string;
A
Alex Dima 已提交
1151 1152
	readonly isDominatedByLongLines: boolean;
	readonly lineNumbersDigitCount: number;
1153
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
1154 1155
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
1156
	readonly accessibilitySupport: AccessibilitySupport;
1157
}
1158

1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
function _boolean<T>(value: any, defaultValue: T): boolean | T {
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	if (value === 'false') {
		// treat the string 'false' as false
		return false;
	}
	return Boolean(value);
}
1169

A
Alex Dima 已提交
1170
function _booleanMap(value: { [key: string]: boolean } | undefined, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
	if (!value) {
		return defaultValue;
	}

	const out = Object.create(null);
	for (const k of Object.keys(value)) {
		const v = value[k];
		if (typeof v === 'boolean') {
			out[k] = v;
		}
	}
	return out;
}

1185 1186 1187 1188 1189 1190
function _string(value: any, defaultValue: string): string {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	return value;
}
1191

A
Alex Dima 已提交
1192
function _stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: T[]): T {
1193 1194 1195 1196 1197 1198
	if (typeof value !== 'string') {
		return defaultValue;
	}
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
	}
M
Martin Aeschlimann 已提交
1199
	return value;
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
}

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;
1210
		}
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224
	}
	r = Math.max(minimum, r);
	r = Math.min(maximum, r);
	return r | 0;
}

function _float(value: any, defaultValue: number): number {
	let r = parseFloat(value);
	if (isNaN(r)) {
		r = defaultValue;
	}
	return r;
}

A
Alex Dima 已提交
1225 1226 1227 1228 1229 1230
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;
1231 1232 1233
	}
}

A
Alex Dima 已提交
1234
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle {
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248
	switch (cursorBlinkingStyle) {
		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;
	}
}

A
Alex Dima 已提交
1249
function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272
	if (typeof visibility !== 'string') {
		return defaultValue;
	}
	switch (visibility) {
		case 'hidden':
			return ScrollbarVisibility.Hidden;
		case 'visible':
			return ScrollbarVisibility.Visible;
		default:
			return ScrollbarVisibility.Auto;
	}
}

/**
 * @internal
 */
export class EditorOptionsValidator {

	/**
	 * Validate raw editor options.
	 * i.e. since they can be defined by the user, they might be invalid.
	 */
	public static validate(opts: IEditorOptions, defaults: IValidatedEditorOptions): IValidatedEditorOptions {
1273
		const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
A
Alex Dima 已提交
1274 1275 1276 1277 1278
		return {
			contribInfo: contribInfo,
		};
	}

A
Alex Dima 已提交
1279
	private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
1280 1281 1282 1283 1284
		if (typeof opts !== 'object') {
			return defaults;
		}

		return {
R
rebornix 已提交
1285
			seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
1286
			autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection),
1287 1288
			globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard),
			addExtraSpaceOnTop: _boolean(opts.addExtraSpaceOnTop, defaults.addExtraSpaceOnTop)
1289 1290 1291
		};
	}

A
Alex Dima 已提交
1292
	private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions | undefined, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
		if (typeof opts !== 'object') {
			return defaults;
		}

		return {
			enabled: _boolean(opts.enabled, defaults.enabled),
			cycle: _boolean(opts.cycle, defaults.cycle)
		};
	}

B
bissonex 已提交
1303
	private static _sanitizeHoverOpts(_opts: boolean | IEditorHoverOptions | undefined, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
A
Alex Dima 已提交
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315
		let opts: IEditorHoverOptions;
		if (typeof _opts === 'boolean') {
			opts = {
				enabled: _opts
			};
		} else if (typeof _opts === 'object') {
			opts = _opts;
		} else {
			return defaults;
		}

		return {
1316
			enabled: _boolean(opts.enabled, defaults.enabled),
1317 1318
			delay: _clampedInt(opts.delay, defaults.delay, 0, 10000),
			sticky: _boolean(opts.sticky, defaults.sticky)
A
Alex Dima 已提交
1319 1320 1321
		};
	}

1322
	private static _sanitizeSuggestOpts(opts: IEditorOptions, defaults: InternalSuggestOptions): InternalSuggestOptions {
1323
		const suggestOpts = opts.suggest || {};
1324
		return {
1325
			filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful),
1326
			snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
1327
			snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
J
Johannes Rieken 已提交
1328
			localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
1329 1330
			shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
			showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
J
Johannes Rieken 已提交
1331
			maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 15),
1332
			filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null)
1333 1334 1335
		};
	}

T
Tony Xia 已提交
1336
	private static _sanitizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions {
1337 1338
		const gotoOpts = opts.gotoLocation || {};
		return {
J
Johannes Rieken 已提交
1339
			multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(gotoOpts.multiple, defaults.multiple, ['peek', 'gotoAndPeek', 'goto'])
1340 1341 1342
		};
	}

A
Alex Dima 已提交
1343
	private static _sanitizeTabCompletionOpts(opts: boolean | 'on' | 'off' | 'onlySnippets' | undefined, defaults: 'on' | 'off' | 'onlySnippets'): 'on' | 'off' | 'onlySnippets' {
1344 1345 1346 1347 1348 1349 1350 1351
		if (opts === false) {
			return 'off';
		} else if (opts === true) {
			return 'onlySnippets';
		} else {
			return _stringSet<'on' | 'off' | 'onlySnippets'>(opts, defaults, ['on', 'off', 'onlySnippets']);
		}
	}
1352

1353
	private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions {
A
Alex Dima 已提交
1354 1355 1356 1357 1358 1359
		let quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
		if (typeof opts.quickSuggestions === 'object') {
			quickSuggestions = { other: true, ...opts.quickSuggestions };
		} else {
			quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions);
		}
B
bissonex 已提交
1360
		const find = this._sanitizeFindOpts(opts.find, defaults.find);
A
Alex Dima 已提交
1361
		return {
B
bissonex 已提交
1362
			hover: this._sanitizeHoverOpts(opts.hover, defaults.hover),
1363
			quickSuggestions: quickSuggestions,
1364
			parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
B
Benas Svipas 已提交
1365
			suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']),
1366 1367
			suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
			suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
1368
			tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion),
1369
			suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
T
Tony Xia 已提交
1370
			gotoLocation: this._sanitizeGotoLocationOpts(opts, defaults.gotoLocation),
1371
			foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']),
1372
			showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
1373
			find: find,
1374 1375
			codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}),
			codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000)
1376 1377 1378 1379 1380 1381 1382 1383 1384
		};
	}
}

/**
 * @internal
 */
export class InternalEditorOptionsFactory {

A
Alex Dima 已提交
1385
	public static createInternalEditorOptions(env: IEnvironmentalOptions, opts: IValidatedEditorOptions) {
1386
		return new InternalEditorOptions({
1387
			pixelRatio: env.pixelRatio,
A
Alex Dima 已提交
1388
			lineHeight: env.fontInfo.lineHeight,
1389
			fontInfo: env.fontInfo,
1390
			contribInfo: opts.contribInfo,
1391 1392 1393 1394 1395 1396 1397 1398
		});
	}
}

/**
 * @internal
 */
export interface IEditorLayoutProviderOpts {
M
Matt Bierner 已提交
1399 1400
	readonly outerWidth: number;
	readonly outerHeight: number;
1401

M
Matt Bierner 已提交
1402 1403
	readonly showGlyphMargin: boolean;
	readonly lineHeight: number;
1404

M
Matt Bierner 已提交
1405 1406 1407
	readonly showLineNumbers: boolean;
	readonly lineNumbersMinChars: number;
	readonly lineNumbersDigitCount: number;
1408

M
Matt Bierner 已提交
1409
	readonly lineDecorationsWidth: number;
1410

M
Matt Bierner 已提交
1411 1412
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
1413

M
Matt Bierner 已提交
1414 1415 1416 1417
	readonly verticalScrollbarWidth: number;
	readonly verticalScrollbarHasArrows: boolean;
	readonly scrollbarArrowSize: number;
	readonly horizontalScrollbarHeight: number;
1418

M
Matt Bierner 已提交
1419 1420 1421 1422 1423
	readonly minimap: boolean;
	readonly minimapSide: string;
	readonly minimapRenderCharacters: boolean;
	readonly minimapMaxColumn: number;
	readonly pixelRatio: number;
1424 1425
}

A
Alex Dima 已提交
1426 1427 1428 1429
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\'';

1430 1431 1432
/**
 * @internal
 */
A
Alex Dima 已提交
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
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,
};
1444

A
Alex Dima 已提交
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
	indentSize: 4,
	insertSpaces: true,
	detectIndentation: true,
	trimAutoWhitespace: true,
	largeFileOptimizations: true
};
1456

A
Alex Dima 已提交
1457 1458 1459 1460
/**
 * @internal
 */
export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
A
Alex Dima 已提交
1461
	contribInfo: {
A
Alex Dima 已提交
1462
		hover: {
1463
			enabled: true,
1464 1465
			delay: 300,
			sticky: true
A
Alex Dima 已提交
1466
		},
A
Alex Dima 已提交
1467 1468 1469 1470 1471
		quickSuggestions: {
			other: true,
			comments: false,
			strings: false
		},
1472 1473 1474 1475
		parameterHints: {
			enabled: true,
			cycle: false
		},
B
Benas Svipas 已提交
1476
		suggestSelection: 'recentlyUsed',
A
Alex Dima 已提交
1477 1478
		suggestFontSize: 0,
		suggestLineHeight: 0,
1479
		tabCompletion: 'off',
1480 1481
		suggest: {
			filterGraceful: true,
1482
			snippets: 'inline',
J
Johannes Rieken 已提交
1483
			snippetsPreventQuickSuggestions: true,
1484
			localityBonus: false,
1485 1486
			shareSuggestSelections: false,
			showIcons: true,
J
Johannes Rieken 已提交
1487
			maxVisibleSuggestions: 12,
1488
			filteredTypes: Object.create(null)
1489
		},
1490
		gotoLocation: {
J
Johannes Rieken 已提交
1491
			multiple: 'peek'
1492
		},
1493
		foldingStrategy: 'auto',
1494
		showFoldingControls: 'mouseover',
1495
		find: {
R
rebornix 已提交
1496
			seedSearchStringFromSelection: true,
1497
			autoFindInSelection: false,
1498 1499
			globalFindClipboard: false,
			addExtraSpaceOnTop: true
1500
		},
1501 1502
		codeActionsOnSave: {},
		codeActionsOnSaveTimeout: 750
A
Alex Dima 已提交
1503
	},
1504
};
1505

A
Alex Dima 已提交
1506
export interface IRawEditorOptionsBag extends IEditorOptions {
1507 1508 1509 1510 1511 1512 1513 1514
	[key: string]: any;
}

/**
 * @internal
 */
export class RawEditorOptions {
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
1515
	public _read<T>(id: EditorOption): T | undefined {
1516 1517
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1518
	public _write<T>(id: EditorOption, value: T | undefined): void {
1519 1520 1521 1522 1523 1524 1525 1526 1527
		this._values[id] = value;
	}
}

/**
 * @internal
 */
export class ValidatedEditorOptions {
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
1528
	public _read<T>(option: EditorOption): T {
1529 1530
		return this._values[option];
	}
A
Alex Dima 已提交
1531 1532 1533
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1534
	public _write<T>(option: EditorOption, value: T): void {
1535 1536 1537 1538
		this._values[option] = value;
	}
}

A
Alex Dima 已提交
1539
export interface IComputedEditorOptions {
A
renames  
Alex Dima 已提交
1540
	get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
A
Alex Dima 已提交
1541 1542
}

1543 1544 1545
/**
 * @internal
 */
A
Alex Dima 已提交
1546
export class ComputedEditorOptions implements IComputedEditorOptions {
1547
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
1548
	public _read<T>(id: EditorOption): T {
1549 1550
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1551
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
A
Alex Dima 已提交
1552 1553
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1554
	public _write<T>(id: EditorOption, value: T): void {
1555 1556 1557 1558 1559 1560 1561 1562 1563
		this._values[id] = value;
	}
}

/**
 * @internal
 */
export class ChangedEditorOptions {
	private readonly _values: boolean[] = [];
A
renames  
Alex Dima 已提交
1564
	public get(id: EditorOption): boolean {
1565 1566
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
1567
	public _write(id: EditorOption, value: boolean): void {
1568 1569 1570
		this._values[id] = value;
	}
}
1571 1572
type PossibleKeyName0<V> = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions];
type PossibleKeyName<V> = NonNullable<PossibleKeyName0<V>>;
1573

1574 1575 1576
export interface IEditorOption<K1 extends EditorOption, K2 extends keyof IEditorOptions, T2 = NonNullable<IEditorOptions[K2]>, T3 = T2> {
	readonly id: K1;
	readonly name: K2;
A
Alex Dima 已提交
1577
	readonly defaultValue: T2;
1578 1579 1580
	read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined;
	mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined;
	validate(input: IEditorOptions[K2] | undefined): T2;
A
Alex Dima 已提交
1581
	compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3;
1582 1583 1584
	equals(a: T3, b: T3): boolean;
}

A
Alex Dima 已提交
1585 1586 1587
/**
 * @internal
 */
A
renames  
Alex Dima 已提交
1588
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];
A
Alex Dima 已提交
1589

1590
function registerEditorOption<K1 extends EditorOption, K2 extends keyof IEditorOptions, T2, T3>(option: IEditorOption<K1, K2, T2, T3>): IEditorOption<K1, K2, T2, T3> {
A
Alex Dima 已提交
1591 1592 1593 1594
	editorOptionsRegistry[option.id] = option;
	return option;
}

1595
export abstract class BaseEditorOption<K1 extends EditorOption, K2 extends keyof IEditorOptions, T2 = IEditorOptions[K2], T3 = T2> implements IEditorOption<K1, K2, T2, T3> {
A
Alex Dima 已提交
1596

1597 1598
	public readonly id: K1;
	public readonly name: K2;
A
Alex Dima 已提交
1599
	public readonly defaultValue: T2;
1600

1601
	constructor(id: K1, name: K2, defaultValue: T2, deps: EditorOption[] = []) {
1602 1603 1604
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
A
Alex Dima 已提交
1605 1606 1607
		for (const dep of deps) {
			assert.ok(dep < id);
		}
1608
	}
1609
	public read(options: IRawEditorOptionsBag): IEditorOptions[K2] | undefined {
A
Alex Dima 已提交
1610
		return options[<any>this.name];
1611
	}
1612
	public mix(a: IEditorOptions[K2] | undefined, b: IEditorOptions[K2] | undefined): IEditorOptions[K2] | undefined {
A
Alex Dima 已提交
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622
		switch (typeof b) {
			case 'bigint': return b;
			case 'boolean': return b;
			case 'function': return b;
			case 'number': return b;
			case 'object': return (Array.isArray(b) || typeof a !== 'object' ? b : objects.mixin(objects.mixin({}, a), b));
			case 'string': return b;
			default:
				return a;
		}
1623
	}
1624
	public abstract validate(input: IEditorOptions[K2] | undefined): T2;
A
Alex Dima 已提交
1625 1626 1627 1628 1629
	public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T2): T3;
	public equals(a: T3, b: T3): boolean {
		return (a === b);
	}
}
1630

1631
class EditorBooleanOption<K1 extends EditorOption, K2 extends PossibleKeyName<boolean>> extends BaseEditorOption<K1, K2, boolean> {
1632 1633 1634
	public validate(input: boolean | undefined): boolean {
		return _boolean(input, this.defaultValue);
	}
A
Alex Dima 已提交
1635 1636 1637 1638
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
		return value;
	}
}
1639

1640
class EditorIntOption<K1 extends EditorOption, K2 extends PossibleKeyName<number>> extends BaseEditorOption<K1, K2, number> {
A
Alex Dima 已提交
1641 1642
	public readonly minimum: number;
	public readonly maximum: number;
1643
	constructor(id: K1, name: K2, defaultValue: number, minimum: number, maximum: number, deps: EditorOption[] = []) {
A
Alex Dima 已提交
1644 1645 1646 1647 1648 1649 1650 1651
		super(id, name, defaultValue, deps);
		this.minimum = minimum;
		this.maximum = maximum;
	}
	public validate(input: number | undefined): number {
		return _clampedInt(input, this.defaultValue, this.minimum, this.maximum);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
1652 1653
		return value;
	}
A
Alex Dima 已提交
1654
}
1655

1656
class EditorFloatOption<K1 extends EditorOption, K2 extends PossibleKeyName<number>> extends BaseEditorOption<K1, K2, number> {
A
Alex Dima 已提交
1657
	public readonly validationFn: (value: number) => number;
1658
	constructor(id: K1, name: K2, defaultValue: number, validationFn: (value: number) => number, deps: EditorOption[] = []) {
A
Alex Dima 已提交
1659 1660 1661 1662 1663 1664 1665 1666
		super(id, name, defaultValue, deps);
		this.validationFn = validationFn;
	}
	public validate(input: number | undefined): number {
		return this.validationFn(_float(input, this.defaultValue));
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
		return value;
1667 1668 1669
	}
}

1670
class EditorStringOption<K1 extends EditorOption, K2 extends PossibleKeyName<string>> extends BaseEditorOption<K1, K2, string> {
A
Alex Dima 已提交
1671 1672 1673 1674 1675 1676 1677
	public validate(input: string | undefined): string {
		return _string(input, this.defaultValue);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string {
		return value;
	}
}
1678

1679
class EditorEnumOption<K1 extends EditorOption, K2 extends PossibleKeyName<T1>, T1 extends string, T2 = T1> extends BaseEditorOption<K1, K2, T1, T2> {
A
Alex Dima 已提交
1680 1681
	public readonly allowedValues: T1[];
	public readonly convert: (value: T1) => T2;
1682
	constructor(id: K1, name: K2, defaultValue: T1, allowedValues: T1[], convert: (value: T1) => T2, deps: EditorOption[] = []) {
A
Alex Dima 已提交
1683 1684 1685 1686
		super(id, name, defaultValue, deps);
		this.allowedValues = allowedValues;
		this.convert = convert;
	}
1687 1688
	public validate(input: IEditorOptions[K2] | undefined): T1 {
		return _stringSet<T1>(<any>input, this.defaultValue, this.allowedValues);
A
Alex Dima 已提交
1689 1690 1691 1692 1693 1694
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: T1): T2 {
		return this.convert(value);
	}
}

1695 1696
class EditorPassthroughOption<K1 extends EditorOption, K2 extends keyof IEditorOptions> extends BaseEditorOption<K1, K2> {
	public validate(input: IEditorOptions[K2] | undefined): IEditorOptions[K2] {
A
Alex Dima 已提交
1697 1698 1699 1700 1701
		if (typeof input === 'undefined') {
			return this.defaultValue;
		}
		return input;
	}
1702
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: IEditorOptions[K2]): IEditorOptions[K2] {
A
Alex Dima 已提交
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723
		return value;
	}
}

//#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;
}

1724
class EditorRenderLineNumbersOption<K1 extends EditorOption, K2 extends PossibleKeyName<LineNumbersType>> extends BaseEditorOption<K1, K2, InternalEditorRenderLineNumbersOptions, InternalEditorRenderLineNumbersOptions> {
A
Alex Dima 已提交
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757
	public validate(lineNumbers: LineNumbersType | undefined): InternalEditorRenderLineNumbersOptions {
		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
		};
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorRenderLineNumbersOptions): InternalEditorRenderLineNumbersOptions {
		return value;
	}
	public equals(a: InternalEditorRenderLineNumbersOptions, b: InternalEditorRenderLineNumbersOptions): boolean {
		return (
			a.renderType === b.renderType
			&& a.renderFn === b.renderFn
		);
	}
1758 1759
}

A
Alex Dima 已提交
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771
//#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 已提交
1772
class EditorMinimap<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorMinimapOptions>> extends BaseEditorOption<K1, K2, InternalEditorMinimapOptions, InternalEditorMinimapOptions> {
A
Alex Dima 已提交
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
	public validate(input: IEditorMinimapOptions | undefined): InternalEditorMinimapOptions {
		if (typeof input !== 'object') {
			return this.defaultValue;
		}
		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),
		};
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorMinimapOptions): InternalEditorMinimapOptions {
		return value;
	}
	public equals(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean {
		return (
			a.enabled === b.enabled
			&& a.side === b.side
			&& a.showSlider === b.showSlider
			&& a.renderCharacters === b.renderCharacters
			&& a.maxColumn === b.maxColumn
		);
	}
}

//#endregion

//#region accessibilitySupport

1803
class EditorAccessibilitySupportOption<K1 extends EditorOption, K2 extends PossibleKeyName<'auto' | 'off' | 'on'>> extends BaseEditorOption<K1, K2, 'auto' | 'off' | 'on', AccessibilitySupport> {
A
Alex Dima 已提交
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820
	public validate(input: 'auto' | 'off' | 'on' | undefined): 'auto' | 'off' | 'on' {
		return _stringSet<'auto' | 'off' | 'on'>(input, this.defaultValue, ['auto', 'off', 'on']);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: 'auto' | 'off' | 'on'): AccessibilitySupport {
		if (value === 'auto') {
			// The editor reads the `accessibilitySupport` from the environment
			return env.accessibilitySupport;
		} else if (value === 'on') {
			return AccessibilitySupport.Enabled;
		} else {
			return AccessibilitySupport.Disabled;
		}
	}
}

//#endregion

A
Alex Dima 已提交
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844
//#region rulers

class EditorRulers<K1 extends EditorOption, K2 extends PossibleKeyName<number[]>> extends BaseEditorOption<K1, K2, number[]> {
	public validate(input: number[] | undefined): number[] {
		if (Array.isArray(input)) {
			let rulers: number[] = [];
			for (let value in input) {
				rulers.push(_clampedInt(value, 0, 0, 10000));
			}
			rulers.sort();
			return rulers;
		}
		return this.defaultValue;
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number[]): number[] {
		return value;
	}
	public equals(a: number[], b: number[]): boolean {
		return arrays.equals(a, b);
	}
}

//#endregion

A
Alex Dima 已提交
1845 1846
//#region ariaLabel

1847
class EditorAriaLabel<K1 extends EditorOption, K2 extends PossibleKeyName<string>> extends BaseEditorOption<K1, K2, string> {
A
Alex Dima 已提交
1848 1849 1850 1851
	public validate(input: string | undefined): string {
		return _string(input, this.defaultValue);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string {
A
renames  
Alex Dima 已提交
1852
		const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
A
Alex Dima 已提交
1853 1854 1855 1856 1857 1858 1859 1860 1861
		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 已提交
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 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902
//#region disableMonospaceOptimizations

class EditorDisableMonospaceOptimizations<K1 extends EditorOption, K2 extends PossibleKeyName<boolean>> extends BaseEditorOption<K1, K2, boolean> {
	public validate(input: boolean | undefined): boolean {
		return _boolean(input, this.defaultValue);
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
		return (value || options.get(EditorOption.folding));
	}
}

//#endregion

//#region editorClassName

class EditorClassName<K1 extends EditorOption, K2 extends PossibleKeyName<undefined>> extends BaseEditorOption<K1, K2, undefined, string> {
	public validate(input: undefined): undefined {
		return undefined;
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): string {
		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

1903 1904
//#region tabFocusMode

1905
class EditorTabFocusMode<K1 extends EditorOption, K2 extends PossibleKeyName<undefined>> extends BaseEditorOption<K1, K2, undefined, boolean> {
1906 1907 1908 1909
	public validate(input: undefined): undefined {
		return undefined;
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): boolean {
A
renames  
Alex Dima 已提交
1910
		const readOnly = options.get(EditorOption.readOnly);
1911 1912 1913 1914 1915 1916
		return (readOnly ? true : env.tabFocusMode);
	}
}

//#endregion

A
Alex Dima 已提交
1917
//#region emptySelectionClipboard
A
Alex Dima 已提交
1918 1919 1920 1921 1922 1923 1924 1925 1926

class EditorEmptySelectionClipboard<K1 extends EditorOption, K2 extends PossibleKeyName<boolean>> extends EditorBooleanOption<K1, K2> {
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
		return value && env.emptySelectionClipboard;
	}
}

//#endregion

A
Alex Dima 已提交
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
//#region lightbulb

export type ValidEditorLightbulbOptions = Required<IEditorLightbulbOptions>;

class EditorLightbulb<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorLightbulbOptions>> extends BaseEditorOption<K1, K2, ValidEditorLightbulbOptions> {
	public validate(input: IEditorLightbulbOptions | undefined): ValidEditorLightbulbOptions {
		if (typeof input !== 'object') {
			return this.defaultValue;
		}
		return {
			enabled: _boolean(input.enabled, this.defaultValue.enabled)
		};
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: ValidEditorLightbulbOptions): ValidEditorLightbulbOptions {
		return value;
	}
	public equals(a: ValidEditorLightbulbOptions, b: ValidEditorLightbulbOptions): boolean {
		return (
			a.enabled === b.enabled
		);
	}
}

//#endregion

A
Alex Dima 已提交
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
//#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 已提交
1968
class EditorScrollbar<K1 extends EditorOption, K2 extends PossibleKeyName<IEditorScrollbarOptions>> extends BaseEditorOption<K1, K2, InternalEditorScrollbarOptions, InternalEditorScrollbarOptions> {
A
Alex Dima 已提交
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 2077 2078 2079 2080 2081 2082 2083 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
	public validate(input: IEditorScrollbarOptions | undefined): InternalEditorScrollbarOptions {
		if (typeof input !== 'object') {
			return this.defaultValue;
		}
		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),
		};
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: InternalEditorScrollbarOptions): InternalEditorScrollbarOptions {
		return value;
	}
	public equals(a: InternalEditorScrollbarOptions, b: InternalEditorScrollbarOptions): boolean {
		return (
			a.arrowSize === b.arrowSize
			&& a.vertical === b.vertical
			&& a.horizontal === b.horizontal
			&& a.useShadows === b.useShadows
			&& a.verticalHasArrows === b.verticalHasArrows
			&& a.horizontalHasArrows === b.horizontalHasArrows
			&& a.handleMouseWheel === b.handleMouseWheel
			&& a.horizontalScrollbarSize === b.horizontalScrollbarSize
			&& a.horizontalSliderSize === b.horizontalSliderSize
			&& a.verticalScrollbarSize === b.verticalScrollbarSize
			&& a.verticalSliderSize === b.verticalSliderSize
		);
	}
}

//#endregion

//#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
 */
2138
export class EditorLayoutInfoComputer<K1 extends EditorOption, K2 extends PossibleKeyName<undefined>> extends BaseEditorOption<K1, K2, undefined, EditorLayoutInfo> {
A
Alex Dima 已提交
2139 2140 2141 2142
	public validate(input: undefined): undefined {
		return undefined;
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorLayoutInfo {
A
renames  
Alex Dima 已提交
2143 2144 2145 2146 2147 2148
		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 已提交
2149
		const lineNumbers = options.get(EditorOption.lineNumbers);
A
Alex Dima 已提交
2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166

		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 已提交
2167
			showLineNumbers: (lineNumbers.renderType !== RenderLineNumbersType.Off),
A
Alex Dima 已提交
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362
			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 equals(a: EditorLayoutInfo, b: EditorLayoutInfo): boolean {
		return (
			a.width === b.width
			&& a.height === b.height
			&& a.glyphMarginLeft === b.glyphMarginLeft
			&& a.glyphMarginWidth === b.glyphMarginWidth
			&& a.glyphMarginHeight === b.glyphMarginHeight
			&& a.lineNumbersLeft === b.lineNumbersLeft
			&& a.lineNumbersWidth === b.lineNumbersWidth
			&& a.lineNumbersHeight === b.lineNumbersHeight
			&& a.decorationsLeft === b.decorationsLeft
			&& a.decorationsWidth === b.decorationsWidth
			&& a.decorationsHeight === b.decorationsHeight
			&& a.contentLeft === b.contentLeft
			&& a.contentWidth === b.contentWidth
			&& a.contentHeight === b.contentHeight
			&& a.renderMinimap === b.renderMinimap
			&& a.minimapLeft === b.minimapLeft
			&& a.minimapWidth === b.minimapWidth
			&& a.viewportColumn === b.viewportColumn
			&& a.verticalScrollbarWidth === b.verticalScrollbarWidth
			&& a.horizontalScrollbarHeight === b.horizontalScrollbarHeight
			&& EditorLayoutInfoComputer._equalsOverviewRuler(a.overviewRuler, b.overviewRuler)
		);
	}

	private static _equalsOverviewRuler(a: OverviewRulerPosition, b: OverviewRulerPosition): boolean {
		return (
			a.width === b.width
			&& a.height === b.height
			&& a.top === b.top
			&& a.right === b.right
		);
	}

	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;
}

2363
class EditorWrappingInfoComputer<K1 extends EditorOption, K2 extends PossibleKeyName<undefined>> extends BaseEditorOption<K1, K2, undefined, EditorWrappingInfo> {
A
Alex Dima 已提交
2364 2365 2366 2367 2368 2369 2370
	public mix(a: undefined, b: undefined): undefined {
		return undefined;
	}
	public validate(input: undefined): undefined {
		return undefined;
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: undefined): EditorWrappingInfo {
A
renames  
Alex Dima 已提交
2371 2372 2373 2374 2375
		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 已提交
2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441

		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,
		};
	}
	public equals(a: EditorWrappingInfo, b: EditorWrappingInfo): boolean {
		return (
			a.isDominatedByLongLines === b.isDominatedByLongLines
			&& a.isWordWrapMinified === b.isWordWrapMinified
			&& a.isViewportWrapping === b.isViewportWrapping
			&& a.wrappingColumn === b.wrappingColumn
		);
	}
}

//#endregion

A
Alex Dima 已提交
2442 2443 2444 2445 2446 2447 2448
function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): 'altKey' | 'metaKey' | 'ctrlKey' {
	if (multiCursorModifier === 'ctrlCmd') {
		return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
	}
	return 'altKey';
}

A
renames  
Alex Dima 已提交
2449
export const enum EditorOption {
A
Alex Dima 已提交
2450 2451
	acceptSuggestionOnCommitCharacter,
	acceptSuggestionOnEnter,
A
Alex Dima 已提交
2452
	accessibilitySupport,
A
Alex Dima 已提交
2453 2454 2455 2456 2457 2458
	autoClosingBrackets,
	autoClosingOvertype,
	autoClosingQuotes,
	autoIndent,
	automaticLayout,
	autoSurround,
A
Alex Dima 已提交
2459 2460 2461
	codeLens,
	colorDecorators,
	contextmenu,
A
Alex Dima 已提交
2462 2463 2464 2465 2466 2467 2468 2469 2470 2471
	copyWithSyntaxHighlighting,
	cursorBlinking,
	cursorSmoothCaretAnimation,
	cursorStyle,
	cursorSurroundingLines,
	cursorWidth,
	disableLayerHinting,
	dragAndDrop,
	emptySelectionClipboard,
	extraEditorClassName,
A
Alex Dima 已提交
2472
	fastScrollSensitivity,
A
Alex Dima 已提交
2473
	fixedOverflowWidgets,
A
Alex Dima 已提交
2474
	folding,
A
Alex Dima 已提交
2475
	fontLigatures,
A
Alex Dima 已提交
2476 2477
	formatOnPaste,
	formatOnType,
A
Alex Dima 已提交
2478
	glyphMargin,
A
Alex Dima 已提交
2479 2480
	hideCursorInOverviewRuler,
	highlightActiveIndentGuide,
A
Alex Dima 已提交
2481
	inDiffEditor,
A
Alex Dima 已提交
2482
	lightbulb,
A
Alex Dima 已提交
2483
	lineDecorationsWidth,
A
Alex Dima 已提交
2484
	lineNumbers,
A
Alex Dima 已提交
2485
	lineNumbersMinChars,
A
Alex Dima 已提交
2486 2487
	links,
	matchBrackets,
A
Alex Dima 已提交
2488
	minimap,
A
Alex Dima 已提交
2489
	mouseStyle,
A
Alex Dima 已提交
2490
	mouseWheelScrollSensitivity,
A
Alex Dima 已提交
2491 2492 2493
	mouseWheelZoom,
	multiCursorMergeOverlapping,
	multiCursorModifier,
A
Alex Dima 已提交
2494
	occurrencesHighlight,
A
Alex Dima 已提交
2495 2496
	overviewRulerBorder,
	overviewRulerLanes,
A
Alex Dima 已提交
2497
	quickSuggestionsDelay,
2498
	readOnly,
A
Alex Dima 已提交
2499 2500
	renderControlCharacters,
	renderIndentGuides,
A
Alex Dima 已提交
2501
	renderFinalNewline,
A
Alex Dima 已提交
2502 2503 2504 2505 2506
	renderLineHighlight,
	renderWhitespace,
	revealHorizontalRightPadding,
	roundedSelection,
	rulers,
A
Alex Dima 已提交
2507
	scrollbar,
A
Alex Dima 已提交
2508 2509
	scrollBeyondLastColumn,
	scrollBeyondLastLine,
A
Alex Dima 已提交
2510
	selectionClipboard,
A
Alex Dima 已提交
2511
	selectionHighlight,
A
Alex Dima 已提交
2512
	selectOnLineNumbers,
A
Alex Dima 已提交
2513 2514 2515
	showUnused,
	smoothScrolling,
	stopRenderingLineAfter,
A
Alex Dima 已提交
2516
	suggestOnTriggerCharacters,
A
Alex Dima 已提交
2517
	useTabStops,
A
Alex Dima 已提交
2518
	wordBasedSuggestions,
A
Alex Dima 已提交
2519
	wordSeparators,
A
Alex Dima 已提交
2520 2521 2522 2523 2524 2525 2526 2527
	wordWrap,
	wordWrapBreakAfterCharacters,
	wordWrapBreakBeforeCharacters,
	wordWrapBreakObtrusiveCharacters,
	wordWrapColumn,
	wordWrapMinified,
	wrappingIndent,

A
Alex Dima 已提交
2528 2529 2530 2531
	ariaLabel,
	disableMonospaceOptimizations,
	editorClassName,
	tabFocusMode,
A
Alex Dima 已提交
2532 2533
	layoutInfo,
	wrappingInfo,
2534 2535
}

A
renames  
Alex Dima 已提交
2536
export const EditorOptions = {
A
Alex Dima 已提交
2537 2538
	acceptSuggestionOnCommitCharacter: registerEditorOption(new EditorBooleanOption(EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true)),
	acceptSuggestionOnEnter: registerEditorOption(new EditorEnumOption(EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter', 'on', ['on', 'smart', 'off'], x => x)),
A
renames  
Alex Dima 已提交
2539
	accessibilitySupport: registerEditorOption(new EditorAccessibilitySupportOption(EditorOption.accessibilitySupport, 'accessibilitySupport', 'auto')),
A
Alex Dima 已提交
2540 2541 2542 2543 2544 2545
	autoClosingBrackets: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingBrackets, 'autoClosingBrackets', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], x => x)),
	autoClosingOvertype: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingOvertype, 'autoClosingOvertype', 'auto', ['always', 'auto', 'never'], x => x)),
	autoClosingQuotes: registerEditorOption(new EditorEnumOption(EditorOption.autoClosingQuotes, 'autoClosingQuotes', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], x => x)),
	autoIndent: registerEditorOption(new EditorBooleanOption(EditorOption.autoIndent, 'autoIndent', true)),
	automaticLayout: registerEditorOption(new EditorBooleanOption(EditorOption.automaticLayout, 'automaticLayout', false)),
	autoSurround: registerEditorOption(new EditorEnumOption(EditorOption.autoSurround, 'autoSurround', 'languageDefined', ['languageDefined', 'quotes', 'brackets', 'never'], x => x)),
A
Alex Dima 已提交
2546 2547 2548
	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 已提交
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558
	copyWithSyntaxHighlighting: registerEditorOption(new EditorBooleanOption(EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true)),
	cursorBlinking: registerEditorOption(new EditorEnumOption(EditorOption.cursorBlinking, 'cursorBlinking', 'blink', ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString)),
	cursorSmoothCaretAnimation: registerEditorOption(new EditorBooleanOption(EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false)),
	cursorStyle: registerEditorOption(new EditorEnumOption(EditorOption.cursorStyle, 'cursorStyle', 'line', ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString)),
	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 已提交
2559
	fastScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.fastScrollSensitivity, 'fastScrollSensitivity', 5, x => (x <= 0 ? 5 : x))),
A
Alex Dima 已提交
2560
	fixedOverflowWidgets: registerEditorOption(new EditorBooleanOption(EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false)),
A
renames  
Alex Dima 已提交
2561
	folding: registerEditorOption(new EditorBooleanOption(EditorOption.folding, 'folding', true)),
A
Alex Dima 已提交
2562
	fontLigatures: registerEditorOption(new EditorBooleanOption(EditorOption.fontLigatures, 'fontLigatures', true)),
A
Alex Dima 已提交
2563 2564
	formatOnPaste: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnPaste, 'formatOnPaste', false)),
	formatOnType: registerEditorOption(new EditorBooleanOption(EditorOption.formatOnType, 'formatOnType', false)),
A
renames  
Alex Dima 已提交
2565
	glyphMargin: registerEditorOption(new EditorBooleanOption(EditorOption.glyphMargin, 'glyphMargin', true)),
A
Alex Dima 已提交
2566 2567
	hideCursorInOverviewRuler: registerEditorOption(new EditorBooleanOption(EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false)),
	highlightActiveIndentGuide: registerEditorOption(new EditorBooleanOption(EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true)),
A
renames  
Alex Dima 已提交
2568
	inDiffEditor: registerEditorOption(new EditorBooleanOption(EditorOption.inDiffEditor, 'inDiffEditor', false)),
A
Alex Dima 已提交
2569 2570 2571
	lightbulb: registerEditorOption(new EditorLightbulb(EditorOption.lightbulb, 'lightbulb', {
		enabled: true
	})),
2572
	lineDecorationsWidth: registerEditorOption(new EditorPassthroughOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10)),
A
Alex Dima 已提交
2573
	lineNumbers: registerEditorOption(new EditorRenderLineNumbersOption(EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null })),
A
renames  
Alex Dima 已提交
2574
	lineNumbersMinChars: registerEditorOption(new EditorIntOption(EditorOption.lineNumbersMinChars, 'lineNumbersMinChars', 5, 1, 10)),
A
Alex Dima 已提交
2575 2576 2577
	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 已提交
2578 2579 2580 2581 2582 2583
		enabled: true,
		side: 'right',
		showSlider: 'mouseover',
		renderCharacters: true,
		maxColumn: 120,
	})),
A
Alex Dima 已提交
2584
	mouseStyle: registerEditorOption(new EditorEnumOption(EditorOption.mouseStyle, 'mouseStyle', 'text', ['text', 'default', 'copy'], x => x)),
A
renames  
Alex Dima 已提交
2585
	mouseWheelScrollSensitivity: registerEditorOption(new EditorFloatOption(EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity', 1, x => (x === 0 ? 1 : x))),
A
Alex Dima 已提交
2586 2587 2588
	mouseWheelZoom: registerEditorOption(new EditorBooleanOption(EditorOption.mouseWheelZoom, 'mouseWheelZoom', false)),
	multiCursorMergeOverlapping: registerEditorOption(new EditorBooleanOption(EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true)),
	multiCursorModifier: registerEditorOption(new EditorEnumOption(EditorOption.multiCursorModifier, 'multiCursorModifier', 'alt', ['ctrlCmd', 'alt'], _multiCursorModifierFromString)),
A
Alex Dima 已提交
2589
	occurrencesHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.occurrencesHighlight, 'occurrencesHighlight', true)),
A
Alex Dima 已提交
2590 2591
	overviewRulerBorder: registerEditorOption(new EditorBooleanOption(EditorOption.overviewRulerBorder, 'overviewRulerBorder', true)),
	overviewRulerLanes: registerEditorOption(new EditorIntOption(EditorOption.overviewRulerLanes, 'overviewRulerLanes', 2, 0, 3)),
A
Alex Dima 已提交
2592
	quickSuggestionsDelay: registerEditorOption(new EditorIntOption(EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay', 10, 0, Constants.MAX_SAFE_SMALL_INTEGER)),
A
renames  
Alex Dima 已提交
2593
	readOnly: registerEditorOption(new EditorBooleanOption(EditorOption.readOnly, 'readOnly', false)),
A
Alex Dima 已提交
2594 2595
	renderControlCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.renderControlCharacters, 'renderControlCharacters', false)),
	renderIndentGuides: registerEditorOption(new EditorBooleanOption(EditorOption.renderIndentGuides, 'renderIndentGuides', true)),
A
renames  
Alex Dima 已提交
2596
	renderFinalNewline: registerEditorOption(new EditorBooleanOption(EditorOption.renderFinalNewline, 'renderFinalNewline', true)),
A
Alex Dima 已提交
2597 2598 2599 2600 2601
	renderLineHighlight: registerEditorOption(new EditorEnumOption(EditorOption.renderLineHighlight, 'renderLineHighlight', 'line', ['none', 'gutter', 'line', 'all'], x => x)),
	renderWhitespace: registerEditorOption(new EditorEnumOption(EditorOption.renderWhitespace, 'renderWhitespace', 'none', ['none', 'boundary', 'selection', 'all'], x => x)),
	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 已提交
2602
	scrollbar: registerEditorOption(new EditorScrollbar(EditorOption.scrollbar, 'scrollbar', {
A
Alex Dima 已提交
2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614
		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 已提交
2615 2616
	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 已提交
2617
	selectionClipboard: registerEditorOption(new EditorBooleanOption(EditorOption.selectionClipboard, 'selectionClipboard', true)),
A
Alex Dima 已提交
2618
	selectionHighlight: registerEditorOption(new EditorBooleanOption(EditorOption.selectionHighlight, 'selectionHighlight', true)),
A
renames  
Alex Dima 已提交
2619
	selectOnLineNumbers: registerEditorOption(new EditorBooleanOption(EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true)),
A
Alex Dima 已提交
2620 2621 2622
	showUnused: registerEditorOption(new EditorBooleanOption(EditorOption.showUnused, 'showUnused', true)),
	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 已提交
2623
	suggestOnTriggerCharacters: registerEditorOption(new EditorBooleanOption(EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true)),
A
Alex Dima 已提交
2624
	useTabStops: registerEditorOption(new EditorBooleanOption(EditorOption.useTabStops, 'useTabStops', true)),
A
Alex Dima 已提交
2625
	wordBasedSuggestions: registerEditorOption(new EditorBooleanOption(EditorOption.wordBasedSuggestions, 'wordBasedSuggestions', true)),
A
Alex Dima 已提交
2626
	wordSeparators: registerEditorOption(new EditorStringOption(EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS)),
2627
	wordWrap: registerEditorOption(new EditorEnumOption(EditorOption.wordWrap, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], x => x)),
A
renames  
Alex Dima 已提交
2628 2629 2630
	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 已提交
2631
	wordWrapColumn: registerEditorOption(new EditorIntOption(EditorOption.wordWrapColumn, 'wordWrapColumn', 80, 1, Constants.MAX_SAFE_SMALL_INTEGER)),
A
renames  
Alex Dima 已提交
2632
	wordWrapMinified: registerEditorOption(new EditorBooleanOption(EditorOption.wordWrapMinified, 'wordWrapMinified', true)),
2633
	wrappingIndent: registerEditorOption(new EditorEnumOption(EditorOption.wrappingIndent, 'wrappingIndent', 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString)),
A
Alex Dima 已提交
2634 2635

	// Leave these at the end!
A
Alex Dima 已提交
2636 2637 2638 2639 2640
	ariaLabel: registerEditorOption(new EditorAriaLabel(EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content"), [EditorOption.accessibilitySupport])),
	disableMonospaceOptimizations: registerEditorOption(new EditorDisableMonospaceOptimizations(EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false, [EditorOption.fontLigatures])),
	editorClassName: registerEditorOption(new EditorClassName(EditorOption.editorClassName, 'editorClassName', undefined, [EditorOption.mouseStyle, EditorOption.fontLigatures, EditorOption.extraEditorClassName])),
	tabFocusMode: registerEditorOption(new EditorTabFocusMode(EditorOption.tabFocusMode, 'tabFocusMode', undefined, [EditorOption.readOnly])),
	layoutInfo: registerEditorOption(new EditorLayoutInfoComputer(EditorOption.layoutInfo, 'layoutInfo', undefined, [EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding, EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers])),
A
renames  
Alex Dima 已提交
2641
	wrappingInfo: registerEditorOption(new EditorWrappingInfoComputer(EditorOption.wrappingInfo, 'wrappingInfo', undefined, [EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified, EditorOption.layoutInfo, EditorOption.accessibilitySupport])),
2642
};
A
Alex Dima 已提交
2643

A
Alex Dima 已提交
2644 2645 2646 2647 2648 2649 2650 2651
// const tmp: { [key: string]: IEditorOption<any, any>; } = EditorOptions;
// for (const key of Object.keys(tmp)) {
// 	const option = tmp[key];
// 	if (key !== option.name) {
// 		throw new Error(`mismatch - ${key} - ${option.name}`);
// 	}
// }

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