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

/**
 * 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 已提交
30
	vertical?: 'auto' | 'visible' | 'hidden';
31 32 33 34
	/**
	 * Render horizontal scrollbar.
	 * Defaults to 'auto'.
	 */
A
Alex Dima 已提交
35
	horizontal?: 'auto' | 'visible' | 'hidden';
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
	/**
	 * 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;
}

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

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

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

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

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

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

174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
/**
 * 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;
}

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

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

228 229 230 231 232 233 234
/**
 * Configuration map for codeActionsOnSave
 */
export interface ICodeActionsOnSaveOptions {
	[kind: string]: boolean;
}

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

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

749
export const enum RenderMinimap {
750 751 752 753 754 755 756 757 758 759
	None = 0,
	Small = 1,
	Large = 2,
	SmallBlocks = 3,
	LargeBlocks = 4,
}

/**
 * Describes how to indent wrapped lines.
 */
760
export const enum WrappingIndent {
761 762 763 764 765 766 767 768 769
	/**
	 * No indentation => wrapped lines begin at column 1.
	 */
	None = 0,
	/**
	 * Same => wrapped lines get the same indentation as the parent.
	 */
	Same = 1,
	/**
770
	 * Indent => wrapped lines get +1 indentation toward the parent.
771
	 */
772 773 774
	Indent = 2,
	/**
	 * DeepIndent => wrapped lines get +2 indentation toward the parent.
775
	 */
776
	DeepIndent = 3
777 778 779 780 781
}

/**
 * The kind of animation in which the editor's cursor should be rendered.
 */
782
export const enum TextEditorCursorBlinkingStyle {
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
	/**
	 * 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
}
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
/**
 * @internal
 */
export function blinkingStyleToString(blinkingStyle: TextEditorCursorBlinkingStyle): string {
	if (blinkingStyle === TextEditorCursorBlinkingStyle.Blink) {
		return 'blink';
	} else if (blinkingStyle === TextEditorCursorBlinkingStyle.Expand) {
		return 'expand';
	} else if (blinkingStyle === TextEditorCursorBlinkingStyle.Phase) {
		return 'phase';
	} else if (blinkingStyle === TextEditorCursorBlinkingStyle.Smooth) {
		return 'smooth';
	} else if (blinkingStyle === TextEditorCursorBlinkingStyle.Solid) {
		return 'solid';
	} else {
		throw new Error('blinkingStyleToString: Unknown blinkingStyle');
	}
}
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

/**
 * 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
 */
export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): string {
	if (cursorStyle === TextEditorCursorStyle.Line) {
		return 'line';
	} else if (cursorStyle === TextEditorCursorStyle.Block) {
		return 'block';
	} else if (cursorStyle === TextEditorCursorStyle.Underline) {
		return 'underline';
	} else if (cursorStyle === TextEditorCursorStyle.LineThin) {
		return 'line-thin';
	} else if (cursorStyle === TextEditorCursorStyle.BlockOutline) {
		return 'block-outline';
	} else if (cursorStyle === TextEditorCursorStyle.UnderlineThin) {
		return 'underline-thin';
	} else {
		throw new Error('cursorStyleToString: Unknown cursorStyle');
	}
}

A
Alex Dima 已提交
878
function _cursorStyleFromString(cursorStyle: string | undefined, defaultValue: TextEditorCursorStyle): TextEditorCursorStyle {
A
Alex Dima 已提交
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
	if (typeof cursorStyle !== 'string') {
		return defaultValue;
	}
	if (cursorStyle === 'line') {
		return TextEditorCursorStyle.Line;
	} else if (cursorStyle === 'block') {
		return TextEditorCursorStyle.Block;
	} else if (cursorStyle === 'underline') {
		return TextEditorCursorStyle.Underline;
	} else if (cursorStyle === 'line-thin') {
		return TextEditorCursorStyle.LineThin;
	} else if (cursorStyle === 'block-outline') {
		return TextEditorCursorStyle.BlockOutline;
	} else if (cursorStyle === 'underline-thin') {
		return TextEditorCursorStyle.UnderlineThin;
	}
	return TextEditorCursorStyle.Line;
}

A
Alex Dima 已提交
898
export interface InternalEditorScrollbarOptions {
899 900 901 902 903 904 905 906 907 908 909 910
	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;
	readonly mouseWheelScrollSensitivity: number;
T
Tiago Ribeiro 已提交
911
	readonly fastScrollSensitivity: number;
912 913
}

A
Alex Dima 已提交
914
export interface InternalEditorMinimapOptions {
915
	readonly enabled: boolean;
916
	readonly side: 'right' | 'left';
917
	readonly showSlider: 'always' | 'mouseover';
918 919 920 921
	readonly renderCharacters: boolean;
	readonly maxColumn: number;
}

922 923
export interface InternalEditorFindOptions {
	readonly seedSearchStringFromSelection: boolean;
R
rebornix 已提交
924
	readonly autoFindInSelection: boolean;
925
	readonly addExtraSpaceOnTop: boolean;
926 927 928 929
	/**
	 * @internal
	 */
	readonly globalFindClipboard: boolean;
930 931
}

A
Alex Dima 已提交
932 933
export interface InternalEditorHoverOptions {
	readonly enabled: boolean;
934
	readonly delay: number;
935
	readonly sticky: boolean;
A
Alex Dima 已提交
936 937
}

938
export interface InternalGoToLocationOptions {
J
Johannes Rieken 已提交
939
	readonly multiple: 'peek' | 'gotoAndPeek' | 'goto';
940 941
}

942 943
export interface InternalSuggestOptions {
	readonly filterGraceful: boolean;
944
	readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
945
	readonly snippetsPreventQuickSuggestions: boolean;
J
Johannes Rieken 已提交
946
	readonly localityBonus: boolean;
J
Johannes Rieken 已提交
947
	readonly shareSuggestSelections: boolean;
948
	readonly showIcons: boolean;
J
Johannes Rieken 已提交
949
	readonly maxVisibleSuggestions: number;
950
	readonly filteredTypes: Record<string, boolean>;
951 952
}

953 954 955 956 957
export interface InternalParameterHintOptions {
	readonly enabled: boolean;
	readonly cycle: boolean;
}

A
Alex Dima 已提交
958
export interface EditorWrappingInfo {
959 960 961 962 963 964 965 966 967 968 969
	readonly inDiffEditor: boolean;
	readonly isDominatedByLongLines: boolean;
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;
	readonly wrappingIndent: WrappingIndent;
	readonly wordWrapBreakBeforeCharacters: string;
	readonly wordWrapBreakAfterCharacters: string;
	readonly wordWrapBreakObtrusiveCharacters: string;
}

970 971 972 973
export const enum RenderLineNumbersType {
	Off = 0,
	On = 1,
	Relative = 2,
974 975
	Interval = 3,
	Custom = 4
976 977
}

A
Alex Dima 已提交
978
export interface InternalEditorViewOptions {
979
	readonly extraEditorClassName: string;
980 981 982
	readonly disableMonospaceOptimizations: boolean;
	readonly rulers: number[];
	readonly ariaLabel: string;
983
	readonly renderLineNumbers: RenderLineNumbersType;
A
Alex Dima 已提交
984
	readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null;
A
Alex Dima 已提交
985
	readonly renderFinalNewline: boolean;
986 987 988 989 990 991 992 993
	readonly selectOnLineNumbers: boolean;
	readonly glyphMargin: boolean;
	readonly revealHorizontalRightPadding: number;
	readonly roundedSelection: boolean;
	readonly overviewRulerLanes: number;
	readonly overviewRulerBorder: boolean;
	readonly cursorBlinking: TextEditorCursorBlinkingStyle;
	readonly mouseWheelZoom: boolean;
994
	readonly cursorSmoothCaretAnimation: boolean;
995
	readonly cursorStyle: TextEditorCursorStyle;
996
	readonly cursorWidth: number;
997 998
	readonly hideCursorInOverviewRuler: boolean;
	readonly scrollBeyondLastLine: boolean;
999
	readonly scrollBeyondLastColumn: number;
1000
	readonly smoothScrolling: boolean;
1001 1002 1003 1004 1005
	readonly stopRenderingLineAfter: number;
	readonly renderWhitespace: 'none' | 'boundary' | 'all';
	readonly renderControlCharacters: boolean;
	readonly fontLigatures: boolean;
	readonly renderIndentGuides: boolean;
1006
	readonly highlightActiveIndentGuide: boolean;
1007 1008 1009 1010 1011 1012
	readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
	readonly scrollbar: InternalEditorScrollbarOptions;
	readonly minimap: InternalEditorMinimapOptions;
	readonly fixedOverflowWidgets: boolean;
}

A
Alex Dima 已提交
1013
export interface EditorContribOptions {
1014
	readonly selectionClipboard: boolean;
A
Alex Dima 已提交
1015
	readonly hover: InternalEditorHoverOptions;
1016
	readonly links: boolean;
1017 1018 1019
	readonly contextmenu: boolean;
	readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
	readonly quickSuggestionsDelay: number;
1020
	readonly parameterHints: InternalParameterHintOptions;
1021 1022 1023
	readonly formatOnType: boolean;
	readonly formatOnPaste: boolean;
	readonly suggestOnTriggerCharacters: boolean;
1024
	readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off';
1025 1026
	readonly acceptSuggestionOnCommitCharacter: boolean;
	readonly wordBasedSuggestions: boolean;
B
Benas Svipas 已提交
1027
	readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
1028 1029
	readonly suggestFontSize: number;
	readonly suggestLineHeight: number;
1030
	readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
1031
	readonly suggest: InternalSuggestOptions;
1032
	readonly gotoLocation: InternalGoToLocationOptions;
1033 1034 1035 1036
	readonly selectionHighlight: boolean;
	readonly occurrencesHighlight: boolean;
	readonly codeLens: boolean;
	readonly folding: boolean;
1037
	readonly foldingStrategy: 'auto' | 'indentation';
1038
	readonly showFoldingControls: 'always' | 'mouseover';
1039
	readonly matchBrackets: boolean;
1040
	readonly find: InternalEditorFindOptions;
R
rebornix 已提交
1041
	readonly colorDecorators: boolean;
1042
	readonly lightbulbEnabled: boolean;
1043 1044
	readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
	readonly codeActionsOnSaveTimeout: number;
1045 1046
}

1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
/**
 * 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 inDiffEditor: boolean;
	readonly wordSeparators: string;
	readonly lineNumbersMinChars: number;
	readonly lineDecorationsWidth: number | string;
	readonly readOnly: boolean;
	readonly mouseStyle: 'text' | 'default' | 'copy';
1059
	readonly disableLayerHinting: boolean;
1060 1061 1062 1063 1064 1065 1066 1067
	readonly automaticLayout: boolean;
	readonly wordWrap: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
	readonly wordWrapColumn: number;
	readonly wordWrapMinified: boolean;
	readonly wrappingIndent: WrappingIndent;
	readonly wordWrapBreakBeforeCharacters: string;
	readonly wordWrapBreakAfterCharacters: string;
	readonly wordWrapBreakObtrusiveCharacters: string;
J
Jackson Kearl 已提交
1068 1069
	readonly autoClosingBrackets: EditorAutoClosingStrategy;
	readonly autoClosingQuotes: EditorAutoClosingStrategy;
1070
	readonly autoSurround: EditorAutoSurroundStrategy;
1071
	readonly autoIndent: boolean;
1072 1073
	readonly dragAndDrop: boolean;
	readonly emptySelectionClipboard: boolean;
1074
	readonly copyWithSyntaxHighlighting: boolean;
1075
	readonly useTabStops: boolean;
1076
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1077
	readonly multiCursorMergeOverlapping: boolean;
1078
	readonly accessibilitySupport: 'auto' | 'off' | 'on';
1079
	readonly showUnused: boolean;
1080 1081 1082 1083 1084

	readonly viewInfo: InternalEditorViewOptions;
	readonly contribInfo: EditorContribOptions;
}

1085 1086 1087 1088 1089 1090
/**
 * Internal configuration options (transformed or computed) for the editor.
 */
export class InternalEditorOptions {
	readonly _internalEditorOptionsBrand: void;

1091
	readonly canUseLayerHinting: boolean;
1092
	readonly pixelRatio: number;
A
Alex Dima 已提交
1093
	readonly editorClassName: string;
A
Alex Dima 已提交
1094
	readonly lineHeight: number;
1095
	readonly readOnly: boolean;
1096 1097 1098
	/**
	 * @internal
	 */
1099
	readonly accessibilitySupport: AccessibilitySupport;
1100
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1101
	readonly multiCursorMergeOverlapping: boolean;
1102
	readonly showUnused: boolean;
A
Alex Dima 已提交
1103

1104 1105
	// ---- cursor options
	readonly wordSeparators: string;
J
Jackson Kearl 已提交
1106 1107
	readonly autoClosingBrackets: EditorAutoClosingStrategy;
	readonly autoClosingQuotes: EditorAutoClosingStrategy;
1108
	readonly autoSurround: EditorAutoSurroundStrategy;
1109
	readonly autoIndent: boolean;
1110 1111 1112
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
1113
	readonly emptySelectionClipboard: boolean;
1114
	readonly copyWithSyntaxHighlighting: boolean;
A
Alex Dima 已提交
1115

1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
	// ---- grouped options
	readonly layoutInfo: EditorLayoutInfo;
	readonly fontInfo: FontInfo;
	readonly viewInfo: InternalEditorViewOptions;
	readonly wrappingInfo: EditorWrappingInfo;
	readonly contribInfo: EditorContribOptions;

	/**
	 * @internal
	 */
	constructor(source: {
1127
		canUseLayerHinting: boolean;
1128
		pixelRatio: number;
A
Alex Dima 已提交
1129
		editorClassName: string;
1130 1131
		lineHeight: number;
		readOnly: boolean;
1132
		accessibilitySupport: AccessibilitySupport;
1133
		multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1134
		multiCursorMergeOverlapping: boolean;
1135
		wordSeparators: string;
J
Jackson Kearl 已提交
1136 1137
		autoClosingBrackets: EditorAutoClosingStrategy;
		autoClosingQuotes: EditorAutoClosingStrategy;
1138
		autoSurround: EditorAutoSurroundStrategy;
1139
		autoIndent: boolean;
1140 1141 1142
		useTabStops: boolean;
		tabFocusMode: boolean;
		dragAndDrop: boolean;
1143
		emptySelectionClipboard: boolean;
1144
		copyWithSyntaxHighlighting: boolean;
1145 1146 1147 1148 1149
		layoutInfo: EditorLayoutInfo;
		fontInfo: FontInfo;
		viewInfo: InternalEditorViewOptions;
		wrappingInfo: EditorWrappingInfo;
		contribInfo: EditorContribOptions;
1150
		showUnused: boolean;
1151
	}) {
1152
		this.canUseLayerHinting = source.canUseLayerHinting;
1153 1154
		this.pixelRatio = source.pixelRatio;
		this.editorClassName = source.editorClassName;
1155
		this.lineHeight = source.lineHeight | 0;
1156
		this.readOnly = source.readOnly;
1157
		this.accessibilitySupport = source.accessibilitySupport;
1158
		this.multiCursorModifier = source.multiCursorModifier;
A
Alex Dima 已提交
1159
		this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping;
1160 1161
		this.wordSeparators = source.wordSeparators;
		this.autoClosingBrackets = source.autoClosingBrackets;
J
Jackson Kearl 已提交
1162
		this.autoClosingQuotes = source.autoClosingQuotes;
1163
		this.autoSurround = source.autoSurround;
1164
		this.autoIndent = source.autoIndent;
1165 1166 1167
		this.useTabStops = source.useTabStops;
		this.tabFocusMode = source.tabFocusMode;
		this.dragAndDrop = source.dragAndDrop;
1168
		this.emptySelectionClipboard = source.emptySelectionClipboard;
1169
		this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting;
1170 1171 1172 1173 1174
		this.layoutInfo = source.layoutInfo;
		this.fontInfo = source.fontInfo;
		this.viewInfo = source.viewInfo;
		this.wrappingInfo = source.wrappingInfo;
		this.contribInfo = source.contribInfo;
1175
		this.showUnused = source.showUnused;
1176 1177 1178 1179 1180 1181 1182
	}

	/**
	 * @internal
	 */
	public equals(other: InternalEditorOptions): boolean {
		return (
1183
			this.canUseLayerHinting === other.canUseLayerHinting
1184
			&& this.pixelRatio === other.pixelRatio
A
Alex Dima 已提交
1185 1186
			&& this.editorClassName === other.editorClassName
			&& this.lineHeight === other.lineHeight
1187
			&& this.readOnly === other.readOnly
1188
			&& this.accessibilitySupport === other.accessibilitySupport
1189
			&& this.multiCursorModifier === other.multiCursorModifier
A
Alex Dima 已提交
1190
			&& this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping
1191 1192
			&& this.wordSeparators === other.wordSeparators
			&& this.autoClosingBrackets === other.autoClosingBrackets
J
Jackson Kearl 已提交
1193
			&& this.autoClosingQuotes === other.autoClosingQuotes
1194
			&& this.autoSurround === other.autoSurround
1195
			&& this.autoIndent === other.autoIndent
1196 1197 1198
			&& this.useTabStops === other.useTabStops
			&& this.tabFocusMode === other.tabFocusMode
			&& this.dragAndDrop === other.dragAndDrop
1199
			&& this.showUnused === other.showUnused
1200
			&& this.emptySelectionClipboard === other.emptySelectionClipboard
1201
			&& this.copyWithSyntaxHighlighting === other.copyWithSyntaxHighlighting
A
Alex Dima 已提交
1202
			&& InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, other.layoutInfo)
1203
			&& this.fontInfo.equals(other.fontInfo)
A
Alex Dima 已提交
1204 1205 1206
			&& InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo)
			&& InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, other.wrappingInfo)
			&& InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo)
1207 1208 1209 1210 1211 1212 1213 1214
		);
	}

	/**
	 * @internal
	 */
	public createChangeEvent(newOpts: InternalEditorOptions): IConfigurationChangedEvent {
		return {
1215
			canUseLayerHinting: (this.canUseLayerHinting !== newOpts.canUseLayerHinting),
1216
			pixelRatio: (this.pixelRatio !== newOpts.pixelRatio),
A
Alex Dima 已提交
1217
			editorClassName: (this.editorClassName !== newOpts.editorClassName),
1218 1219
			lineHeight: (this.lineHeight !== newOpts.lineHeight),
			readOnly: (this.readOnly !== newOpts.readOnly),
1220
			accessibilitySupport: (this.accessibilitySupport !== newOpts.accessibilitySupport),
1221
			multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier),
A
Alex Dima 已提交
1222
			multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping),
1223 1224
			wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
			autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
J
Jackson Kearl 已提交
1225
			autoClosingQuotes: (this.autoClosingQuotes !== newOpts.autoClosingQuotes),
1226
			autoSurround: (this.autoSurround !== newOpts.autoSurround),
1227
			autoIndent: (this.autoIndent !== newOpts.autoIndent),
1228 1229 1230
			useTabStops: (this.useTabStops !== newOpts.useTabStops),
			tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
			dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop),
1231
			emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard),
1232
			copyWithSyntaxHighlighting: (this.copyWithSyntaxHighlighting !== newOpts.copyWithSyntaxHighlighting),
A
Alex Dima 已提交
1233
			layoutInfo: (!InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, newOpts.layoutInfo)),
1234
			fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
A
Alex Dima 已提交
1235 1236
			viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)),
			wrappingInfo: (!InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, newOpts.wrappingInfo)),
1237
			contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo))
1238 1239 1240
		};
	}

A
Alex Dima 已提交
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
	/**
	 * @internal
	 */
	private static _equalsLayoutInfo(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
1261
			&& a.minimapLeft === b.minimapLeft
A
Alex Dima 已提交
1262 1263 1264 1265 1266 1267 1268
			&& a.minimapWidth === b.minimapWidth
			&& a.viewportColumn === b.viewportColumn
			&& a.verticalScrollbarWidth === b.verticalScrollbarWidth
			&& a.horizontalScrollbarHeight === b.horizontalScrollbarHeight
			&& this._equalsOverviewRuler(a.overviewRuler, b.overviewRuler)
		);
	}
1269 1270

	/**
A
Alex Dima 已提交
1271
	 * @internal
1272
	 */
A
Alex Dima 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281
	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
		);
	}

1282
	/**
A
Alex Dima 已提交
1283
	 * @internal
1284
	 */
A
Alex Dima 已提交
1285 1286
	private static _equalsViewOptions(a: InternalEditorViewOptions, b: InternalEditorViewOptions): boolean {
		return (
1287
			a.extraEditorClassName === b.extraEditorClassName
A
Alex Dima 已提交
1288
			&& a.disableMonospaceOptimizations === b.disableMonospaceOptimizations
1289
			&& arrays.equals(a.rulers, b.rulers)
A
Alex Dima 已提交
1290 1291 1292
			&& a.ariaLabel === b.ariaLabel
			&& a.renderLineNumbers === b.renderLineNumbers
			&& a.renderCustomLineNumbers === b.renderCustomLineNumbers
A
Alex Dima 已提交
1293
			&& a.renderFinalNewline === b.renderFinalNewline
A
Alex Dima 已提交
1294 1295 1296 1297 1298 1299 1300 1301
			&& a.selectOnLineNumbers === b.selectOnLineNumbers
			&& a.glyphMargin === b.glyphMargin
			&& a.revealHorizontalRightPadding === b.revealHorizontalRightPadding
			&& a.roundedSelection === b.roundedSelection
			&& a.overviewRulerLanes === b.overviewRulerLanes
			&& a.overviewRulerBorder === b.overviewRulerBorder
			&& a.cursorBlinking === b.cursorBlinking
			&& a.mouseWheelZoom === b.mouseWheelZoom
1302
			&& a.cursorSmoothCaretAnimation === b.cursorSmoothCaretAnimation
A
Alex Dima 已提交
1303
			&& a.cursorStyle === b.cursorStyle
1304
			&& a.cursorWidth === b.cursorWidth
A
Alex Dima 已提交
1305 1306
			&& a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler
			&& a.scrollBeyondLastLine === b.scrollBeyondLastLine
1307
			&& a.scrollBeyondLastColumn === b.scrollBeyondLastColumn
1308
			&& a.smoothScrolling === b.smoothScrolling
A
Alex Dima 已提交
1309 1310 1311 1312 1313
			&& a.stopRenderingLineAfter === b.stopRenderingLineAfter
			&& a.renderWhitespace === b.renderWhitespace
			&& a.renderControlCharacters === b.renderControlCharacters
			&& a.fontLigatures === b.fontLigatures
			&& a.renderIndentGuides === b.renderIndentGuides
A
Alex Dima 已提交
1314
			&& a.highlightActiveIndentGuide === b.highlightActiveIndentGuide
A
Alex Dima 已提交
1315 1316 1317 1318 1319 1320 1321
			&& a.renderLineHighlight === b.renderLineHighlight
			&& this._equalsScrollbarOptions(a.scrollbar, b.scrollbar)
			&& this._equalsMinimapOptions(a.minimap, b.minimap)
			&& a.fixedOverflowWidgets === b.fixedOverflowWidgets
		);
	}

1322
	/**
A
Alex Dima 已提交
1323
	 * @internal
1324
	 */
A
Alex Dima 已提交
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
	private static _equalsScrollbarOptions(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
			&& a.mouseWheelScrollSensitivity === b.mouseWheelScrollSensitivity
T
Tiago Ribeiro 已提交
1339
			&& a.fastScrollSensitivity === b.fastScrollSensitivity
A
Alex Dima 已提交
1340 1341 1342
		);
	}

1343
	/**
A
Alex Dima 已提交
1344
	 * @internal
1345
	 */
A
Alex Dima 已提交
1346 1347 1348
	private static _equalsMinimapOptions(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean {
		return (
			a.enabled === b.enabled
1349
			&& a.side === b.side
1350
			&& a.showSlider === b.showSlider
A
Alex Dima 已提交
1351 1352 1353 1354 1355
			&& a.renderCharacters === b.renderCharacters
			&& a.maxColumn === b.maxColumn
		);
	}

1356 1357 1358 1359 1360 1361
	/**
	 * @internal
	 */
	private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
		return (
			a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
R
rebornix 已提交
1362
			&& a.autoFindInSelection === b.autoFindInSelection
1363
			&& a.globalFindClipboard === b.globalFindClipboard
1364
			&& a.addExtraSpaceOnTop === b.addExtraSpaceOnTop
1365 1366 1367
		);
	}

1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
	/**
	 * @internal
	 */
	private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
		return (
			a.enabled === b.enabled
			&& a.cycle === b.cycle
		);
	}

A
Alex Dima 已提交
1378 1379 1380 1381 1382 1383
	/**
	 * @internal
	 */
	private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
		return (
			a.enabled === b.enabled
1384
			&& a.delay === b.delay
1385
			&& a.sticky === b.sticky
A
Alex Dima 已提交
1386 1387 1388
		);
	}

1389 1390 1391
	/**
	 * @internal
	 */
1392
	private static _equalsSuggestOptions(a: InternalSuggestOptions, b: InternalSuggestOptions): any {
1393 1394 1395 1396 1397
		if (a === b) {
			return true;
		} else if (!a || !b) {
			return false;
		} else {
1398 1399
			return a.filterGraceful === b.filterGraceful
				&& a.snippets === b.snippets
J
Johannes Rieken 已提交
1400
				&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
1401
				&& a.localityBonus === b.localityBonus
1402 1403
				&& a.shareSuggestSelections === b.shareSuggestSelections
				&& a.showIcons === b.showIcons
J
Johannes Rieken 已提交
1404 1405
				&& a.maxVisibleSuggestions === b.maxVisibleSuggestions
				&& objects.equals(a.filteredTypes, b.filteredTypes);
1406 1407 1408
		}
	}

1409 1410 1411 1412 1413 1414
	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 已提交
1415
			return a.multiple === b.multiple;
1416 1417 1418
		}
	}

1419 1420 1421
	/**
	 * @internal
	 */
A
Alex Dima 已提交
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
	private static _equalsWrappingInfo(a: EditorWrappingInfo, b: EditorWrappingInfo): boolean {
		return (
			a.inDiffEditor === b.inDiffEditor
			&& a.isDominatedByLongLines === b.isDominatedByLongLines
			&& a.isWordWrapMinified === b.isWordWrapMinified
			&& a.isViewportWrapping === b.isViewportWrapping
			&& a.wrappingColumn === b.wrappingColumn
			&& a.wrappingIndent === b.wrappingIndent
			&& a.wordWrapBreakBeforeCharacters === b.wordWrapBreakBeforeCharacters
			&& a.wordWrapBreakAfterCharacters === b.wordWrapBreakAfterCharacters
			&& a.wordWrapBreakObtrusiveCharacters === b.wordWrapBreakObtrusiveCharacters
		);
1434 1435 1436 1437 1438
	}

	/**
	 * @internal
	 */
A
Alex Dima 已提交
1439 1440 1441
	private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
		return (
			a.selectionClipboard === b.selectionClipboard
A
Alex Dima 已提交
1442
			&& this._equalsHoverOptions(a.hover, b.hover)
1443
			&& a.links === b.links
A
Alex Dima 已提交
1444 1445 1446
			&& a.contextmenu === b.contextmenu
			&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
			&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
1447
			&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
A
Alex Dima 已提交
1448 1449 1450 1451 1452 1453
			&& a.formatOnType === b.formatOnType
			&& a.formatOnPaste === b.formatOnPaste
			&& a.suggestOnTriggerCharacters === b.suggestOnTriggerCharacters
			&& a.acceptSuggestionOnEnter === b.acceptSuggestionOnEnter
			&& a.acceptSuggestionOnCommitCharacter === b.acceptSuggestionOnCommitCharacter
			&& a.wordBasedSuggestions === b.wordBasedSuggestions
J
Johannes Rieken 已提交
1454
			&& a.suggestSelection === b.suggestSelection
A
Alex Dima 已提交
1455 1456
			&& a.suggestFontSize === b.suggestFontSize
			&& a.suggestLineHeight === b.suggestLineHeight
1457
			&& a.tabCompletion === b.tabCompletion
1458
			&& this._equalsSuggestOptions(a.suggest, b.suggest)
1459
			&& InternalEditorOptions._equalsGotoLocationOptions(a.gotoLocation, b.gotoLocation)
A
Alex Dima 已提交
1460 1461 1462 1463
			&& a.selectionHighlight === b.selectionHighlight
			&& a.occurrencesHighlight === b.occurrencesHighlight
			&& a.codeLens === b.codeLens
			&& a.folding === b.folding
1464
			&& a.foldingStrategy === b.foldingStrategy
1465
			&& a.showFoldingControls === b.showFoldingControls
A
Alex Dima 已提交
1466
			&& a.matchBrackets === b.matchBrackets
1467
			&& this._equalFindOptions(a.find, b.find)
R
rebornix 已提交
1468
			&& a.colorDecorators === b.colorDecorators
1469 1470
			&& objects.equals(a.codeActionsOnSave, b.codeActionsOnSave)
			&& a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout
1471
			&& a.lightbulbEnabled === b.lightbulbEnabled
A
Alex Dima 已提交
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484
		);
	}

	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;
		}
1485
		return (
A
Alex Dima 已提交
1486 1487 1488
			a.comments === b.comments
			&& a.other === b.other
			&& a.strings === b.strings
1489 1490 1491 1492
		);
	}
}

A
Alex Dima 已提交
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
/**
 * 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;
}

1515 1516 1517
/**
 * The internal layout details of the editor.
 */
A
Alex Dima 已提交
1518
export interface EditorLayoutInfo {
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580

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

1581 1582 1583 1584
	/**
	 * The position for the minimap
	 */
	readonly minimapLeft: number;
1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
	/**
	 * 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;
}

/**
 * An event describing that the configuration of the editor has changed.
 */
export interface IConfigurationChangedEvent {
1619
	readonly canUseLayerHinting: boolean;
1620
	readonly pixelRatio: boolean;
A
Alex Dima 已提交
1621
	readonly editorClassName: boolean;
1622 1623
	readonly lineHeight: boolean;
	readonly readOnly: boolean;
1624
	readonly accessibilitySupport: boolean;
1625
	readonly multiCursorModifier: boolean;
A
Alex Dima 已提交
1626
	readonly multiCursorMergeOverlapping: boolean;
1627 1628
	readonly wordSeparators: boolean;
	readonly autoClosingBrackets: boolean;
J
Jackson Kearl 已提交
1629
	readonly autoClosingQuotes: boolean;
1630
	readonly autoSurround: boolean;
1631
	readonly autoIndent: boolean;
1632 1633 1634
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
1635
	readonly emptySelectionClipboard: boolean;
1636
	readonly copyWithSyntaxHighlighting: boolean;
1637 1638
	readonly layoutInfo: boolean;
	readonly fontInfo: boolean;
A
Alex Dima 已提交
1639
	readonly viewInfo: boolean;
1640 1641 1642
	readonly wrappingInfo: boolean;
	readonly contribInfo: boolean;
}
1643 1644 1645 1646

/**
 * @internal
 */
A
Alex Dima 已提交
1647 1648 1649 1650
export interface IEnvironmentalOptions {
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
1651
	readonly extraEditorClassName: string;
A
Alex Dima 已提交
1652 1653
	readonly isDominatedByLongLines: boolean;
	readonly lineNumbersDigitCount: number;
1654
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
1655 1656
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
1657
	readonly accessibilitySupport: AccessibilitySupport;
1658
}
1659

1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
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);
}
1670

A
Alex Dima 已提交
1671
function _booleanMap(value: { [key: string]: boolean } | undefined, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685
	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;
}

1686 1687 1688 1689 1690 1691
function _string(value: any, defaultValue: string): string {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	return value;
}
1692

A
Alex Dima 已提交
1693
function _stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: T[]): T {
1694 1695 1696 1697 1698 1699
	if (typeof value !== 'string') {
		return defaultValue;
	}
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
	}
M
Martin Aeschlimann 已提交
1700
	return value;
1701 1702 1703 1704 1705 1706 1707 1708 1709 1710
}

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;
1711
		}
1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
	}
	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 已提交
1726
function _wrappingIndentFromString(wrappingIndent: string | undefined, defaultValue: WrappingIndent): WrappingIndent {
1727 1728 1729
	if (typeof wrappingIndent !== 'string') {
		return defaultValue;
	}
1730
	if (wrappingIndent === 'same') {
1731
		return WrappingIndent.Same;
1732 1733 1734 1735
	} else if (wrappingIndent === 'indent') {
		return WrappingIndent.Indent;
	} else if (wrappingIndent === 'deepIndent') {
		return WrappingIndent.DeepIndent;
1736 1737 1738 1739 1740
	} else {
		return WrappingIndent.None;
	}
}

A
Alex Dima 已提交
1741
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string | undefined, defaultValue: TextEditorCursorBlinkingStyle): TextEditorCursorBlinkingStyle {
1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760
	if (typeof cursorBlinkingStyle !== 'string') {
		return defaultValue;
	}
	switch (cursorBlinkingStyle) {
		case 'blink':
			return TextEditorCursorBlinkingStyle.Blink;
		case 'smooth':
			return TextEditorCursorBlinkingStyle.Smooth;
		case 'phase':
			return TextEditorCursorBlinkingStyle.Phase;
		case 'expand':
			return TextEditorCursorBlinkingStyle.Expand;
		case 'visible': // maintain compatibility
		case 'solid':
			return TextEditorCursorBlinkingStyle.Solid;
	}
	return TextEditorCursorBlinkingStyle.Blink;
}

A
Alex Dima 已提交
1761
function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784
	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 {
A
Alex Dima 已提交
1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797
		let wordWrap = opts.wordWrap;
		{
			// Compatibility with old true or false values
			if (<any>wordWrap === true) {
				wordWrap = 'on';
			} else if (<any>wordWrap === false) {
				wordWrap = 'off';
			}

			wordWrap = _stringSet<'off' | 'on' | 'wordWrapColumn' | 'bounded'>(wordWrap, defaults.wordWrap, ['off', 'on', 'wordWrapColumn', 'bounded']);
		}

		const viewInfo = this._sanitizeViewInfo(opts, defaults.viewInfo);
1798
		const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
A
Alex Dima 已提交
1799

A
Alex Dima 已提交
1800
		let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey' | undefined = undefined;
1801
		if (typeof opts.multiCursorModifier === 'string') {
1802 1803
			if (opts.multiCursorModifier === 'ctrlCmd') {
				configuredMulticursorModifier = platform.isMacintosh ? 'metaKey' : 'ctrlKey';
1804
			} else {
1805
				configuredMulticursorModifier = 'altKey';
1806 1807
			}
		}
1808
		const multiCursorModifier = _stringSet<'altKey' | 'metaKey' | 'ctrlKey'>(configuredMulticursorModifier, defaults.multiCursorModifier, ['altKey', 'metaKey', 'ctrlKey']);
1809

1810 1811
		let autoClosingBrackets: EditorAutoClosingStrategy;
		let autoClosingQuotes: EditorAutoClosingStrategy;
1812
		let autoSurround: EditorAutoSurroundStrategy;
A
Alex Dima 已提交
1813
		if (typeof opts.autoClosingBrackets === 'boolean' && opts.autoClosingBrackets === false) {
1814 1815 1816
			// backwards compatibility: disable all on boolean false
			autoClosingBrackets = 'never';
			autoClosingQuotes = 'never';
1817
			autoSurround = 'never';
1818 1819 1820
		} else {
			autoClosingBrackets = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingBrackets, defaults.autoClosingBrackets, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
			autoClosingQuotes = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingQuotes, defaults.autoClosingQuotes, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
M
Matt Bierner 已提交
1821
			autoSurround = _stringSet<EditorAutoSurroundStrategy>(opts.autoSurround, defaults.autoSurround, ['languageDefined', 'brackets', 'quotes', 'never']);
J
Jackson Kearl 已提交
1822 1823
		}

A
Alex Dima 已提交
1824 1825 1826 1827 1828 1829 1830
		return {
			inDiffEditor: _boolean(opts.inDiffEditor, defaults.inDiffEditor),
			wordSeparators: _string(opts.wordSeparators, defaults.wordSeparators),
			lineNumbersMinChars: _clampedInt(opts.lineNumbersMinChars, defaults.lineNumbersMinChars, 1, 10),
			lineDecorationsWidth: (typeof opts.lineDecorationsWidth === 'undefined' ? defaults.lineDecorationsWidth : opts.lineDecorationsWidth),
			readOnly: _boolean(opts.readOnly, defaults.readOnly),
			mouseStyle: _stringSet<'text' | 'default' | 'copy'>(opts.mouseStyle, defaults.mouseStyle, ['text', 'default', 'copy']),
1831
			disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting),
A
Alex Dima 已提交
1832 1833 1834 1835 1836 1837 1838 1839
			automaticLayout: _boolean(opts.automaticLayout, defaults.automaticLayout),
			wordWrap: wordWrap,
			wordWrapColumn: _clampedInt(opts.wordWrapColumn, defaults.wordWrapColumn, 1, Constants.MAX_SAFE_SMALL_INTEGER),
			wordWrapMinified: _boolean(opts.wordWrapMinified, defaults.wordWrapMinified),
			wrappingIndent: _wrappingIndentFromString(opts.wrappingIndent, defaults.wrappingIndent),
			wordWrapBreakBeforeCharacters: _string(opts.wordWrapBreakBeforeCharacters, defaults.wordWrapBreakBeforeCharacters),
			wordWrapBreakAfterCharacters: _string(opts.wordWrapBreakAfterCharacters, defaults.wordWrapBreakAfterCharacters),
			wordWrapBreakObtrusiveCharacters: _string(opts.wordWrapBreakObtrusiveCharacters, defaults.wordWrapBreakObtrusiveCharacters),
1840 1841
			autoClosingBrackets,
			autoClosingQuotes,
1842
			autoSurround,
1843
			autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
A
Alex Dima 已提交
1844
			dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
1845
			emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard),
1846
			copyWithSyntaxHighlighting: _boolean(opts.copyWithSyntaxHighlighting, defaults.copyWithSyntaxHighlighting),
A
Alex Dima 已提交
1847
			useTabStops: _boolean(opts.useTabStops, defaults.useTabStops),
1848
			multiCursorModifier: multiCursorModifier,
A
Alex Dima 已提交
1849
			multiCursorMergeOverlapping: _boolean(opts.multiCursorMergeOverlapping, defaults.multiCursorMergeOverlapping),
1850
			accessibilitySupport: _stringSet<'auto' | 'on' | 'off'>(opts.accessibilitySupport, defaults.accessibilitySupport, ['auto', 'on', 'off']),
1851
			showUnused: _boolean(opts.showUnused, defaults.showUnused),
A
Alex Dima 已提交
1852 1853 1854 1855 1856
			viewInfo: viewInfo,
			contribInfo: contribInfo,
		};
	}

T
Tiago Ribeiro 已提交
1857
	private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions | undefined, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number, fastScrollSensitivity: number): InternalEditorScrollbarOptions {
A
Alex Dima 已提交
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879
		if (typeof opts !== 'object') {
			return defaults;
		}
		const horizontalScrollbarSize = _clampedInt(opts.horizontalScrollbarSize, defaults.horizontalScrollbarSize, 0, 1000);
		const verticalScrollbarSize = _clampedInt(opts.verticalScrollbarSize, defaults.verticalScrollbarSize, 0, 1000);
		return {
			vertical: _scrollbarVisibilityFromString(opts.vertical, defaults.vertical),
			horizontal: _scrollbarVisibilityFromString(opts.horizontal, defaults.horizontal),

			arrowSize: _clampedInt(opts.arrowSize, defaults.arrowSize, 0, 1000),
			useShadows: _boolean(opts.useShadows, defaults.useShadows),

			verticalHasArrows: _boolean(opts.verticalHasArrows, defaults.verticalHasArrows),
			horizontalHasArrows: _boolean(opts.horizontalHasArrows, defaults.horizontalHasArrows),

			horizontalScrollbarSize: horizontalScrollbarSize,
			horizontalSliderSize: _clampedInt(opts.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),

			verticalScrollbarSize: verticalScrollbarSize,
			verticalSliderSize: _clampedInt(opts.verticalSliderSize, verticalScrollbarSize, 0, 1000),

			handleMouseWheel: _boolean(opts.handleMouseWheel, defaults.handleMouseWheel),
T
Tiago Ribeiro 已提交
1880 1881
			mouseWheelScrollSensitivity: mouseWheelScrollSensitivity,
			fastScrollSensitivity: fastScrollSensitivity,
A
Alex Dima 已提交
1882 1883 1884
		};
	}

A
Alex Dima 已提交
1885
	private static _sanitizeMinimapOpts(opts: IEditorMinimapOptions | undefined, defaults: InternalEditorMinimapOptions): InternalEditorMinimapOptions {
A
Alex Dima 已提交
1886 1887 1888 1889 1890
		if (typeof opts !== 'object') {
			return defaults;
		}
		return {
			enabled: _boolean(opts.enabled, defaults.enabled),
1891
			side: _stringSet<'right' | 'left'>(opts.side, defaults.side, ['right', 'left']),
1892
			showSlider: _stringSet<'always' | 'mouseover'>(opts.showSlider, defaults.showSlider, ['always', 'mouseover']),
A
Alex Dima 已提交
1893 1894 1895 1896 1897
			renderCharacters: _boolean(opts.renderCharacters, defaults.renderCharacters),
			maxColumn: _clampedInt(opts.maxColumn, defaults.maxColumn, 1, 10000),
		};
	}

B
bissonex 已提交
1898
	private static _sanitizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
1899 1900 1901 1902 1903
		if (typeof opts !== 'object') {
			return defaults;
		}

		return {
R
rebornix 已提交
1904
			seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
1905
			autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection),
1906 1907
			globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard),
			addExtraSpaceOnTop: _boolean(opts.addExtraSpaceOnTop, defaults.addExtraSpaceOnTop)
1908 1909 1910
		};
	}

A
Alex Dima 已提交
1911
	private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions | undefined, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
		if (typeof opts !== 'object') {
			return defaults;
		}

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

B
bissonex 已提交
1922
	private static _sanitizeHoverOpts(_opts: boolean | IEditorHoverOptions | undefined, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
A
Alex Dima 已提交
1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934
		let opts: IEditorHoverOptions;
		if (typeof _opts === 'boolean') {
			opts = {
				enabled: _opts
			};
		} else if (typeof _opts === 'object') {
			opts = _opts;
		} else {
			return defaults;
		}

		return {
1935
			enabled: _boolean(opts.enabled, defaults.enabled),
1936 1937
			delay: _clampedInt(opts.delay, defaults.delay, 0, 10000),
			sticky: _boolean(opts.sticky, defaults.sticky)
A
Alex Dima 已提交
1938 1939 1940
		};
	}

1941
	private static _sanitizeSuggestOpts(opts: IEditorOptions, defaults: InternalSuggestOptions): InternalSuggestOptions {
1942
		const suggestOpts = opts.suggest || {};
1943
		return {
1944
			filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful),
1945
			snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
1946
			snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
J
Johannes Rieken 已提交
1947
			localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
1948 1949
			shareSuggestSelections: _boolean(suggestOpts.shareSuggestSelections, defaults.shareSuggestSelections),
			showIcons: _boolean(suggestOpts.showIcons, defaults.showIcons),
J
Johannes Rieken 已提交
1950
			maxVisibleSuggestions: _clampedInt(suggestOpts.maxVisibleSuggestions, defaults.maxVisibleSuggestions, 1, 15),
1951
			filteredTypes: isObject(suggestOpts.filteredTypes) ? suggestOpts.filteredTypes : Object.create(null)
1952 1953 1954
		};
	}

1955 1956 1957
	private static _santizeGotoLocationOpts(opts: IEditorOptions, defaults: InternalGoToLocationOptions): InternalGoToLocationOptions {
		const gotoOpts = opts.gotoLocation || {};
		return {
J
Johannes Rieken 已提交
1958
			multiple: _stringSet<'peek' | 'gotoAndPeek' | 'goto'>(gotoOpts.multiple, defaults.multiple, ['peek', 'gotoAndPeek', 'goto'])
1959 1960 1961
		};
	}

A
Alex Dima 已提交
1962
	private static _sanitizeTabCompletionOpts(opts: boolean | 'on' | 'off' | 'onlySnippets' | undefined, defaults: 'on' | 'off' | 'onlySnippets'): 'on' | 'off' | 'onlySnippets' {
1963 1964 1965 1966 1967 1968 1969 1970
		if (opts === false) {
			return 'off';
		} else if (opts === true) {
			return 'onlySnippets';
		} else {
			return _stringSet<'on' | 'off' | 'onlySnippets'>(opts, defaults, ['on', 'off', 'onlySnippets']);
		}
	}
1971

A
Alex Dima 已提交
1972
	private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
1973 1974 1975 1976 1977 1978 1979

		let rulers: number[] = [];
		if (Array.isArray(opts.rulers)) {
			for (let i = 0, len = opts.rulers.length; i < len; i++) {
				rulers.push(_clampedInt(opts.rulers[i], 0, 0, 10000));
			}
			rulers.sort();
1980 1981
		}

1982
		let renderLineNumbers: RenderLineNumbersType = defaults.renderLineNumbers;
A
Alex Dima 已提交
1983
		let renderCustomLineNumbers: ((lineNumber: number) => string) | null = defaults.renderCustomLineNumbers;
1984 1985

		if (typeof opts.lineNumbers !== 'undefined') {
1986
			let lineNumbers = opts.lineNumbers;
1987

1988 1989 1990 1991 1992 1993 1994 1995
			// Compatibility with old true or false values
			if (<any>lineNumbers === true) {
				lineNumbers = 'on';
			} else if (<any>lineNumbers === false) {
				lineNumbers = 'off';
			}

			if (typeof lineNumbers === 'function') {
1996
				renderLineNumbers = RenderLineNumbersType.Custom;
1997
				renderCustomLineNumbers = lineNumbers;
1998 1999
			} else if (lineNumbers === 'interval') {
				renderLineNumbers = RenderLineNumbersType.Interval;
2000
			} else if (lineNumbers === 'relative') {
2001
				renderLineNumbers = RenderLineNumbersType.Relative;
2002
			} else if (lineNumbers === 'on') {
2003
				renderLineNumbers = RenderLineNumbersType.On;
2004
			} else {
2005
				renderLineNumbers = RenderLineNumbersType.Off;
2006 2007 2008
			}
		}

A
Alex Dima 已提交
2009 2010
		const fontLigatures = _boolean(opts.fontLigatures, defaults.fontLigatures);
		const disableMonospaceOptimizations = _boolean(opts.disableMonospaceOptimizations, defaults.disableMonospaceOptimizations) || fontLigatures;
2011 2012 2013 2014 2015 2016 2017 2018 2019

		let renderWhitespace = opts.renderWhitespace;
		{
			// Compatibility with old true or false values
			if (<any>renderWhitespace === true) {
				renderWhitespace = 'boundary';
			} else if (<any>renderWhitespace === false) {
				renderWhitespace = 'none';
			}
A
Alex Dima 已提交
2020
			renderWhitespace = _stringSet<'none' | 'boundary' | 'all'>(renderWhitespace, defaults.renderWhitespace, ['none', 'boundary', 'all']);
2021 2022 2023 2024 2025 2026 2027 2028 2029 2030
		}

		let renderLineHighlight = opts.renderLineHighlight;
		{
			// Compatibility with old true or false values
			if (<any>renderLineHighlight === true) {
				renderLineHighlight = 'line';
			} else if (<any>renderLineHighlight === false) {
				renderLineHighlight = 'none';
			}
A
Alex Dima 已提交
2031
			renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']);
2032 2033
		}

A
Alex Dima 已提交
2034 2035 2036 2037 2038
		let mouseWheelScrollSensitivity = _float(opts.mouseWheelScrollSensitivity, defaults.scrollbar.mouseWheelScrollSensitivity);
		if (mouseWheelScrollSensitivity === 0) {
			// Disallow 0, as it would prevent/block scrolling
			mouseWheelScrollSensitivity = 1;
		}
T
Tiago Ribeiro 已提交
2039 2040 2041

		let fastScrollSensitivity = _float(opts.fastScrollSensitivity, defaults.scrollbar.fastScrollSensitivity);
		if (fastScrollSensitivity <= 0) {
2042
			fastScrollSensitivity = defaults.scrollbar.fastScrollSensitivity;
T
Tiago Ribeiro 已提交
2043 2044
		}
		const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity, fastScrollSensitivity);
2045 2046 2047
		const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap);

		return {
2048
			extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName),
A
Alex Dima 已提交
2049
			disableMonospaceOptimizations: disableMonospaceOptimizations,
2050
			rulers: rulers,
A
Alex Dima 已提交
2051
			ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel),
2052 2053
			renderLineNumbers: renderLineNumbers,
			renderCustomLineNumbers: renderCustomLineNumbers,
A
Alex Dima 已提交
2054
			renderFinalNewline: _boolean(opts.renderFinalNewline, defaults.renderFinalNewline),
2055 2056 2057 2058 2059 2060 2061 2062
			selectOnLineNumbers: _boolean(opts.selectOnLineNumbers, defaults.selectOnLineNumbers),
			glyphMargin: _boolean(opts.glyphMargin, defaults.glyphMargin),
			revealHorizontalRightPadding: _clampedInt(opts.revealHorizontalRightPadding, defaults.revealHorizontalRightPadding, 0, 1000),
			roundedSelection: _boolean(opts.roundedSelection, defaults.roundedSelection),
			overviewRulerLanes: _clampedInt(opts.overviewRulerLanes, defaults.overviewRulerLanes, 0, 3),
			overviewRulerBorder: _boolean(opts.overviewRulerBorder, defaults.overviewRulerBorder),
			cursorBlinking: _cursorBlinkingStyleFromString(opts.cursorBlinking, defaults.cursorBlinking),
			mouseWheelZoom: _boolean(opts.mouseWheelZoom, defaults.mouseWheelZoom),
2063
			cursorSmoothCaretAnimation: _boolean(opts.cursorSmoothCaretAnimation, defaults.cursorSmoothCaretAnimation),
2064
			cursorStyle: _cursorStyleFromString(opts.cursorStyle, defaults.cursorStyle),
2065
			cursorWidth: _clampedInt(opts.cursorWidth, defaults.cursorWidth, 0, Number.MAX_VALUE),
2066 2067
			hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler),
			scrollBeyondLastLine: _boolean(opts.scrollBeyondLastLine, defaults.scrollBeyondLastLine),
2068
			scrollBeyondLastColumn: _clampedInt(opts.scrollBeyondLastColumn, defaults.scrollBeyondLastColumn, 0, Constants.MAX_SAFE_SMALL_INTEGER),
2069
			smoothScrolling: _boolean(opts.smoothScrolling, defaults.smoothScrolling),
2070
			stopRenderingLineAfter: _clampedInt(opts.stopRenderingLineAfter, defaults.stopRenderingLineAfter, -1, Constants.MAX_SAFE_SMALL_INTEGER),
A
Alex Dima 已提交
2071 2072 2073 2074
			renderWhitespace: renderWhitespace,
			renderControlCharacters: _boolean(opts.renderControlCharacters, defaults.renderControlCharacters),
			fontLigatures: fontLigatures,
			renderIndentGuides: _boolean(opts.renderIndentGuides, defaults.renderIndentGuides),
2075
			highlightActiveIndentGuide: _boolean(opts.highlightActiveIndentGuide, defaults.highlightActiveIndentGuide),
A
Alex Dima 已提交
2076 2077 2078 2079 2080 2081 2082
			renderLineHighlight: renderLineHighlight,
			scrollbar: scrollbar,
			minimap: minimap,
			fixedOverflowWidgets: _boolean(opts.fixedOverflowWidgets, defaults.fixedOverflowWidgets),
		};
	}

2083
	private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions {
A
Alex Dima 已提交
2084 2085 2086 2087 2088 2089
		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);
		}
A
Alex Dima 已提交
2090 2091 2092 2093
		// Compatibility support for acceptSuggestionOnEnter
		if (typeof opts.acceptSuggestionOnEnter === 'boolean') {
			opts.acceptSuggestionOnEnter = opts.acceptSuggestionOnEnter ? 'on' : 'off';
		}
B
bissonex 已提交
2094
		const find = this._sanitizeFindOpts(opts.find, defaults.find);
A
Alex Dima 已提交
2095 2096
		return {
			selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard),
B
bissonex 已提交
2097
			hover: this._sanitizeHoverOpts(opts.hover, defaults.hover),
2098
			links: _boolean(opts.links, defaults.links),
2099 2100 2101
			contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
			quickSuggestions: quickSuggestions,
			quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
2102
			parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
2103 2104 2105
			formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
			formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
			suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters),
A
Alex Dima 已提交
2106
			acceptSuggestionOnEnter: _stringSet<'on' | 'smart' | 'off'>(opts.acceptSuggestionOnEnter, defaults.acceptSuggestionOnEnter, ['on', 'smart', 'off']),
2107 2108
			acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter),
			wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions),
B
Benas Svipas 已提交
2109
			suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']),
2110 2111
			suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
			suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
2112
			tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion),
2113
			suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
2114
			gotoLocation: this._santizeGotoLocationOpts(opts, defaults.gotoLocation),
2115 2116
			selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
			occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
2117
			codeLens: _boolean(opts.codeLens, defaults.codeLens),
2118
			folding: _boolean(opts.folding, defaults.folding),
2119
			foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']),
2120
			showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
2121
			matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets),
2122
			find: find,
R
rebornix 已提交
2123
			colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators),
2124 2125 2126
			lightbulbEnabled: _boolean(opts.lightbulb ? opts.lightbulb.enabled : false, defaults.lightbulbEnabled),
			codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}),
			codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000)
2127 2128 2129 2130 2131 2132 2133 2134 2135
		};
	}
}

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

2136 2137 2138
	private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: AccessibilitySupport): IValidatedEditorOptions {
		const accessibilityIsOn = (accessibilitySupport === AccessibilitySupport.Enabled);
		const accessibilityIsOff = (accessibilitySupport === AccessibilitySupport.Disabled);
2139 2140 2141 2142 2143 2144 2145
		return {
			inDiffEditor: opts.inDiffEditor,
			wordSeparators: opts.wordSeparators,
			lineNumbersMinChars: opts.lineNumbersMinChars,
			lineDecorationsWidth: opts.lineDecorationsWidth,
			readOnly: opts.readOnly,
			mouseStyle: opts.mouseStyle,
2146
			disableLayerHinting: opts.disableLayerHinting,
2147 2148 2149 2150 2151 2152 2153 2154
			automaticLayout: opts.automaticLayout,
			wordWrap: opts.wordWrap,
			wordWrapColumn: opts.wordWrapColumn,
			wordWrapMinified: opts.wordWrapMinified,
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
2155
			autoClosingBrackets: opts.autoClosingBrackets,
J
Jackson Kearl 已提交
2156
			autoClosingQuotes: opts.autoClosingQuotes,
2157
			autoSurround: opts.autoSurround,
2158
			autoIndent: opts.autoIndent,
2159 2160
			dragAndDrop: opts.dragAndDrop,
			emptySelectionClipboard: opts.emptySelectionClipboard,
2161
			copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting,
2162
			useTabStops: opts.useTabStops,
2163
			multiCursorModifier: opts.multiCursorModifier,
A
Alex Dima 已提交
2164
			multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
2165
			accessibilitySupport: opts.accessibilitySupport,
2166
			showUnused: opts.showUnused,
2167 2168 2169 2170 2171

			viewInfo: {
				extraEditorClassName: opts.viewInfo.extraEditorClassName,
				disableMonospaceOptimizations: opts.viewInfo.disableMonospaceOptimizations,
				rulers: opts.viewInfo.rulers,
2172
				ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel),
2173 2174
				renderLineNumbers: opts.viewInfo.renderLineNumbers,
				renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers,
A
Alex Dima 已提交
2175
				renderFinalNewline: opts.viewInfo.renderFinalNewline,
2176 2177 2178
				selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
				glyphMargin: opts.viewInfo.glyphMargin,
				revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding,
2179
				roundedSelection: (accessibilityIsOn ? false : opts.viewInfo.roundedSelection), // DISABLED WHEN SCREEN READER IS ATTACHED
2180 2181 2182 2183
				overviewRulerLanes: opts.viewInfo.overviewRulerLanes,
				overviewRulerBorder: opts.viewInfo.overviewRulerBorder,
				cursorBlinking: opts.viewInfo.cursorBlinking,
				mouseWheelZoom: opts.viewInfo.mouseWheelZoom,
2184
				cursorSmoothCaretAnimation: opts.viewInfo.cursorSmoothCaretAnimation,
2185
				cursorStyle: opts.viewInfo.cursorStyle,
2186
				cursorWidth: opts.viewInfo.cursorWidth,
2187 2188
				hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler,
				scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine,
2189
				scrollBeyondLastColumn: opts.viewInfo.scrollBeyondLastColumn,
2190
				smoothScrolling: opts.viewInfo.smoothScrolling,
2191
				stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
2192 2193 2194 2195
				renderWhitespace: (accessibilityIsOn ? 'none' : opts.viewInfo.renderWhitespace), // DISABLED WHEN SCREEN READER IS ATTACHED
				renderControlCharacters: (accessibilityIsOn ? false : opts.viewInfo.renderControlCharacters), // DISABLED WHEN SCREEN READER IS ATTACHED
				fontLigatures: (accessibilityIsOn ? false : opts.viewInfo.fontLigatures), // DISABLED WHEN SCREEN READER IS ATTACHED
				renderIndentGuides: (accessibilityIsOn ? false : opts.viewInfo.renderIndentGuides), // DISABLED WHEN SCREEN READER IS ATTACHED
2196
				highlightActiveIndentGuide: opts.viewInfo.highlightActiveIndentGuide,
A
Alex Dima 已提交
2197
				renderLineHighlight: opts.viewInfo.renderLineHighlight,
2198 2199
				scrollbar: opts.viewInfo.scrollbar,
				minimap: {
2200
					enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED
2201
					side: opts.viewInfo.minimap.side,
2202
					renderCharacters: opts.viewInfo.minimap.renderCharacters,
2203
					showSlider: opts.viewInfo.minimap.showSlider,
2204 2205 2206 2207 2208 2209 2210 2211
					maxColumn: opts.viewInfo.minimap.maxColumn
				},
				fixedOverflowWidgets: opts.viewInfo.fixedOverflowWidgets
			},

			contribInfo: {
				selectionClipboard: opts.contribInfo.selectionClipboard,
				hover: opts.contribInfo.hover,
2212
				links: (accessibilityIsOn ? false : opts.contribInfo.links), // DISABLED WHEN SCREEN READER IS ATTACHED
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222
				contextmenu: opts.contribInfo.contextmenu,
				quickSuggestions: opts.contribInfo.quickSuggestions,
				quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
				parameterHints: opts.contribInfo.parameterHints,
				formatOnType: opts.contribInfo.formatOnType,
				formatOnPaste: opts.contribInfo.formatOnPaste,
				suggestOnTriggerCharacters: opts.contribInfo.suggestOnTriggerCharacters,
				acceptSuggestionOnEnter: opts.contribInfo.acceptSuggestionOnEnter,
				acceptSuggestionOnCommitCharacter: opts.contribInfo.acceptSuggestionOnCommitCharacter,
				wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions,
J
Johannes Rieken 已提交
2223
				suggestSelection: opts.contribInfo.suggestSelection,
2224 2225
				suggestFontSize: opts.contribInfo.suggestFontSize,
				suggestLineHeight: opts.contribInfo.suggestLineHeight,
2226
				tabCompletion: opts.contribInfo.tabCompletion,
2227
				suggest: opts.contribInfo.suggest,
2228
				gotoLocation: opts.contribInfo.gotoLocation,
2229 2230 2231 2232
				selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
				occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
				codeLens: (accessibilityIsOn ? false : opts.contribInfo.codeLens), // DISABLED WHEN SCREEN READER IS ATTACHED
				folding: (accessibilityIsOn ? false : opts.contribInfo.folding), // DISABLED WHEN SCREEN READER IS ATTACHED
2233
				foldingStrategy: opts.contribInfo.foldingStrategy,
2234
				showFoldingControls: opts.contribInfo.showFoldingControls,
2235
				matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED
2236
				find: opts.contribInfo.find,
2237
				colorDecorators: opts.contribInfo.colorDecorators,
2238 2239 2240
				lightbulbEnabled: opts.contribInfo.lightbulbEnabled,
				codeActionsOnSave: opts.contribInfo.codeActionsOnSave,
				codeActionsOnSaveTimeout: opts.contribInfo.codeActionsOnSaveTimeout
2241 2242 2243 2244 2245 2246
			}
		};
	}

	public static createInternalEditorOptions(env: IEnvironmentalOptions, _opts: IValidatedEditorOptions) {

2247
		let accessibilitySupport: AccessibilitySupport;
2248 2249 2250 2251
		if (_opts.accessibilitySupport === 'auto') {
			// The editor reads the `accessibilitySupport` from the environment
			accessibilitySupport = env.accessibilitySupport;
		} else if (_opts.accessibilitySupport === 'on') {
2252
			accessibilitySupport = AccessibilitySupport.Enabled;
2253
		} else {
2254
			accessibilitySupport = AccessibilitySupport.Disabled;
2255 2256
		}

2257 2258
		// Disable some non critical features to get as best performance as possible
		// See https://github.com/Microsoft/vscode/issues/26730
2259
		const opts = this._tweakValidatedOptions(_opts, accessibilitySupport);
2260 2261 2262 2263 2264 2265 2266 2267

		let lineDecorationsWidth: number;
		if (typeof opts.lineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(opts.lineDecorationsWidth)) {
			const multiple = parseFloat(opts.lineDecorationsWidth.substr(0, opts.lineDecorationsWidth.length - 2));
			lineDecorationsWidth = multiple * env.fontInfo.typicalHalfwidthCharacterWidth;
		} else {
			lineDecorationsWidth = _clampedInt(opts.lineDecorationsWidth, 0, 0, 1000);
		}
A
Alex Dima 已提交
2268
		if (opts.contribInfo.folding) {
2269 2270 2271
			lineDecorationsWidth += 16;
		}

2272 2273 2274
		const layoutInfo = EditorLayoutProvider.compute({
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
A
Alex Dima 已提交
2275
			showGlyphMargin: opts.viewInfo.glyphMargin,
2276
			lineHeight: env.fontInfo.lineHeight,
2277
			showLineNumbers: (opts.viewInfo.renderLineNumbers !== RenderLineNumbersType.Off),
2278
			lineNumbersMinChars: opts.lineNumbersMinChars,
2279 2280 2281 2282
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			lineDecorationsWidth: lineDecorationsWidth,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
A
Alex Dima 已提交
2283 2284 2285 2286 2287
			verticalScrollbarWidth: opts.viewInfo.scrollbar.verticalScrollbarSize,
			horizontalScrollbarHeight: opts.viewInfo.scrollbar.horizontalScrollbarSize,
			scrollbarArrowSize: opts.viewInfo.scrollbar.arrowSize,
			verticalScrollbarHasArrows: opts.viewInfo.scrollbar.verticalHasArrows,
			minimap: opts.viewInfo.minimap.enabled,
2288
			minimapSide: opts.viewInfo.minimap.side,
A
Alex Dima 已提交
2289 2290
			minimapRenderCharacters: opts.viewInfo.minimap.renderCharacters,
			minimapMaxColumn: opts.viewInfo.minimap.maxColumn,
2291 2292 2293
			pixelRatio: env.pixelRatio
		});

A
Alex Dima 已提交
2294
		let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null;
2295
		{
A
Alex Dima 已提交
2296
			const wordWrap = opts.wordWrap;
2297 2298
			const wordWrapColumn = opts.wordWrapColumn;
			const wordWrapMinified = opts.wordWrapMinified;
2299

2300
			if (accessibilitySupport === AccessibilitySupport.Enabled) {
2301 2302 2303 2304 2305 2306 2307 2308 2309 2310
				// 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) {
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
				// 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
				};
			}
		}

A
Alex Dima 已提交
2344
		const wrappingInfo: EditorWrappingInfo = {
2345
			inDiffEditor: opts.inDiffEditor,
2346 2347 2348 2349
			isDominatedByLongLines: env.isDominatedByLongLines,
			isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
			isViewportWrapping: bareWrappingInfo.isViewportWrapping,
			wrappingColumn: bareWrappingInfo.wrappingColumn,
2350 2351 2352 2353
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
A
Alex Dima 已提交
2354
		};
2355

2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371
		let className = 'monaco-editor';
		if (opts.viewInfo.extraEditorClassName) {
			className += ' ' + opts.viewInfo.extraEditorClassName;
		}
		if (env.extraEditorClassName) {
			className += ' ' + env.extraEditorClassName;
		}
		if (opts.viewInfo.fontLigatures) {
			className += ' enable-ligatures';
		}
		if (opts.mouseStyle === 'default') {
			className += ' mouse-default';
		} else if (opts.mouseStyle === 'copy') {
			className += ' mouse-copy';
		}

2372
		return new InternalEditorOptions({
2373
			canUseLayerHinting: opts.disableLayerHinting ? false : true,
2374
			pixelRatio: env.pixelRatio,
2375
			editorClassName: className,
A
Alex Dima 已提交
2376
			lineHeight: env.fontInfo.lineHeight,
2377
			readOnly: opts.readOnly,
2378
			accessibilitySupport: accessibilitySupport,
2379
			multiCursorModifier: opts.multiCursorModifier,
A
Alex Dima 已提交
2380
			multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
2381 2382
			wordSeparators: opts.wordSeparators,
			autoClosingBrackets: opts.autoClosingBrackets,
J
Jackson Kearl 已提交
2383
			autoClosingQuotes: opts.autoClosingQuotes,
2384
			autoSurround: opts.autoSurround,
2385
			autoIndent: opts.autoIndent,
2386 2387 2388
			useTabStops: opts.useTabStops,
			tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
			dragAndDrop: opts.dragAndDrop,
2389
			emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard,
2390
			copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting,
2391 2392
			layoutInfo: layoutInfo,
			fontInfo: env.fontInfo,
A
Alex Dima 已提交
2393
			viewInfo: opts.viewInfo,
2394
			wrappingInfo: wrappingInfo,
2395 2396
			contribInfo: opts.contribInfo,
			showUnused: opts.showUnused,
2397 2398 2399 2400 2401 2402 2403 2404
		});
	}
}

/**
 * @internal
 */
export interface IEditorLayoutProviderOpts {
M
Matt Bierner 已提交
2405 2406
	readonly outerWidth: number;
	readonly outerHeight: number;
2407

M
Matt Bierner 已提交
2408 2409
	readonly showGlyphMargin: boolean;
	readonly lineHeight: number;
2410

M
Matt Bierner 已提交
2411 2412 2413
	readonly showLineNumbers: boolean;
	readonly lineNumbersMinChars: number;
	readonly lineNumbersDigitCount: number;
2414

M
Matt Bierner 已提交
2415
	readonly lineDecorationsWidth: number;
2416

M
Matt Bierner 已提交
2417 2418
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
2419

M
Matt Bierner 已提交
2420 2421 2422 2423
	readonly verticalScrollbarWidth: number;
	readonly verticalScrollbarHasArrows: boolean;
	readonly scrollbarArrowSize: number;
	readonly horizontalScrollbarHeight: number;
2424

M
Matt Bierner 已提交
2425 2426 2427 2428 2429
	readonly minimap: boolean;
	readonly minimapSide: string;
	readonly minimapRenderCharacters: boolean;
	readonly minimapMaxColumn: number;
	readonly pixelRatio: number;
2430 2431 2432 2433 2434 2435 2436 2437 2438
}

/**
 * @internal
 */
export class EditorLayoutProvider {
	public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo {
		const outerWidth = _opts.outerWidth | 0;
		const outerHeight = _opts.outerHeight | 0;
A
Alex Dima 已提交
2439
		const showGlyphMargin = _opts.showGlyphMargin;
2440
		const lineHeight = _opts.lineHeight | 0;
A
Alex Dima 已提交
2441
		const showLineNumbers = _opts.showLineNumbers;
2442 2443 2444
		const lineNumbersMinChars = _opts.lineNumbersMinChars | 0;
		const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0;
		const lineDecorationsWidth = _opts.lineDecorationsWidth | 0;
A
Alex Dima 已提交
2445 2446
		const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth;
		const maxDigitWidth = _opts.maxDigitWidth;
A
Alex Dima 已提交
2447
		const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0;
A
Alex Dima 已提交
2448
		const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows;
2449 2450
		const scrollbarArrowSize = _opts.scrollbarArrowSize | 0;
		const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0;
A
Alex Dima 已提交
2451
		const minimap = _opts.minimap;
2452
		const minimapSide = _opts.minimapSide;
A
Alex Dima 已提交
2453
		const minimapRenderCharacters = _opts.minimapRenderCharacters;
2454
		const minimapMaxColumn = _opts.minimapMaxColumn | 0;
A
Alex Dima 已提交
2455
		const pixelRatio = _opts.pixelRatio;
2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467

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

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

A
Alex Dima 已提交
2468 2469 2470 2471 2472
		let glyphMarginLeft = 0;
		let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
		let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
		let contentLeft = decorationsLeft + lineDecorationsWidth;

2473 2474 2475
		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;

		let renderMinimap: RenderMinimap;
2476
		let minimapLeft: number;
2477 2478 2479
		let minimapWidth: number;
		let contentWidth: number;
		if (!minimap) {
2480
			minimapLeft = 0;
2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494
			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:
2495 2496
			// (leaving 2px for the cursor to have space after the last character)
			// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
2497 2498 2499 2500
			// minimapWidth = viewportColumn * minimapCharWidth
			// contentWidth = remainingWidth - minimapWidth
			// What are good values for contentWidth and minimapWidth ?

2501 2502 2503 2504 2505
			// 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)
2506

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

A
Alex Dima 已提交
2514
			if (minimapSide === 'left') {
2515
				minimapLeft = 0;
A
Alex Dima 已提交
2516 2517 2518 2519
				glyphMarginLeft += minimapWidth;
				lineNumbersLeft += minimapWidth;
				decorationsLeft += minimapWidth;
				contentLeft += minimapWidth;
2520 2521
			} else {
				minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth;
2522
			}
2523 2524
		}

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

		const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);

A
Alex Dima 已提交
2530
		return {
2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550
			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,
2551
			minimapLeft: minimapLeft,
2552 2553 2554 2555 2556 2557 2558
			minimapWidth: minimapWidth,

			viewportColumn: viewportColumn,

			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

A
Alex Dima 已提交
2559
			overviewRuler: {
2560 2561 2562 2563
				top: verticalArrowSize,
				width: verticalScrollbarWidth,
				height: (outerHeight - 2 * verticalArrowSize),
				right: 0
A
Alex Dima 已提交
2564 2565
			}
		};
2566 2567
	}
}
2568 2569 2570

const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
2571
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';
2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584

/**
 * @internal
 */
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,
2585
	letterSpacing: 0,
2586 2587 2588 2589 2590 2591 2592
};

/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
D
David Lechner 已提交
2593
	indentSize: 4,
2594 2595
	insertSpaces: true,
	detectIndentation: true,
2596
	trimAutoWhitespace: true,
2597
	largeFileOptimizations: true
2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609
};

/**
 * @internal
 */
export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
	inDiffEditor: false,
	wordSeparators: USUAL_WORD_SEPARATORS,
	lineNumbersMinChars: 5,
	lineDecorationsWidth: 10,
	readOnly: false,
	mouseStyle: 'text',
2610
	disableLayerHinting: false,
2611 2612 2613 2614 2615 2616
	automaticLayout: false,
	wordWrap: 'off',
	wordWrapColumn: 80,
	wordWrapMinified: true,
	wrappingIndent: WrappingIndent.Same,
	wordWrapBreakBeforeCharacters: '([{‘“〈《「『【〔([{「£¥$£¥++',
2617
	wordWrapBreakAfterCharacters: ' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
2618
	wordWrapBreakObtrusiveCharacters: '.',
J
Jackson Kearl 已提交
2619 2620
	autoClosingBrackets: 'languageDefined',
	autoClosingQuotes: 'languageDefined',
2621
	autoSurround: 'languageDefined',
R
rebornix 已提交
2622
	autoIndent: true,
2623
	dragAndDrop: true,
2624
	emptySelectionClipboard: true,
2625
	copyWithSyntaxHighlighting: true,
2626
	useTabStops: true,
2627
	multiCursorModifier: 'altKey',
A
Alex Dima 已提交
2628
	multiCursorMergeOverlapping: true,
2629
	accessibilitySupport: 'auto',
2630
	showUnused: true,
A
Alex Dima 已提交
2631 2632

	viewInfo: {
2633
		extraEditorClassName: '',
A
Alex Dima 已提交
2634 2635 2636
		disableMonospaceOptimizations: false,
		rulers: [],
		ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
2637
		renderLineNumbers: RenderLineNumbersType.On,
A
Alex Dima 已提交
2638
		renderCustomLineNumbers: null,
2639
		renderFinalNewline: true,
A
Alex Dima 已提交
2640 2641 2642 2643 2644 2645 2646 2647
		selectOnLineNumbers: true,
		glyphMargin: true,
		revealHorizontalRightPadding: 30,
		roundedSelection: true,
		overviewRulerLanes: 2,
		overviewRulerBorder: true,
		cursorBlinking: TextEditorCursorBlinkingStyle.Blink,
		mouseWheelZoom: false,
2648
		cursorSmoothCaretAnimation: false,
A
Alex Dima 已提交
2649
		cursorStyle: TextEditorCursorStyle.Line,
2650
		cursorWidth: 0,
A
Alex Dima 已提交
2651 2652
		hideCursorInOverviewRuler: false,
		scrollBeyondLastLine: true,
2653
		scrollBeyondLastColumn: 5,
2654
		smoothScrolling: false,
A
Alex Dima 已提交
2655 2656 2657 2658
		stopRenderingLineAfter: 10000,
		renderWhitespace: 'none',
		renderControlCharacters: false,
		fontLigatures: false,
2659
		renderIndentGuides: true,
2660
		highlightActiveIndentGuide: true,
A
Alex Dima 已提交
2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674
		renderLineHighlight: 'line',
		scrollbar: {
			vertical: ScrollbarVisibility.Auto,
			horizontal: ScrollbarVisibility.Auto,
			arrowSize: 11,
			useShadows: true,
			verticalHasArrows: false,
			horizontalHasArrows: false,
			horizontalScrollbarSize: 10,
			horizontalSliderSize: 10,
			verticalScrollbarSize: 14,
			verticalSliderSize: 14,
			handleMouseWheel: true,
			mouseWheelScrollSensitivity: 1,
T
Tiago Ribeiro 已提交
2675
			fastScrollSensitivity: 5,
A
Alex Dima 已提交
2676 2677
		},
		minimap: {
2678
			enabled: true,
2679
			side: 'right',
2680
			showSlider: 'mouseover',
A
Alex Dima 已提交
2681 2682 2683 2684 2685 2686 2687 2688
			renderCharacters: true,
			maxColumn: 120
		},
		fixedOverflowWidgets: false,
	},

	contribInfo: {
		selectionClipboard: true,
A
Alex Dima 已提交
2689
		hover: {
2690
			enabled: true,
2691 2692
			delay: 300,
			sticky: true
A
Alex Dima 已提交
2693
		},
2694
		links: true,
A
Alex Dima 已提交
2695 2696 2697
		contextmenu: true,
		quickSuggestions: { other: true, comments: false, strings: false },
		quickSuggestionsDelay: 10,
2698 2699 2700 2701
		parameterHints: {
			enabled: true,
			cycle: false
		},
A
Alex Dima 已提交
2702
		formatOnType: false,
2703
		formatOnPaste: false,
A
Alex Dima 已提交
2704
		suggestOnTriggerCharacters: true,
2705
		acceptSuggestionOnEnter: 'on',
A
Alex Dima 已提交
2706 2707
		acceptSuggestionOnCommitCharacter: true,
		wordBasedSuggestions: true,
B
Benas Svipas 已提交
2708
		suggestSelection: 'recentlyUsed',
A
Alex Dima 已提交
2709 2710
		suggestFontSize: 0,
		suggestLineHeight: 0,
2711
		tabCompletion: 'off',
2712 2713
		suggest: {
			filterGraceful: true,
2714
			snippets: 'inline',
J
Johannes Rieken 已提交
2715
			snippetsPreventQuickSuggestions: true,
2716
			localityBonus: false,
2717 2718
			shareSuggestSelections: false,
			showIcons: true,
J
Johannes Rieken 已提交
2719
			maxVisibleSuggestions: 12,
2720
			filteredTypes: Object.create(null)
2721
		},
2722
		gotoLocation: {
J
Johannes Rieken 已提交
2723
			multiple: 'peek'
2724
		},
A
Alex Dima 已提交
2725 2726 2727 2728
		selectionHighlight: true,
		occurrencesHighlight: true,
		codeLens: true,
		folding: true,
2729
		foldingStrategy: 'auto',
2730
		showFoldingControls: 'mouseover',
A
Alex Dima 已提交
2731
		matchBrackets: true,
2732
		find: {
R
rebornix 已提交
2733
			seedSearchStringFromSelection: true,
2734
			autoFindInSelection: false,
2735 2736
			globalFindClipboard: false,
			addExtraSpaceOnTop: true
2737
		},
2738
		colorDecorators: true,
2739 2740 2741
		lightbulbEnabled: true,
		codeActionsOnSave: {},
		codeActionsOnSaveTimeout: 750
A
Alex Dima 已提交
2742
	},
2743
};