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

7 8
import * as nls from 'vs/nls';
import * as platform from 'vs/base/common/platform';
9 10
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
11
import { Constants } from 'vs/editor/common/core/uint';
12
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
13
import * as arrays from 'vs/base/common/arrays';
14
import * as objects from 'vs/base/common/objects';
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

/**
 * Configuration options for editor scrollbars
 */
export interface IEditorScrollbarOptions {
	/**
	 * The size of arrows (if displayed).
	 * Defaults to 11.
	 */
	arrowSize?: number;
	/**
	 * Render vertical scrollbar.
	 * Accepted values: 'auto', 'visible', 'hidden'.
	 * Defaults to 'auto'.
	 */
	vertical?: string;
	/**
	 * Render horizontal scrollbar.
	 * Accepted values: 'auto', 'visible', 'hidden'.
	 * Defaults to 'auto'.
	 */
	horizontal?: string;
	/**
	 * Cast horizontal and vertical shadows when the content is scrolled.
	 * Defaults to true.
	 */
	useShadows?: boolean;
	/**
	 * Render arrows at the top and bottom of the vertical scrollbar.
	 * Defaults to false.
	 */
	verticalHasArrows?: boolean;
	/**
	 * Render arrows at the left and right of the horizontal scrollbar.
	 * Defaults to false.
	 */
	horizontalHasArrows?: boolean;
	/**
	 * Listen to mouse wheel events and react to them by scrolling.
	 * Defaults to true.
	 */
	handleMouseWheel?: boolean;
	/**
	 * Height in pixels for the horizontal scrollbar.
	 * Defaults to 10 (px).
	 */
	horizontalScrollbarSize?: number;
	/**
	 * Width in pixels for the vertical scrollbar.
	 * Defaults to 10 (px).
	 */
	verticalScrollbarSize?: number;
	/**
	 * Width in pixels for the vertical slider.
	 * Defaults to `verticalScrollbarSize`.
	 */
	verticalSliderSize?: number;
	/**
	 * Height in pixels for the horizontal slider.
	 * Defaults to `horizontalScrollbarSize`.
	 */
	horizontalSliderSize?: number;
}

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

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

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

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

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

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

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

187 188 189 190 191
export interface ISuggestOptions {
	/**
	 * Enable graceful matching. Defaults to true.
	 */
	filterGraceful?: boolean;
192 193 194 195
	/**
	 * Prevent quick suggestions when a snippet is active. Defaults to true.
	 */
	snippetsPreventQuickSuggestions?: boolean;
196 197
}

198 199 200 201 202 203 204
/**
 * Configuration map for codeActionsOnSave
 */
export interface ICodeActionsOnSaveOptions {
	[kind: string]: boolean;
}

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

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

export enum RenderMinimap {
	None = 0,
	Small = 1,
	Large = 2,
	SmallBlocks = 3,
	LargeBlocks = 4,
}

/**
 * Describes how to indent wrapped lines.
 */
export enum WrappingIndent {
	/**
	 * No indentation => wrapped lines begin at column 1.
	 */
	None = 0,
	/**
	 * Same => wrapped lines get the same indentation as the parent.
	 */
	Same = 1,
	/**
718
	 * Indent => wrapped lines get +1 indentation toward the parent.
719
	 */
720 721 722 723 724
	Indent = 2,
	/**
	 * DeepIndent => wrapped lines get +2 indentation toward the parent.
	 */
	DeepIndent = 3
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
}

/**
 * The kind of animation in which the editor's cursor should be rendered.
 */
export enum TextEditorCursorBlinkingStyle {
	/**
	 * 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
}
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
/**
 * @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');
	}
}
774 775 776 777 778 779 780 781 782 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 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825

/**
 * 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 已提交
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
function _cursorStyleFromString(cursorStyle: string, defaultValue: TextEditorCursorStyle): TextEditorCursorStyle {
	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 已提交
846
export interface InternalEditorScrollbarOptions {
847 848 849 850 851 852 853 854 855 856 857 858 859 860
	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;
}

A
Alex Dima 已提交
861
export interface InternalEditorMinimapOptions {
862
	readonly enabled: boolean;
863
	readonly side: 'right' | 'left';
864
	readonly showSlider: 'always' | 'mouseover';
865 866 867 868
	readonly renderCharacters: boolean;
	readonly maxColumn: number;
}

869 870
export interface InternalEditorFindOptions {
	readonly seedSearchStringFromSelection: boolean;
R
rebornix 已提交
871
	readonly autoFindInSelection: boolean;
872 873 874 875
	/**
	 * @internal
	 */
	readonly globalFindClipboard: boolean;
876 877
}

A
Alex Dima 已提交
878 879
export interface InternalEditorHoverOptions {
	readonly enabled: boolean;
880
	readonly delay: number;
881
	readonly sticky: boolean;
A
Alex Dima 已提交
882 883
}

884 885
export interface InternalSuggestOptions {
	readonly filterGraceful: boolean;
886
	readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
887
	readonly snippetsPreventQuickSuggestions: boolean;
888 889
}

890 891 892 893 894
export interface InternalParameterHintOptions {
	readonly enabled: boolean;
	readonly cycle: boolean;
}

A
Alex Dima 已提交
895
export interface EditorWrappingInfo {
896 897 898 899 900 901 902 903 904 905 906
	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;
}

907 908 909 910
export const enum RenderLineNumbersType {
	Off = 0,
	On = 1,
	Relative = 2,
911 912
	Interval = 3,
	Custom = 4
913 914
}

A
Alex Dima 已提交
915
export interface InternalEditorViewOptions {
916
	readonly extraEditorClassName: string;
917 918 919
	readonly disableMonospaceOptimizations: boolean;
	readonly rulers: number[];
	readonly ariaLabel: string;
920
	readonly renderLineNumbers: RenderLineNumbersType;
921 922 923 924 925 926 927 928 929 930
	readonly renderCustomLineNumbers: (lineNumber: number) => string;
	readonly selectOnLineNumbers: boolean;
	readonly glyphMargin: boolean;
	readonly revealHorizontalRightPadding: number;
	readonly roundedSelection: boolean;
	readonly overviewRulerLanes: number;
	readonly overviewRulerBorder: boolean;
	readonly cursorBlinking: TextEditorCursorBlinkingStyle;
	readonly mouseWheelZoom: boolean;
	readonly cursorStyle: TextEditorCursorStyle;
931
	readonly cursorWidth: number;
932 933
	readonly hideCursorInOverviewRuler: boolean;
	readonly scrollBeyondLastLine: boolean;
934
	readonly scrollBeyondLastColumn: number;
935
	readonly smoothScrolling: boolean;
936 937 938 939 940
	readonly stopRenderingLineAfter: number;
	readonly renderWhitespace: 'none' | 'boundary' | 'all';
	readonly renderControlCharacters: boolean;
	readonly fontLigatures: boolean;
	readonly renderIndentGuides: boolean;
941
	readonly highlightActiveIndentGuide: boolean;
942 943 944 945 946 947
	readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
	readonly scrollbar: InternalEditorScrollbarOptions;
	readonly minimap: InternalEditorMinimapOptions;
	readonly fixedOverflowWidgets: boolean;
}

A
Alex Dima 已提交
948
export interface EditorContribOptions {
949
	readonly selectionClipboard: boolean;
A
Alex Dima 已提交
950
	readonly hover: InternalEditorHoverOptions;
951
	readonly links: boolean;
952 953 954
	readonly contextmenu: boolean;
	readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
	readonly quickSuggestionsDelay: number;
955
	readonly parameterHints: InternalParameterHintOptions;
956 957 958 959
	readonly iconsInSuggestions: boolean;
	readonly formatOnType: boolean;
	readonly formatOnPaste: boolean;
	readonly suggestOnTriggerCharacters: boolean;
960
	readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off';
961
	readonly acceptSuggestionOnCommitCharacter: boolean;
962
	// readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
963
	readonly wordBasedSuggestions: boolean;
B
Benas Svipas 已提交
964
	readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
965 966
	readonly suggestFontSize: number;
	readonly suggestLineHeight: number;
967
	readonly suggest: InternalSuggestOptions;
968 969 970 971
	readonly selectionHighlight: boolean;
	readonly occurrencesHighlight: boolean;
	readonly codeLens: boolean;
	readonly folding: boolean;
972
	readonly foldingStrategy: 'auto' | 'indentation';
973
	readonly showFoldingControls: 'always' | 'mouseover';
974
	readonly matchBrackets: boolean;
975
	readonly find: InternalEditorFindOptions;
R
rebornix 已提交
976
	readonly colorDecorators: boolean;
977
	readonly lightbulbEnabled: boolean;
978 979
	readonly codeActionsOnSave: ICodeActionsOnSaveOptions;
	readonly codeActionsOnSaveTimeout: number;
980 981
}

982 983 984 985 986 987 988 989 990 991 992 993
/**
 * 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';
994
	readonly disableLayerHinting: boolean;
995 996 997 998 999 1000 1001 1002
	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 已提交
1003 1004 1005
	readonly autoClosingBrackets: EditorAutoClosingStrategy;
	readonly autoClosingQuotes: EditorAutoClosingStrategy;
	readonly autoWrapping: EditorAutoWrappingStrategy;
1006
	readonly autoIndent: boolean;
1007 1008 1009
	readonly dragAndDrop: boolean;
	readonly emptySelectionClipboard: boolean;
	readonly useTabStops: boolean;
1010
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1011
	readonly multiCursorMergeOverlapping: boolean;
1012
	readonly accessibilitySupport: 'auto' | 'off' | 'on';
1013
	readonly showUnused: boolean;
1014 1015 1016 1017 1018

	readonly viewInfo: InternalEditorViewOptions;
	readonly contribInfo: EditorContribOptions;
}

1019 1020 1021 1022 1023 1024
/**
 * Internal configuration options (transformed or computed) for the editor.
 */
export class InternalEditorOptions {
	readonly _internalEditorOptionsBrand: void;

1025
	readonly canUseLayerHinting: boolean;
1026
	readonly pixelRatio: number;
A
Alex Dima 已提交
1027
	readonly editorClassName: string;
A
Alex Dima 已提交
1028
	readonly lineHeight: number;
1029
	readonly readOnly: boolean;
1030 1031 1032 1033
	/**
	 * @internal
	 */
	readonly accessibilitySupport: platform.AccessibilitySupport;
1034
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1035
	readonly multiCursorMergeOverlapping: boolean;
1036
	readonly showUnused: boolean;
A
Alex Dima 已提交
1037

1038 1039
	// ---- cursor options
	readonly wordSeparators: string;
J
Jackson Kearl 已提交
1040 1041 1042
	readonly autoClosingBrackets: EditorAutoClosingStrategy;
	readonly autoClosingQuotes: EditorAutoClosingStrategy;
	readonly autoWrapping: EditorAutoWrappingStrategy;
1043
	readonly autoIndent: boolean;
1044 1045 1046
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
1047
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
1048

1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
	// ---- grouped options
	readonly layoutInfo: EditorLayoutInfo;
	readonly fontInfo: FontInfo;
	readonly viewInfo: InternalEditorViewOptions;
	readonly wrappingInfo: EditorWrappingInfo;
	readonly contribInfo: EditorContribOptions;

	/**
	 * @internal
	 */
	constructor(source: {
1060
		canUseLayerHinting: boolean;
1061
		pixelRatio: number;
A
Alex Dima 已提交
1062
		editorClassName: string;
1063 1064
		lineHeight: number;
		readOnly: boolean;
1065
		accessibilitySupport: platform.AccessibilitySupport;
1066
		multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
1067
		multiCursorMergeOverlapping: boolean;
1068
		wordSeparators: string;
J
Jackson Kearl 已提交
1069 1070 1071
		autoClosingBrackets: EditorAutoClosingStrategy;
		autoClosingQuotes: EditorAutoClosingStrategy;
		autoWrapping: EditorAutoWrappingStrategy;
1072
		autoIndent: boolean;
1073 1074 1075
		useTabStops: boolean;
		tabFocusMode: boolean;
		dragAndDrop: boolean;
1076
		emptySelectionClipboard: boolean;
1077 1078 1079 1080 1081
		layoutInfo: EditorLayoutInfo;
		fontInfo: FontInfo;
		viewInfo: InternalEditorViewOptions;
		wrappingInfo: EditorWrappingInfo;
		contribInfo: EditorContribOptions;
1082
		showUnused: boolean;
1083
	}) {
1084
		this.canUseLayerHinting = source.canUseLayerHinting;
1085 1086
		this.pixelRatio = source.pixelRatio;
		this.editorClassName = source.editorClassName;
1087
		this.lineHeight = source.lineHeight | 0;
1088
		this.readOnly = source.readOnly;
1089
		this.accessibilitySupport = source.accessibilitySupport;
1090
		this.multiCursorModifier = source.multiCursorModifier;
A
Alex Dima 已提交
1091
		this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping;
1092 1093
		this.wordSeparators = source.wordSeparators;
		this.autoClosingBrackets = source.autoClosingBrackets;
J
Jackson Kearl 已提交
1094
		this.autoClosingQuotes = source.autoClosingQuotes;
J
Jackson Kearl 已提交
1095
		this.autoWrapping = source.autoWrapping;
1096
		this.autoIndent = source.autoIndent;
1097 1098 1099
		this.useTabStops = source.useTabStops;
		this.tabFocusMode = source.tabFocusMode;
		this.dragAndDrop = source.dragAndDrop;
1100
		this.emptySelectionClipboard = source.emptySelectionClipboard;
1101 1102 1103 1104 1105
		this.layoutInfo = source.layoutInfo;
		this.fontInfo = source.fontInfo;
		this.viewInfo = source.viewInfo;
		this.wrappingInfo = source.wrappingInfo;
		this.contribInfo = source.contribInfo;
1106
		this.showUnused = source.showUnused;
1107 1108 1109 1110 1111 1112 1113
	}

	/**
	 * @internal
	 */
	public equals(other: InternalEditorOptions): boolean {
		return (
1114
			this.canUseLayerHinting === other.canUseLayerHinting
1115
			&& this.pixelRatio === other.pixelRatio
A
Alex Dima 已提交
1116 1117
			&& this.editorClassName === other.editorClassName
			&& this.lineHeight === other.lineHeight
1118
			&& this.readOnly === other.readOnly
1119
			&& this.accessibilitySupport === other.accessibilitySupport
1120
			&& this.multiCursorModifier === other.multiCursorModifier
A
Alex Dima 已提交
1121
			&& this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping
1122
			&& this.wordSeparators === other.wordSeparators
J
Jackson Kearl 已提交
1123 1124 1125
			&& this.autoClosingBrackets === other.autoClosingBrackets
			&& this.autoClosingQuotes === other.autoClosingQuotes
			&& this.autoWrapping === other.autoWrapping
1126
			&& this.autoIndent === other.autoIndent
1127 1128 1129
			&& this.useTabStops === other.useTabStops
			&& this.tabFocusMode === other.tabFocusMode
			&& this.dragAndDrop === other.dragAndDrop
1130
			&& this.showUnused === other.showUnused
1131
			&& this.emptySelectionClipboard === other.emptySelectionClipboard
A
Alex Dima 已提交
1132
			&& InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, other.layoutInfo)
1133
			&& this.fontInfo.equals(other.fontInfo)
A
Alex Dima 已提交
1134 1135 1136
			&& InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo)
			&& InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, other.wrappingInfo)
			&& InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo)
1137 1138 1139 1140 1141 1142 1143 1144
		);
	}

	/**
	 * @internal
	 */
	public createChangeEvent(newOpts: InternalEditorOptions): IConfigurationChangedEvent {
		return {
1145
			canUseLayerHinting: (this.canUseLayerHinting !== newOpts.canUseLayerHinting),
1146
			pixelRatio: (this.pixelRatio !== newOpts.pixelRatio),
A
Alex Dima 已提交
1147
			editorClassName: (this.editorClassName !== newOpts.editorClassName),
1148 1149
			lineHeight: (this.lineHeight !== newOpts.lineHeight),
			readOnly: (this.readOnly !== newOpts.readOnly),
1150
			accessibilitySupport: (this.accessibilitySupport !== newOpts.accessibilitySupport),
1151
			multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier),
A
Alex Dima 已提交
1152
			multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping),
1153
			wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
J
Jackson Kearl 已提交
1154 1155 1156
			autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
			autoClosingQuotes: (this.autoClosingQuotes !== newOpts.autoClosingQuotes),
			autoWrapping: (this.autoWrapping !== newOpts.autoWrapping),
1157
			autoIndent: (this.autoIndent !== newOpts.autoIndent),
1158 1159 1160
			useTabStops: (this.useTabStops !== newOpts.useTabStops),
			tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
			dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop),
1161
			emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard),
A
Alex Dima 已提交
1162
			layoutInfo: (!InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, newOpts.layoutInfo)),
1163
			fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
A
Alex Dima 已提交
1164 1165
			viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)),
			wrappingInfo: (!InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, newOpts.wrappingInfo)),
1166
			contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo))
1167 1168 1169
		};
	}

A
Alex Dima 已提交
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
	/**
	 * @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
1190
			&& a.minimapLeft === b.minimapLeft
A
Alex Dima 已提交
1191 1192 1193 1194 1195 1196 1197
			&& a.minimapWidth === b.minimapWidth
			&& a.viewportColumn === b.viewportColumn
			&& a.verticalScrollbarWidth === b.verticalScrollbarWidth
			&& a.horizontalScrollbarHeight === b.horizontalScrollbarHeight
			&& this._equalsOverviewRuler(a.overviewRuler, b.overviewRuler)
		);
	}
1198 1199

	/**
A
Alex Dima 已提交
1200
	 * @internal
1201
	 */
A
Alex Dima 已提交
1202 1203 1204 1205 1206 1207 1208 1209 1210
	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
		);
	}

1211
	/**
A
Alex Dima 已提交
1212
	 * @internal
1213
	 */
A
Alex Dima 已提交
1214 1215
	private static _equalsViewOptions(a: InternalEditorViewOptions, b: InternalEditorViewOptions): boolean {
		return (
1216
			a.extraEditorClassName === b.extraEditorClassName
A
Alex Dima 已提交
1217
			&& a.disableMonospaceOptimizations === b.disableMonospaceOptimizations
1218
			&& arrays.equals(a.rulers, b.rulers)
A
Alex Dima 已提交
1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
			&& a.ariaLabel === b.ariaLabel
			&& a.renderLineNumbers === b.renderLineNumbers
			&& a.renderCustomLineNumbers === b.renderCustomLineNumbers
			&& 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
			&& a.cursorStyle === b.cursorStyle
1231
			&& a.cursorWidth === b.cursorWidth
A
Alex Dima 已提交
1232 1233
			&& a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler
			&& a.scrollBeyondLastLine === b.scrollBeyondLastLine
1234
			&& a.scrollBeyondLastColumn === b.scrollBeyondLastColumn
1235
			&& a.smoothScrolling === b.smoothScrolling
A
Alex Dima 已提交
1236 1237 1238 1239 1240
			&& a.stopRenderingLineAfter === b.stopRenderingLineAfter
			&& a.renderWhitespace === b.renderWhitespace
			&& a.renderControlCharacters === b.renderControlCharacters
			&& a.fontLigatures === b.fontLigatures
			&& a.renderIndentGuides === b.renderIndentGuides
A
Alex Dima 已提交
1241
			&& a.highlightActiveIndentGuide === b.highlightActiveIndentGuide
A
Alex Dima 已提交
1242 1243 1244 1245 1246 1247 1248
			&& a.renderLineHighlight === b.renderLineHighlight
			&& this._equalsScrollbarOptions(a.scrollbar, b.scrollbar)
			&& this._equalsMinimapOptions(a.minimap, b.minimap)
			&& a.fixedOverflowWidgets === b.fixedOverflowWidgets
		);
	}

1249
	/**
A
Alex Dima 已提交
1250
	 * @internal
1251
	 */
A
Alex Dima 已提交
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
	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
		);
	}

1269
	/**
A
Alex Dima 已提交
1270
	 * @internal
1271
	 */
A
Alex Dima 已提交
1272 1273 1274
	private static _equalsMinimapOptions(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean {
		return (
			a.enabled === b.enabled
1275
			&& a.side === b.side
1276
			&& a.showSlider === b.showSlider
A
Alex Dima 已提交
1277 1278 1279 1280 1281
			&& a.renderCharacters === b.renderCharacters
			&& a.maxColumn === b.maxColumn
		);
	}

1282 1283 1284 1285 1286 1287
	/**
	 * @internal
	 */
	private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
		return (
			a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
R
rebornix 已提交
1288
			&& a.autoFindInSelection === b.autoFindInSelection
1289
			&& a.globalFindClipboard === b.globalFindClipboard
1290 1291 1292
		);
	}

1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
	/**
	 * @internal
	 */
	private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
		return (
			a.enabled === b.enabled
			&& a.cycle === b.cycle
		);
	}

A
Alex Dima 已提交
1303 1304 1305 1306 1307 1308
	/**
	 * @internal
	 */
	private static _equalsHoverOptions(a: InternalEditorHoverOptions, b: InternalEditorHoverOptions): boolean {
		return (
			a.enabled === b.enabled
1309
			&& a.delay === b.delay
1310
			&& a.sticky === b.sticky
A
Alex Dima 已提交
1311 1312 1313
		);
	}

1314 1315 1316
	/**
	 * @internal
	 */
1317
	private static _equalsSuggestOptions(a: InternalSuggestOptions, b: InternalSuggestOptions): any {
1318 1319 1320 1321 1322
		if (a === b) {
			return true;
		} else if (!a || !b) {
			return false;
		} else {
1323 1324 1325
			return a.filterGraceful === b.filterGraceful
				&& a.snippets === b.snippets
				&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions;
1326 1327 1328
		}
	}

1329 1330 1331
	/**
	 * @internal
	 */
A
Alex Dima 已提交
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343
	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
		);
1344 1345 1346 1347 1348
	}

	/**
	 * @internal
	 */
A
Alex Dima 已提交
1349 1350 1351
	private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
		return (
			a.selectionClipboard === b.selectionClipboard
A
Alex Dima 已提交
1352
			&& this._equalsHoverOptions(a.hover, b.hover)
1353
			&& a.links === b.links
A
Alex Dima 已提交
1354 1355 1356
			&& a.contextmenu === b.contextmenu
			&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
			&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
1357
			&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
A
Alex Dima 已提交
1358 1359 1360 1361 1362 1363 1364
			&& a.iconsInSuggestions === b.iconsInSuggestions
			&& 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 已提交
1365
			&& a.suggestSelection === b.suggestSelection
A
Alex Dima 已提交
1366 1367
			&& a.suggestFontSize === b.suggestFontSize
			&& a.suggestLineHeight === b.suggestLineHeight
1368
			&& this._equalsSuggestOptions(a.suggest, b.suggest)
A
Alex Dima 已提交
1369 1370 1371 1372
			&& a.selectionHighlight === b.selectionHighlight
			&& a.occurrencesHighlight === b.occurrencesHighlight
			&& a.codeLens === b.codeLens
			&& a.folding === b.folding
1373
			&& a.foldingStrategy === b.foldingStrategy
1374
			&& a.showFoldingControls === b.showFoldingControls
A
Alex Dima 已提交
1375
			&& a.matchBrackets === b.matchBrackets
1376
			&& this._equalFindOptions(a.find, b.find)
R
rebornix 已提交
1377
			&& a.colorDecorators === b.colorDecorators
1378 1379
			&& objects.equals(a.codeActionsOnSave, b.codeActionsOnSave)
			&& a.codeActionsOnSaveTimeout === b.codeActionsOnSaveTimeout
1380
			&& a.lightbulbEnabled === b.lightbulbEnabled
A
Alex Dima 已提交
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393
		);
	}

	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;
		}
1394
		return (
A
Alex Dima 已提交
1395 1396 1397
			a.comments === b.comments
			&& a.other === b.other
			&& a.strings === b.strings
1398 1399 1400 1401
		);
	}
}

A
Alex Dima 已提交
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423
/**
 * 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;
}

1424 1425 1426
/**
 * The internal layout details of the editor.
 */
A
Alex Dima 已提交
1427
export interface EditorLayoutInfo {
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489

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

1490 1491 1492 1493
	/**
	 * The position for the minimap
	 */
	readonly minimapLeft: number;
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527
	/**
	 * 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 {
1528
	readonly canUseLayerHinting: boolean;
1529
	readonly pixelRatio: boolean;
A
Alex Dima 已提交
1530
	readonly editorClassName: boolean;
1531 1532
	readonly lineHeight: boolean;
	readonly readOnly: boolean;
1533
	readonly accessibilitySupport: boolean;
1534
	readonly multiCursorModifier: boolean;
A
Alex Dima 已提交
1535
	readonly multiCursorMergeOverlapping: boolean;
1536 1537
	readonly wordSeparators: boolean;
	readonly autoClosingBrackets: boolean;
J
Jackson Kearl 已提交
1538
	readonly autoClosingQuotes: boolean;
J
Jackson Kearl 已提交
1539
	readonly autoWrapping: boolean;
1540
	readonly autoIndent: boolean;
1541 1542 1543
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
1544
	readonly emptySelectionClipboard: boolean;
1545 1546
	readonly layoutInfo: boolean;
	readonly fontInfo: boolean;
A
Alex Dima 已提交
1547
	readonly viewInfo: boolean;
1548 1549 1550
	readonly wrappingInfo: boolean;
	readonly contribInfo: boolean;
}
1551 1552 1553 1554

/**
 * @internal
 */
A
Alex Dima 已提交
1555 1556 1557 1558
export interface IEnvironmentalOptions {
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
1559
	readonly extraEditorClassName: string;
A
Alex Dima 已提交
1560 1561
	readonly isDominatedByLongLines: boolean;
	readonly lineNumbersDigitCount: number;
1562
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
1563 1564
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
1565
	readonly accessibilitySupport: platform.AccessibilitySupport;
1566
}
1567

1568 1569 1570 1571 1572 1573 1574 1575 1576 1577
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);
}
1578

1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593
function _booleanMap(value: { [key: string]: boolean }, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
	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;
}

1594 1595 1596 1597 1598 1599
function _string(value: any, defaultValue: string): string {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	return value;
}
1600

M
Martin Aeschlimann 已提交
1601
function _stringSet<T>(value: T, defaultValue: T, allowedValues: T[]): T {
1602 1603 1604 1605 1606 1607
	if (typeof value !== 'string') {
		return defaultValue;
	}
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
	}
M
Martin Aeschlimann 已提交
1608
	return value;
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
}

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;
1619
		}
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637
	}
	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;
}

function _wrappingIndentFromString(wrappingIndent: string, defaultValue: WrappingIndent): WrappingIndent {
	if (typeof wrappingIndent !== 'string') {
		return defaultValue;
	}
1638
	if (wrappingIndent === 'same') {
1639
		return WrappingIndent.Same;
1640 1641 1642 1643
	} else if (wrappingIndent === 'indent') {
		return WrappingIndent.Indent;
	} else if (wrappingIndent === 'deepIndent') {
		return WrappingIndent.DeepIndent;
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692
	} else {
		return WrappingIndent.None;
	}
}

function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string, defaultValue: TextEditorCursorBlinkingStyle): TextEditorCursorBlinkingStyle {
	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;
}

function _scrollbarVisibilityFromString(visibility: string, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
	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 已提交
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705
		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);
1706
		const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
A
Alex Dima 已提交
1707

1708
		let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey';
1709
		if (typeof opts.multiCursorModifier === 'string') {
1710 1711
			if (opts.multiCursorModifier === 'ctrlCmd') {
				configuredMulticursorModifier = platform.isMacintosh ? 'metaKey' : 'ctrlKey';
1712
			} else {
1713
				configuredMulticursorModifier = 'altKey';
1714 1715
			}
		}
1716
		const multiCursorModifier = _stringSet<'altKey' | 'metaKey' | 'ctrlKey'>(configuredMulticursorModifier, defaults.multiCursorModifier, ['altKey', 'metaKey', 'ctrlKey']);
1717

1718 1719 1720
		let autoClosingBrackets: EditorAutoClosingStrategy;
		let autoClosingQuotes: EditorAutoClosingStrategy;
		let autoWrapping: EditorAutoWrappingStrategy;
A
Alex Dima 已提交
1721
		if (typeof opts.autoClosingBrackets === 'boolean' && opts.autoClosingBrackets === false) {
1722 1723 1724 1725 1726 1727 1728 1729
			// backwards compatibility: disable all on boolean false
			autoClosingBrackets = 'never';
			autoClosingQuotes = 'never';
			autoWrapping = 'never';
		} else {
			autoClosingBrackets = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingBrackets, defaults.autoClosingBrackets, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
			autoClosingQuotes = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingQuotes, defaults.autoClosingQuotes, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
			autoWrapping = _stringSet<EditorAutoWrappingStrategy>(opts.autoWrapping, defaults.autoWrapping, ['always', 'brackets', 'quotes', 'never'], );
J
Jackson Kearl 已提交
1730 1731
		}

A
Alex Dima 已提交
1732 1733 1734 1735 1736 1737 1738
		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']),
1739
			disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting),
A
Alex Dima 已提交
1740 1741 1742 1743 1744 1745 1746 1747
			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),
1748 1749 1750
			autoClosingBrackets,
			autoClosingQuotes,
			autoWrapping,
1751
			autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
A
Alex Dima 已提交
1752
			dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
1753
			emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard),
A
Alex Dima 已提交
1754
			useTabStops: _boolean(opts.useTabStops, defaults.useTabStops),
1755
			multiCursorModifier: multiCursorModifier,
A
Alex Dima 已提交
1756
			multiCursorMergeOverlapping: _boolean(opts.multiCursorMergeOverlapping, defaults.multiCursorMergeOverlapping),
1757
			accessibilitySupport: _stringSet<'auto' | 'on' | 'off'>(opts.accessibilitySupport, defaults.accessibilitySupport, ['auto', 'on', 'off']),
1758
			showUnused: _boolean(opts.showUnused, defaults.showUnused),
A
Alex Dima 已提交
1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796
			viewInfo: viewInfo,
			contribInfo: contribInfo,
		};
	}

	private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number): InternalEditorScrollbarOptions {
		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),
			mouseWheelScrollSensitivity: mouseWheelScrollSensitivity
		};
	}

	private static _sanitizeMinimapOpts(opts: IEditorMinimapOptions, defaults: InternalEditorMinimapOptions): InternalEditorMinimapOptions {
		if (typeof opts !== 'object') {
			return defaults;
		}
		return {
			enabled: _boolean(opts.enabled, defaults.enabled),
1797
			side: _stringSet<'right' | 'left'>(opts.side, defaults.side, ['right', 'left']),
1798
			showSlider: _stringSet<'always' | 'mouseover'>(opts.showSlider, defaults.showSlider, ['always', 'mouseover']),
A
Alex Dima 已提交
1799 1800 1801 1802 1803
			renderCharacters: _boolean(opts.renderCharacters, defaults.renderCharacters),
			maxColumn: _clampedInt(opts.maxColumn, defaults.maxColumn, 1, 10000),
		};
	}

1804 1805 1806 1807 1808 1809
	private static _santizeFindOpts(opts: IEditorFindOptions, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
		if (typeof opts !== 'object') {
			return defaults;
		}

		return {
R
rebornix 已提交
1810
			seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
1811 1812
			autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection),
			globalFindClipboard: _boolean(opts.globalFindClipboard, defaults.globalFindClipboard)
1813 1814 1815
		};
	}

1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
	private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
		if (typeof opts !== 'object') {
			return defaults;
		}

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

A
Alex Dima 已提交
1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839
	private static _santizeHoverOpts(_opts: boolean | IEditorHoverOptions, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
		let opts: IEditorHoverOptions;
		if (typeof _opts === 'boolean') {
			opts = {
				enabled: _opts
			};
		} else if (typeof _opts === 'object') {
			opts = _opts;
		} else {
			return defaults;
		}

		return {
1840
			enabled: _boolean(opts.enabled, defaults.enabled),
1841 1842
			delay: _clampedInt(opts.delay, defaults.delay, 0, 10000),
			sticky: _boolean(opts.sticky, defaults.sticky)
A
Alex Dima 已提交
1843 1844 1845
		};
	}

1846
	private static _sanitizeSuggestOpts(opts: IEditorOptions, defaults: InternalSuggestOptions): InternalSuggestOptions {
1847
		const suggestOpts = opts.suggest || {};
1848
		return {
1849
			filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful),
1850
			snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
1851
			snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
1852 1853 1854 1855
		};
	}


A
Alex Dima 已提交
1856
	private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
1857 1858 1859 1860 1861 1862 1863

		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();
1864 1865
		}

1866
		let renderLineNumbers: RenderLineNumbersType = defaults.renderLineNumbers;
1867 1868 1869
		let renderCustomLineNumbers: (lineNumber: number) => string = defaults.renderCustomLineNumbers;

		if (typeof opts.lineNumbers !== 'undefined') {
1870
			let lineNumbers = opts.lineNumbers;
1871

1872 1873 1874 1875 1876 1877 1878 1879
			// Compatibility with old true or false values
			if (<any>lineNumbers === true) {
				lineNumbers = 'on';
			} else if (<any>lineNumbers === false) {
				lineNumbers = 'off';
			}

			if (typeof lineNumbers === 'function') {
1880
				renderLineNumbers = RenderLineNumbersType.Custom;
1881
				renderCustomLineNumbers = lineNumbers;
1882 1883
			} else if (lineNumbers === 'interval') {
				renderLineNumbers = RenderLineNumbersType.Interval;
1884
			} else if (lineNumbers === 'relative') {
1885
				renderLineNumbers = RenderLineNumbersType.Relative;
1886
			} else if (lineNumbers === 'on') {
1887
				renderLineNumbers = RenderLineNumbersType.On;
1888
			} else {
1889
				renderLineNumbers = RenderLineNumbersType.Off;
1890 1891 1892
			}
		}

A
Alex Dima 已提交
1893 1894
		const fontLigatures = _boolean(opts.fontLigatures, defaults.fontLigatures);
		const disableMonospaceOptimizations = _boolean(opts.disableMonospaceOptimizations, defaults.disableMonospaceOptimizations) || fontLigatures;
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917

		let renderWhitespace = opts.renderWhitespace;
		{
			// Compatibility with old true or false values
			if (<any>renderWhitespace === true) {
				renderWhitespace = 'boundary';
			} else if (<any>renderWhitespace === false) {
				renderWhitespace = 'none';
			}
			renderWhitespace = _stringSet<'none' | 'boundary' | 'all'>(opts.renderWhitespace, defaults.renderWhitespace, ['none', 'boundary', 'all']);
		}

		let renderLineHighlight = opts.renderLineHighlight;
		{
			// Compatibility with old true or false values
			if (<any>renderLineHighlight === true) {
				renderLineHighlight = 'line';
			} else if (<any>renderLineHighlight === false) {
				renderLineHighlight = 'none';
			}
			renderLineHighlight = _stringSet<'none' | 'gutter' | 'line' | 'all'>(opts.renderLineHighlight, defaults.renderLineHighlight, ['none', 'gutter', 'line', 'all']);
		}

A
Alex Dima 已提交
1918 1919 1920 1921 1922
		let mouseWheelScrollSensitivity = _float(opts.mouseWheelScrollSensitivity, defaults.scrollbar.mouseWheelScrollSensitivity);
		if (mouseWheelScrollSensitivity === 0) {
			// Disallow 0, as it would prevent/block scrolling
			mouseWheelScrollSensitivity = 1;
		}
A
Alex Dima 已提交
1923
		const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity);
1924 1925 1926
		const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap);

		return {
1927
			extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName),
A
Alex Dima 已提交
1928
			disableMonospaceOptimizations: disableMonospaceOptimizations,
1929
			rulers: rulers,
A
Alex Dima 已提交
1930
			ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel),
1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941
			renderLineNumbers: renderLineNumbers,
			renderCustomLineNumbers: renderCustomLineNumbers,
			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),
			cursorStyle: _cursorStyleFromString(opts.cursorStyle, defaults.cursorStyle),
1942
			cursorWidth: _clampedInt(opts.cursorWidth, defaults.cursorWidth, 0, Number.MAX_VALUE),
1943 1944
			hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler),
			scrollBeyondLastLine: _boolean(opts.scrollBeyondLastLine, defaults.scrollBeyondLastLine),
1945
			scrollBeyondLastColumn: _clampedInt(opts.scrollBeyondLastColumn, defaults.scrollBeyondLastColumn, 0, Constants.MAX_SAFE_SMALL_INTEGER),
1946
			smoothScrolling: _boolean(opts.smoothScrolling, defaults.smoothScrolling),
1947
			stopRenderingLineAfter: _clampedInt(opts.stopRenderingLineAfter, defaults.stopRenderingLineAfter, -1, Constants.MAX_SAFE_SMALL_INTEGER),
A
Alex Dima 已提交
1948 1949 1950 1951
			renderWhitespace: renderWhitespace,
			renderControlCharacters: _boolean(opts.renderControlCharacters, defaults.renderControlCharacters),
			fontLigatures: fontLigatures,
			renderIndentGuides: _boolean(opts.renderIndentGuides, defaults.renderIndentGuides),
1952
			highlightActiveIndentGuide: _boolean(opts.highlightActiveIndentGuide, defaults.highlightActiveIndentGuide),
A
Alex Dima 已提交
1953 1954 1955 1956 1957 1958 1959
			renderLineHighlight: renderLineHighlight,
			scrollbar: scrollbar,
			minimap: minimap,
			fixedOverflowWidgets: _boolean(opts.fixedOverflowWidgets, defaults.fixedOverflowWidgets),
		};
	}

1960
	private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions {
A
Alex Dima 已提交
1961 1962 1963 1964 1965 1966
		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 已提交
1967 1968 1969 1970
		// Compatibility support for acceptSuggestionOnEnter
		if (typeof opts.acceptSuggestionOnEnter === 'boolean') {
			opts.acceptSuggestionOnEnter = opts.acceptSuggestionOnEnter ? 'on' : 'off';
		}
1971
		const find = this._santizeFindOpts(opts.find, defaults.find);
A
Alex Dima 已提交
1972 1973
		return {
			selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard),
A
Alex Dima 已提交
1974
			hover: this._santizeHoverOpts(opts.hover, defaults.hover),
1975
			links: _boolean(opts.links, defaults.links),
1976 1977 1978
			contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
			quickSuggestions: quickSuggestions,
			quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
1979
			parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
1980 1981 1982 1983
			iconsInSuggestions: _boolean(opts.iconsInSuggestions, defaults.iconsInSuggestions),
			formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
			formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
			suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters),
A
Alex Dima 已提交
1984
			acceptSuggestionOnEnter: _stringSet<'on' | 'smart' | 'off'>(opts.acceptSuggestionOnEnter, defaults.acceptSuggestionOnEnter, ['on', 'smart', 'off']),
1985 1986
			acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter),
			wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions),
B
Benas Svipas 已提交
1987
			suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']),
1988 1989
			suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
			suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
1990
			suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
1991 1992
			selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
			occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
1993
			codeLens: _boolean(opts.codeLens, defaults.codeLens),
1994
			folding: _boolean(opts.folding, defaults.folding),
1995
			foldingStrategy: _stringSet<'auto' | 'indentation'>(opts.foldingStrategy, defaults.foldingStrategy, ['auto', 'indentation']),
1996
			showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
1997
			matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets),
1998
			find: find,
R
rebornix 已提交
1999
			colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators),
2000 2001 2002
			lightbulbEnabled: _boolean(opts.lightbulb ? opts.lightbulb.enabled : false, defaults.lightbulbEnabled),
			codeActionsOnSave: _booleanMap(opts.codeActionsOnSave, {}),
			codeActionsOnSaveTimeout: _clampedInt(opts.codeActionsOnSaveTimeout, defaults.codeActionsOnSaveTimeout, 1, 10000)
2003 2004 2005 2006 2007 2008 2009 2010 2011
		};
	}
}

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

2012 2013 2014
	private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: platform.AccessibilitySupport): IValidatedEditorOptions {
		const accessibilityIsOn = (accessibilitySupport === platform.AccessibilitySupport.Enabled);
		const accessibilityIsOff = (accessibilitySupport === platform.AccessibilitySupport.Disabled);
2015 2016 2017 2018 2019 2020 2021
		return {
			inDiffEditor: opts.inDiffEditor,
			wordSeparators: opts.wordSeparators,
			lineNumbersMinChars: opts.lineNumbersMinChars,
			lineDecorationsWidth: opts.lineDecorationsWidth,
			readOnly: opts.readOnly,
			mouseStyle: opts.mouseStyle,
2022
			disableLayerHinting: opts.disableLayerHinting,
2023 2024 2025 2026 2027 2028 2029 2030
			automaticLayout: opts.automaticLayout,
			wordWrap: opts.wordWrap,
			wordWrapColumn: opts.wordWrapColumn,
			wordWrapMinified: opts.wordWrapMinified,
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
2031
			autoClosingBrackets: opts.autoClosingBrackets,
J
Jackson Kearl 已提交
2032
			autoClosingQuotes: opts.autoClosingQuotes,
J
Jackson Kearl 已提交
2033
			autoWrapping: opts.autoWrapping,
2034
			autoIndent: opts.autoIndent,
2035 2036 2037
			dragAndDrop: opts.dragAndDrop,
			emptySelectionClipboard: opts.emptySelectionClipboard,
			useTabStops: opts.useTabStops,
2038
			multiCursorModifier: opts.multiCursorModifier,
A
Alex Dima 已提交
2039
			multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
2040
			accessibilitySupport: opts.accessibilitySupport,
2041
			showUnused: opts.showUnused,
2042 2043 2044 2045 2046

			viewInfo: {
				extraEditorClassName: opts.viewInfo.extraEditorClassName,
				disableMonospaceOptimizations: opts.viewInfo.disableMonospaceOptimizations,
				rulers: opts.viewInfo.rulers,
2047
				ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel),
2048 2049 2050 2051 2052
				renderLineNumbers: opts.viewInfo.renderLineNumbers,
				renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers,
				selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
				glyphMargin: opts.viewInfo.glyphMargin,
				revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding,
2053
				roundedSelection: (accessibilityIsOn ? false : opts.viewInfo.roundedSelection), // DISABLED WHEN SCREEN READER IS ATTACHED
2054 2055 2056 2057 2058
				overviewRulerLanes: opts.viewInfo.overviewRulerLanes,
				overviewRulerBorder: opts.viewInfo.overviewRulerBorder,
				cursorBlinking: opts.viewInfo.cursorBlinking,
				mouseWheelZoom: opts.viewInfo.mouseWheelZoom,
				cursorStyle: opts.viewInfo.cursorStyle,
2059
				cursorWidth: opts.viewInfo.cursorWidth,
2060 2061
				hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler,
				scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine,
2062
				scrollBeyondLastColumn: opts.viewInfo.scrollBeyondLastColumn,
2063
				smoothScrolling: opts.viewInfo.smoothScrolling,
2064
				stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
2065 2066 2067 2068
				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
2069
				highlightActiveIndentGuide: opts.viewInfo.highlightActiveIndentGuide,
A
Alex Dima 已提交
2070
				renderLineHighlight: opts.viewInfo.renderLineHighlight,
2071 2072
				scrollbar: opts.viewInfo.scrollbar,
				minimap: {
2073
					enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED
2074
					side: opts.viewInfo.minimap.side,
2075
					renderCharacters: opts.viewInfo.minimap.renderCharacters,
2076
					showSlider: opts.viewInfo.minimap.showSlider,
2077 2078 2079 2080 2081 2082 2083 2084
					maxColumn: opts.viewInfo.minimap.maxColumn
				},
				fixedOverflowWidgets: opts.viewInfo.fixedOverflowWidgets
			},

			contribInfo: {
				selectionClipboard: opts.contribInfo.selectionClipboard,
				hover: opts.contribInfo.hover,
2085
				links: (accessibilityIsOn ? false : opts.contribInfo.links), // DISABLED WHEN SCREEN READER IS ATTACHED
2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096
				contextmenu: opts.contribInfo.contextmenu,
				quickSuggestions: opts.contribInfo.quickSuggestions,
				quickSuggestionsDelay: opts.contribInfo.quickSuggestionsDelay,
				parameterHints: opts.contribInfo.parameterHints,
				iconsInSuggestions: opts.contribInfo.iconsInSuggestions,
				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 已提交
2097
				suggestSelection: opts.contribInfo.suggestSelection,
2098 2099
				suggestFontSize: opts.contribInfo.suggestFontSize,
				suggestLineHeight: opts.contribInfo.suggestLineHeight,
2100
				suggest: opts.contribInfo.suggest,
2101 2102 2103 2104
				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
2105
				foldingStrategy: opts.contribInfo.foldingStrategy,
2106
				showFoldingControls: opts.contribInfo.showFoldingControls,
2107
				matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED
2108
				find: opts.contribInfo.find,
2109
				colorDecorators: opts.contribInfo.colorDecorators,
2110 2111 2112
				lightbulbEnabled: opts.contribInfo.lightbulbEnabled,
				codeActionsOnSave: opts.contribInfo.codeActionsOnSave,
				codeActionsOnSaveTimeout: opts.contribInfo.codeActionsOnSaveTimeout
2113 2114 2115 2116 2117 2118
			}
		};
	}

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

2119 2120 2121 2122 2123 2124 2125 2126 2127 2128
		let accessibilitySupport: platform.AccessibilitySupport;
		if (_opts.accessibilitySupport === 'auto') {
			// The editor reads the `accessibilitySupport` from the environment
			accessibilitySupport = env.accessibilitySupport;
		} else if (_opts.accessibilitySupport === 'on') {
			accessibilitySupport = platform.AccessibilitySupport.Enabled;
		} else {
			accessibilitySupport = platform.AccessibilitySupport.Disabled;
		}

2129 2130
		// Disable some non critical features to get as best performance as possible
		// See https://github.com/Microsoft/vscode/issues/26730
2131
		const opts = this._tweakValidatedOptions(_opts, accessibilitySupport);
2132 2133 2134 2135 2136 2137 2138 2139

		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 已提交
2140
		if (opts.contribInfo.folding) {
2141 2142 2143
			lineDecorationsWidth += 16;
		}

2144 2145 2146
		const layoutInfo = EditorLayoutProvider.compute({
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
A
Alex Dima 已提交
2147
			showGlyphMargin: opts.viewInfo.glyphMargin,
2148
			lineHeight: env.fontInfo.lineHeight,
2149
			showLineNumbers: (opts.viewInfo.renderLineNumbers !== RenderLineNumbersType.Off),
2150
			lineNumbersMinChars: opts.lineNumbersMinChars,
2151 2152 2153 2154
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			lineDecorationsWidth: lineDecorationsWidth,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
A
Alex Dima 已提交
2155 2156 2157 2158 2159
			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,
2160
			minimapSide: opts.viewInfo.minimap.side,
A
Alex Dima 已提交
2161 2162
			minimapRenderCharacters: opts.viewInfo.minimap.renderCharacters,
			minimapMaxColumn: opts.viewInfo.minimap.maxColumn,
2163 2164 2165 2166 2167
			pixelRatio: env.pixelRatio
		});

		let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } = null;
		{
A
Alex Dima 已提交
2168
			const wordWrap = opts.wordWrap;
2169 2170
			const wordWrapColumn = opts.wordWrapColumn;
			const wordWrapMinified = opts.wordWrapMinified;
2171

2172
			if (accessibilitySupport === platform.AccessibilitySupport.Enabled) {
2173 2174 2175 2176 2177 2178 2179 2180 2181 2182
				// 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) {
2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215
				// 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 已提交
2216
		const wrappingInfo: EditorWrappingInfo = {
2217
			inDiffEditor: opts.inDiffEditor,
2218 2219 2220 2221
			isDominatedByLongLines: env.isDominatedByLongLines,
			isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
			isViewportWrapping: bareWrappingInfo.isViewportWrapping,
			wrappingColumn: bareWrappingInfo.wrappingColumn,
2222 2223 2224 2225
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
A
Alex Dima 已提交
2226
		};
2227

2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243
		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';
		}

2244
		return new InternalEditorOptions({
2245
			canUseLayerHinting: opts.disableLayerHinting ? false : true,
2246
			pixelRatio: env.pixelRatio,
2247
			editorClassName: className,
A
Alex Dima 已提交
2248
			lineHeight: env.fontInfo.lineHeight,
2249
			readOnly: opts.readOnly,
2250
			accessibilitySupport: accessibilitySupport,
2251
			multiCursorModifier: opts.multiCursorModifier,
A
Alex Dima 已提交
2252
			multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
2253 2254
			wordSeparators: opts.wordSeparators,
			autoClosingBrackets: opts.autoClosingBrackets,
J
Jackson Kearl 已提交
2255
			autoClosingQuotes: opts.autoClosingQuotes,
J
Jackson Kearl 已提交
2256
			autoWrapping: opts.autoWrapping,
2257
			autoIndent: opts.autoIndent,
2258 2259 2260
			useTabStops: opts.useTabStops,
			tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
			dragAndDrop: opts.dragAndDrop,
2261
			emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard,
2262 2263
			layoutInfo: layoutInfo,
			fontInfo: env.fontInfo,
A
Alex Dima 已提交
2264
			viewInfo: opts.viewInfo,
2265
			wrappingInfo: wrappingInfo,
2266 2267
			contribInfo: opts.contribInfo,
			showUnused: opts.showUnused,
2268 2269 2270 2271 2272 2273 2274 2275
		});
	}
}

/**
 * @internal
 */
export interface IEditorLayoutProviderOpts {
M
Matt Bierner 已提交
2276 2277
	readonly outerWidth: number;
	readonly outerHeight: number;
2278

M
Matt Bierner 已提交
2279 2280
	readonly showGlyphMargin: boolean;
	readonly lineHeight: number;
2281

M
Matt Bierner 已提交
2282 2283 2284
	readonly showLineNumbers: boolean;
	readonly lineNumbersMinChars: number;
	readonly lineNumbersDigitCount: number;
2285

M
Matt Bierner 已提交
2286
	readonly lineDecorationsWidth: number;
2287

M
Matt Bierner 已提交
2288 2289
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
2290

M
Matt Bierner 已提交
2291 2292 2293 2294
	readonly verticalScrollbarWidth: number;
	readonly verticalScrollbarHasArrows: boolean;
	readonly scrollbarArrowSize: number;
	readonly horizontalScrollbarHeight: number;
2295

M
Matt Bierner 已提交
2296 2297 2298 2299 2300
	readonly minimap: boolean;
	readonly minimapSide: string;
	readonly minimapRenderCharacters: boolean;
	readonly minimapMaxColumn: number;
	readonly pixelRatio: number;
2301 2302 2303 2304 2305 2306 2307 2308 2309
}

/**
 * @internal
 */
export class EditorLayoutProvider {
	public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo {
		const outerWidth = _opts.outerWidth | 0;
		const outerHeight = _opts.outerHeight | 0;
A
Alex Dima 已提交
2310
		const showGlyphMargin = _opts.showGlyphMargin;
2311
		const lineHeight = _opts.lineHeight | 0;
A
Alex Dima 已提交
2312
		const showLineNumbers = _opts.showLineNumbers;
2313 2314 2315
		const lineNumbersMinChars = _opts.lineNumbersMinChars | 0;
		const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0;
		const lineDecorationsWidth = _opts.lineDecorationsWidth | 0;
A
Alex Dima 已提交
2316 2317
		const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth;
		const maxDigitWidth = _opts.maxDigitWidth;
A
Alex Dima 已提交
2318
		const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0;
A
Alex Dima 已提交
2319
		const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows;
2320 2321
		const scrollbarArrowSize = _opts.scrollbarArrowSize | 0;
		const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0;
A
Alex Dima 已提交
2322
		const minimap = _opts.minimap;
2323
		const minimapSide = _opts.minimapSide;
A
Alex Dima 已提交
2324
		const minimapRenderCharacters = _opts.minimapRenderCharacters;
2325
		const minimapMaxColumn = _opts.minimapMaxColumn | 0;
A
Alex Dima 已提交
2326
		const pixelRatio = _opts.pixelRatio;
2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338

		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 已提交
2339 2340 2341 2342 2343
		let glyphMarginLeft = 0;
		let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
		let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
		let contentLeft = decorationsLeft + lineDecorationsWidth;

2344 2345 2346
		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;

		let renderMinimap: RenderMinimap;
2347
		let minimapLeft: number;
2348 2349 2350
		let minimapWidth: number;
		let contentWidth: number;
		if (!minimap) {
2351
			minimapLeft = 0;
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365
			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:
2366 2367
			// (leaving 2px for the cursor to have space after the last character)
			// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
2368 2369 2370 2371
			// minimapWidth = viewportColumn * minimapCharWidth
			// contentWidth = remainingWidth - minimapWidth
			// What are good values for contentWidth and minimapWidth ?

2372 2373 2374 2375 2376
			// 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)
2377

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

A
Alex Dima 已提交
2385
			if (minimapSide === 'left') {
2386
				minimapLeft = 0;
A
Alex Dima 已提交
2387 2388 2389 2390
				glyphMarginLeft += minimapWidth;
				lineNumbersLeft += minimapWidth;
				decorationsLeft += minimapWidth;
				contentLeft += minimapWidth;
2391 2392
			} else {
				minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth;
2393
			}
2394 2395
		}

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

		const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);

A
Alex Dima 已提交
2401
		return {
2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421
			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,
2422
			minimapLeft: minimapLeft,
2423 2424 2425 2426 2427 2428 2429
			minimapWidth: minimapWidth,

			viewportColumn: viewportColumn,

			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

A
Alex Dima 已提交
2430
			overviewRuler: {
2431 2432 2433 2434
				top: verticalArrowSize,
				width: verticalScrollbarWidth,
				height: (outerHeight - 2 * verticalArrowSize),
				right: 0
A
Alex Dima 已提交
2435 2436
			}
		};
2437 2438
	}
}
2439

A
Alex Dima 已提交
2440 2441 2442
const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';
2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455

/**
 * @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,
2456
	letterSpacing: 0,
2457 2458 2459 2460 2461 2462 2463 2464 2465
};

/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
	insertSpaces: true,
	detectIndentation: true,
2466
	trimAutoWhitespace: true,
2467
	largeFileOptimizations: true
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479
};

/**
 * @internal
 */
export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
	inDiffEditor: false,
	wordSeparators: USUAL_WORD_SEPARATORS,
	lineNumbersMinChars: 5,
	lineDecorationsWidth: 10,
	readOnly: false,
	mouseStyle: 'text',
2480
	disableLayerHinting: false,
2481 2482 2483 2484 2485 2486
	automaticLayout: false,
	wordWrap: 'off',
	wordWrapColumn: 80,
	wordWrapMinified: true,
	wrappingIndent: WrappingIndent.Same,
	wordWrapBreakBeforeCharacters: '([{‘“〈《「『【〔([{「£¥$£¥++',
2487
	wordWrapBreakAfterCharacters: ' \t})]?|&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
2488
	wordWrapBreakObtrusiveCharacters: '.',
J
Jackson Kearl 已提交
2489 2490 2491
	autoClosingBrackets: 'languageDefined',
	autoClosingQuotes: 'languageDefined',
	autoWrapping: 'always',
R
rebornix 已提交
2492
	autoIndent: true,
2493
	dragAndDrop: true,
2494
	emptySelectionClipboard: true,
2495
	useTabStops: true,
2496
	multiCursorModifier: 'altKey',
A
Alex Dima 已提交
2497
	multiCursorMergeOverlapping: true,
2498
	accessibilitySupport: 'auto',
2499
	showUnused: true,
A
Alex Dima 已提交
2500 2501

	viewInfo: {
2502
		extraEditorClassName: '',
A
Alex Dima 已提交
2503 2504 2505
		disableMonospaceOptimizations: false,
		rulers: [],
		ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
2506
		renderLineNumbers: RenderLineNumbersType.On,
A
Alex Dima 已提交
2507 2508 2509 2510 2511 2512 2513 2514 2515 2516
		renderCustomLineNumbers: null,
		selectOnLineNumbers: true,
		glyphMargin: true,
		revealHorizontalRightPadding: 30,
		roundedSelection: true,
		overviewRulerLanes: 2,
		overviewRulerBorder: true,
		cursorBlinking: TextEditorCursorBlinkingStyle.Blink,
		mouseWheelZoom: false,
		cursorStyle: TextEditorCursorStyle.Line,
2517
		cursorWidth: 0,
A
Alex Dima 已提交
2518 2519
		hideCursorInOverviewRuler: false,
		scrollBeyondLastLine: true,
2520
		scrollBeyondLastColumn: 5,
2521
		smoothScrolling: false,
A
Alex Dima 已提交
2522 2523 2524 2525
		stopRenderingLineAfter: 10000,
		renderWhitespace: 'none',
		renderControlCharacters: false,
		fontLigatures: false,
2526
		renderIndentGuides: true,
2527
		highlightActiveIndentGuide: true,
A
Alex Dima 已提交
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543
		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,
		},
		minimap: {
2544
			enabled: true,
2545
			side: 'right',
2546
			showSlider: 'mouseover',
A
Alex Dima 已提交
2547 2548 2549 2550 2551 2552 2553 2554
			renderCharacters: true,
			maxColumn: 120
		},
		fixedOverflowWidgets: false,
	},

	contribInfo: {
		selectionClipboard: true,
A
Alex Dima 已提交
2555
		hover: {
2556
			enabled: true,
2557 2558
			delay: 300,
			sticky: true
A
Alex Dima 已提交
2559
		},
2560
		links: true,
A
Alex Dima 已提交
2561 2562 2563
		contextmenu: true,
		quickSuggestions: { other: true, comments: false, strings: false },
		quickSuggestionsDelay: 10,
2564 2565 2566 2567
		parameterHints: {
			enabled: true,
			cycle: false
		},
A
Alex Dima 已提交
2568 2569
		iconsInSuggestions: true,
		formatOnType: false,
2570
		formatOnPaste: false,
A
Alex Dima 已提交
2571
		suggestOnTriggerCharacters: true,
2572
		acceptSuggestionOnEnter: 'on',
A
Alex Dima 已提交
2573 2574
		acceptSuggestionOnCommitCharacter: true,
		wordBasedSuggestions: true,
B
Benas Svipas 已提交
2575
		suggestSelection: 'recentlyUsed',
A
Alex Dima 已提交
2576 2577
		suggestFontSize: 0,
		suggestLineHeight: 0,
2578 2579
		suggest: {
			filterGraceful: true,
2580 2581
			snippets: 'inline',
			snippetsPreventQuickSuggestions: true
2582
		},
A
Alex Dima 已提交
2583 2584 2585 2586
		selectionHighlight: true,
		occurrencesHighlight: true,
		codeLens: true,
		folding: true,
2587
		foldingStrategy: 'auto',
2588
		showFoldingControls: 'mouseover',
A
Alex Dima 已提交
2589
		matchBrackets: true,
2590
		find: {
R
rebornix 已提交
2591
			seedSearchStringFromSelection: true,
2592
			autoFindInSelection: false,
2593
			globalFindClipboard: false
2594
		},
2595
		colorDecorators: true,
2596 2597 2598
		lightbulbEnabled: true,
		codeActionsOnSave: {},
		codeActionsOnSaveTimeout: 750
A
Alex Dima 已提交
2599
	},
2600
};