editorOptions.ts 74.3 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 14 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

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

77 78 79 80
/**
 * Configuration options for editor find widget
 */
export interface IEditorFindOptions {
R
rebornix 已提交
81 82 83
	/**
	 * Controls if we seed search string in the Find Widget with editor selection.
	 */
84
	seedSearchStringFromSelection?: boolean;
R
rebornix 已提交
85 86 87 88
	/**
	 * Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor.
	 */
	autoFindInSelection: boolean;
89 90
}

91 92 93 94 95 96 97 98 99
/**
 * Configuration options for editor minimap
 */
export interface IEditorMinimapOptions {
	/**
	 * Enable the rendering of the minimap.
	 * Defaults to false.
	 */
	enabled?: boolean;
100 101 102 103 104
	/**
	 * Control the rendering of the minimap slider.
	 * Defaults to 'mouseover'.
	 */
	showSlider?: 'always' | 'mouseover';
105 106 107 108 109 110 111 112 113 114 115 116
	/**
	 * 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;
}

117 118 119 120 121 122 123 124 125 126 127
/**
 * Configuration options for editor minimap
 */
export interface IEditorLightbulbOptions {
	/**
	 * Enable the lightbulb code action.
	 * Defaults to true.
	 */
	enabled?: boolean;
}

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
/**
 * Configuration options for the editor.
 */
export interface IEditorOptions {
	/**
	 * This editor is used inside a diff editor.
	 * @internal
	 */
	inDiffEditor?: boolean;
	/**
	 * The aria label for the editor's textarea (when it is focused).
	 */
	ariaLabel?: string;
	/**
	 * Render vertical lines at the specified columns.
	 * Defaults to empty array.
	 */
	rulers?: number[];
	/**
	 * A string containing the word separators used when doing word navigation.
	 * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
	 */
	wordSeparators?: string;
	/**
	 * Enable Linux primary clipboard.
	 * Defaults to true.
	 */
	selectionClipboard?: boolean;
	/**
	 * Control the rendering of line numbers.
	 * If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
	 * Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function).
	 * Otherwise, line numbers will not be rendered.
	 * Defaults to true.
	 */
A
Alex Dima 已提交
163
	lineNumbers?: 'on' | 'off' | 'relative' | ((lineNumber: number) => string);
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
	/**
	 * 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;
	/**
198
	 * Class name to be added to the editor.
199
	 */
200
	extraEditorClassName?: string;
201 202 203 204 205 206 207 208 209 210 211 212 213
	/**
	 * 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;
214 215 216 217
	/**
	 * Control the behavior of the find widget.
	 */
	find?: IEditorFindOptions;
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
	/**
	 * 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;
	/**
	 * Enable font ligatures.
	 * Defaults to false.
	 */
	fontLigatures?: boolean;
	/**
260 261
	 * 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.
262 263
	 * Defaults to false.
	 */
264
	disableLayerHinting?: boolean;
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
	/**
	 * 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;
280 281
	/**
	 * Enable that the editor animates scrolling to a position.
282
	 * Defaults to false.
283 284
	 */
	smoothScrolling?: boolean;
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
	/**
	 * 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;
	/**
	 * Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'.
	 * 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;
	/**
	 * Enable hover.
	 * Defaults to true.
	 */
	hover?: boolean;
346 347 348 349 350
	/**
	 * Enable detecting links and making them clickable.
	 * Defaults to true.
	 */
	links?: boolean;
351
	/**
352
	 * Enable inline color decorators and color picker rendering.
353
	 */
R
rebornix 已提交
354
	colorDecorators?: boolean;
355 356 357 358 359 360 361 362 363 364
	/**
	 * 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;
365 366 367 368
	/**
	 * The modifier to be used to add multiple cursors with the mouse.
	 * Defaults to 'alt'
	 */
369
	multiCursorModifier?: 'ctrlCmd' | 'alt';
370 371 372 373 374
	/**
	 * Configure the editor's accessibility support.
	 * Defaults to 'auto'. It is best to leave this to 'auto'.
	 */
	accessibilitySupport?: 'auto' | 'off' | 'on';
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
	/**
	 * 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;
	/**
	 * Enables parameter hints
	 */
	parameterHints?: boolean;
	/**
	 * Render icons in suggestions box.
	 * Defaults to true.
	 */
	iconsInSuggestions?: boolean;
	/**
	 * Enable auto closing brackets.
	 * Defaults to true.
	 */
	autoClosingBrackets?: boolean;
399 400 401 402 403
	/**
	 * Enable auto indentation adjustment.
	 * Defaults to false.
	 */
	autoIndent?: boolean;
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
	/**
	 * 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.
426
	 * Defaults to 'on'.
427
	 */
J
Johannes Rieken 已提交
428
	acceptSuggestionOnEnter?: boolean | 'on' | 'smart' | 'off';
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
	/**
	 * 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;
	/**
	 * 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;
	/**
	 * @deprecated - use codeLens instead
	 * @internal
	 */
	referenceInfos?: boolean;
476 477 478 479
	/**
	 * Control the behavior and rendering of the code action lightbulb.
	 */
	lightbulb?: IEditorLightbulbOptions;
480 481 482 483 484
	/**
	 * Enable code folding
	 * Defaults to true in vscode and to false in monaco-editor.
	 */
	folding?: boolean;
485
	/**
486 487
	 * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
	 * Defaults to 'mouseover'.
488
	 */
489
	showFoldingControls?: 'always' | 'mouseover';
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
	/**
	 * 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.
	 * Defaults to false.
	 */
	renderIndentGuides?: boolean;
	/**
	 * 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;
535 536 537 538
	/**
	 * The letter spacing
	 */
	letterSpacing?: number;
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 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 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
}

/**
 * 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,
	/**
	 * Indent => wrapped lines get +1 indentation as the parent.
	 */
	Indent = 2
}

/**
 * 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
}
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
/**
 * @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');
	}
}
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 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

/**
 * 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 已提交
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
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 已提交
717
export interface InternalEditorScrollbarOptions {
718 719 720 721 722 723 724 725 726 727 728 729 730 731
	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 已提交
732
export interface InternalEditorMinimapOptions {
733
	readonly enabled: boolean;
734
	readonly showSlider: 'always' | 'mouseover';
735 736 737 738
	readonly renderCharacters: boolean;
	readonly maxColumn: number;
}

739 740
export interface InternalEditorFindOptions {
	readonly seedSearchStringFromSelection: boolean;
R
rebornix 已提交
741
	readonly autoFindInSelection: boolean;
742 743
}

A
Alex Dima 已提交
744
export interface EditorWrappingInfo {
745 746 747 748 749 750 751 752 753 754 755
	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;
}

A
Alex Dima 已提交
756
export interface InternalEditorViewOptions {
757
	readonly extraEditorClassName: string;
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
	readonly disableMonospaceOptimizations: boolean;
	readonly rulers: number[];
	readonly ariaLabel: string;
	readonly renderLineNumbers: boolean;
	readonly renderCustomLineNumbers: (lineNumber: number) => string;
	readonly renderRelativeLineNumbers: boolean;
	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;
	readonly hideCursorInOverviewRuler: boolean;
	readonly scrollBeyondLastLine: boolean;
775
	readonly smoothScrolling: boolean;
776 777 778 779 780 781 782 783 784 785 786
	readonly stopRenderingLineAfter: number;
	readonly renderWhitespace: 'none' | 'boundary' | 'all';
	readonly renderControlCharacters: boolean;
	readonly fontLigatures: boolean;
	readonly renderIndentGuides: boolean;
	readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
	readonly scrollbar: InternalEditorScrollbarOptions;
	readonly minimap: InternalEditorMinimapOptions;
	readonly fixedOverflowWidgets: boolean;
}

A
Alex Dima 已提交
787
export interface EditorContribOptions {
788 789
	readonly selectionClipboard: boolean;
	readonly hover: boolean;
790
	readonly links: boolean;
791 792 793 794 795 796 797 798
	readonly contextmenu: boolean;
	readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
	readonly quickSuggestionsDelay: number;
	readonly parameterHints: boolean;
	readonly iconsInSuggestions: boolean;
	readonly formatOnType: boolean;
	readonly formatOnPaste: boolean;
	readonly suggestOnTriggerCharacters: boolean;
799
	readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off';
800 801 802 803 804 805 806 807 808
	readonly acceptSuggestionOnCommitCharacter: boolean;
	readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
	readonly wordBasedSuggestions: boolean;
	readonly suggestFontSize: number;
	readonly suggestLineHeight: number;
	readonly selectionHighlight: boolean;
	readonly occurrencesHighlight: boolean;
	readonly codeLens: boolean;
	readonly folding: boolean;
809
	readonly showFoldingControls: 'always' | 'mouseover';
810
	readonly matchBrackets: boolean;
811
	readonly find: InternalEditorFindOptions;
R
rebornix 已提交
812
	readonly colorDecorators: boolean;
813
	readonly lightbulbEnabled: boolean;
814 815
}

816 817 818 819 820 821 822 823 824 825 826 827
/**
 * 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';
828
	readonly disableLayerHinting: boolean;
829 830 831 832 833 834 835 836 837
	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;
	readonly autoClosingBrackets: boolean;
838
	readonly autoIndent: boolean;
839 840 841
	readonly dragAndDrop: boolean;
	readonly emptySelectionClipboard: boolean;
	readonly useTabStops: boolean;
842
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
843
	readonly accessibilitySupport: 'auto' | 'off' | 'on';
844 845 846 847 848

	readonly viewInfo: InternalEditorViewOptions;
	readonly contribInfo: EditorContribOptions;
}

849 850 851 852 853 854
/**
 * Internal configuration options (transformed or computed) for the editor.
 */
export class InternalEditorOptions {
	readonly _internalEditorOptionsBrand: void;

855
	readonly canUseLayerHinting: boolean;
856
	readonly pixelRatio: number;
A
Alex Dima 已提交
857
	readonly editorClassName: string;
A
Alex Dima 已提交
858
	readonly lineHeight: number;
859
	readonly readOnly: boolean;
860 861 862 863
	/**
	 * @internal
	 */
	readonly accessibilitySupport: platform.AccessibilitySupport;
864
	readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
A
Alex Dima 已提交
865

866 867 868
	// ---- cursor options
	readonly wordSeparators: string;
	readonly autoClosingBrackets: boolean;
869
	readonly autoIndent: boolean;
870 871 872
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
873
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
874

875 876 877 878 879 880 881 882 883 884 885
	// ---- grouped options
	readonly layoutInfo: EditorLayoutInfo;
	readonly fontInfo: FontInfo;
	readonly viewInfo: InternalEditorViewOptions;
	readonly wrappingInfo: EditorWrappingInfo;
	readonly contribInfo: EditorContribOptions;

	/**
	 * @internal
	 */
	constructor(source: {
886
		canUseLayerHinting: boolean;
887
		pixelRatio: number;
A
Alex Dima 已提交
888
		editorClassName: string;
889 890
		lineHeight: number;
		readOnly: boolean;
891
		accessibilitySupport: platform.AccessibilitySupport;
892
		multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
893 894
		wordSeparators: string;
		autoClosingBrackets: boolean;
895
		autoIndent: boolean;
896 897 898
		useTabStops: boolean;
		tabFocusMode: boolean;
		dragAndDrop: boolean;
899
		emptySelectionClipboard: boolean;
900 901 902 903 904 905
		layoutInfo: EditorLayoutInfo;
		fontInfo: FontInfo;
		viewInfo: InternalEditorViewOptions;
		wrappingInfo: EditorWrappingInfo;
		contribInfo: EditorContribOptions;
	}) {
906
		this.canUseLayerHinting = source.canUseLayerHinting;
907 908
		this.pixelRatio = source.pixelRatio;
		this.editorClassName = source.editorClassName;
909
		this.lineHeight = source.lineHeight | 0;
910
		this.readOnly = source.readOnly;
911
		this.accessibilitySupport = source.accessibilitySupport;
912
		this.multiCursorModifier = source.multiCursorModifier;
913 914
		this.wordSeparators = source.wordSeparators;
		this.autoClosingBrackets = source.autoClosingBrackets;
915
		this.autoIndent = source.autoIndent;
916 917 918
		this.useTabStops = source.useTabStops;
		this.tabFocusMode = source.tabFocusMode;
		this.dragAndDrop = source.dragAndDrop;
919
		this.emptySelectionClipboard = source.emptySelectionClipboard;
920 921 922 923 924
		this.layoutInfo = source.layoutInfo;
		this.fontInfo = source.fontInfo;
		this.viewInfo = source.viewInfo;
		this.wrappingInfo = source.wrappingInfo;
		this.contribInfo = source.contribInfo;
925 926 927 928 929 930 931
	}

	/**
	 * @internal
	 */
	public equals(other: InternalEditorOptions): boolean {
		return (
932
			this.canUseLayerHinting === other.canUseLayerHinting
933
			&& this.pixelRatio === other.pixelRatio
A
Alex Dima 已提交
934 935
			&& this.editorClassName === other.editorClassName
			&& this.lineHeight === other.lineHeight
936
			&& this.readOnly === other.readOnly
937
			&& this.accessibilitySupport === other.accessibilitySupport
938
			&& this.multiCursorModifier === other.multiCursorModifier
939 940
			&& this.wordSeparators === other.wordSeparators
			&& this.autoClosingBrackets === other.autoClosingBrackets
941
			&& this.autoIndent === other.autoIndent
942 943 944
			&& this.useTabStops === other.useTabStops
			&& this.tabFocusMode === other.tabFocusMode
			&& this.dragAndDrop === other.dragAndDrop
945
			&& this.emptySelectionClipboard === other.emptySelectionClipboard
A
Alex Dima 已提交
946
			&& InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, other.layoutInfo)
947
			&& this.fontInfo.equals(other.fontInfo)
A
Alex Dima 已提交
948 949 950
			&& InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo)
			&& InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, other.wrappingInfo)
			&& InternalEditorOptions._equalsContribOptions(this.contribInfo, other.contribInfo)
951 952 953 954 955 956 957 958
		);
	}

	/**
	 * @internal
	 */
	public createChangeEvent(newOpts: InternalEditorOptions): IConfigurationChangedEvent {
		return {
959
			canUseLayerHinting: (this.canUseLayerHinting !== newOpts.canUseLayerHinting),
960
			pixelRatio: (this.pixelRatio !== newOpts.pixelRatio),
A
Alex Dima 已提交
961
			editorClassName: (this.editorClassName !== newOpts.editorClassName),
962 963
			lineHeight: (this.lineHeight !== newOpts.lineHeight),
			readOnly: (this.readOnly !== newOpts.readOnly),
964
			accessibilitySupport: (this.accessibilitySupport !== newOpts.accessibilitySupport),
965
			multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier),
966 967
			wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
			autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
968
			autoIndent: (this.autoIndent !== newOpts.autoIndent),
969 970 971
			useTabStops: (this.useTabStops !== newOpts.useTabStops),
			tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
			dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop),
972
			emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard),
A
Alex Dima 已提交
973
			layoutInfo: (!InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, newOpts.layoutInfo)),
974
			fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
A
Alex Dima 已提交
975 976
			viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)),
			wrappingInfo: (!InternalEditorOptions._equalsWrappingInfo(this.wrappingInfo, newOpts.wrappingInfo)),
977
			contribInfo: (!InternalEditorOptions._equalsContribOptions(this.contribInfo, newOpts.contribInfo))
978 979 980
		};
	}

A
Alex Dima 已提交
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007
	/**
	 * @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
			&& a.minimapWidth === b.minimapWidth
			&& a.viewportColumn === b.viewportColumn
			&& a.verticalScrollbarWidth === b.verticalScrollbarWidth
			&& a.horizontalScrollbarHeight === b.horizontalScrollbarHeight
			&& this._equalsOverviewRuler(a.overviewRuler, b.overviewRuler)
		);
	}
1008 1009

	/**
A
Alex Dima 已提交
1010
	 * @internal
1011
	 */
A
Alex Dima 已提交
1012 1013 1014 1015 1016 1017 1018 1019 1020
	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
		);
	}

1021
	/**
A
Alex Dima 已提交
1022
	 * @internal
1023
	 */
A
Alex Dima 已提交
1024 1025
	private static _equalsViewOptions(a: InternalEditorViewOptions, b: InternalEditorViewOptions): boolean {
		return (
1026
			a.extraEditorClassName === b.extraEditorClassName
A
Alex Dima 已提交
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
			&& a.disableMonospaceOptimizations === b.disableMonospaceOptimizations
			&& this._equalsNumberArrays(a.rulers, b.rulers)
			&& a.ariaLabel === b.ariaLabel
			&& a.renderLineNumbers === b.renderLineNumbers
			&& a.renderCustomLineNumbers === b.renderCustomLineNumbers
			&& a.renderRelativeLineNumbers === b.renderRelativeLineNumbers
			&& 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
			&& a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler
			&& a.scrollBeyondLastLine === b.scrollBeyondLastLine
1044
			&& a.smoothScrolling === b.smoothScrolling
A
Alex Dima 已提交
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
			&& a.stopRenderingLineAfter === b.stopRenderingLineAfter
			&& a.renderWhitespace === b.renderWhitespace
			&& a.renderControlCharacters === b.renderControlCharacters
			&& a.fontLigatures === b.fontLigatures
			&& a.renderIndentGuides === b.renderIndentGuides
			&& a.renderLineHighlight === b.renderLineHighlight
			&& this._equalsScrollbarOptions(a.scrollbar, b.scrollbar)
			&& this._equalsMinimapOptions(a.minimap, b.minimap)
			&& a.fixedOverflowWidgets === b.fixedOverflowWidgets
		);
	}

1057
	/**
A
Alex Dima 已提交
1058
	 * @internal
1059
	 */
A
Alex Dima 已提交
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
	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
		);
	}

1077
	/**
A
Alex Dima 已提交
1078
	 * @internal
1079
	 */
A
Alex Dima 已提交
1080 1081 1082
	private static _equalsMinimapOptions(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean {
		return (
			a.enabled === b.enabled
1083
			&& a.showSlider === b.showSlider
A
Alex Dima 已提交
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099
			&& a.renderCharacters === b.renderCharacters
			&& a.maxColumn === b.maxColumn
		);
	}

	private static _equalsNumberArrays(a: number[], b: number[]): boolean {
		if (a.length !== b.length) {
			return false;
		}
		for (let i = 0; i < a.length; i++) {
			if (a[i] !== b[i]) {
				return false;
			}
		}
		return true;
	}
1100

1101 1102 1103 1104 1105 1106 1107
	/**
	 * @internal
	 */

	private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
		return (
			a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
R
rebornix 已提交
1108
			&& a.autoFindInSelection === b.autoFindInSelection
1109 1110 1111
		);
	}

1112 1113 1114
	/**
	 * @internal
	 */
A
Alex Dima 已提交
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
	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
		);
1127 1128 1129 1130 1131
	}

	/**
	 * @internal
	 */
A
Alex Dima 已提交
1132 1133 1134 1135
	private static _equalsContribOptions(a: EditorContribOptions, b: EditorContribOptions): boolean {
		return (
			a.selectionClipboard === b.selectionClipboard
			&& a.hover === b.hover
1136
			&& a.links === b.links
A
Alex Dima 已提交
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
			&& a.contextmenu === b.contextmenu
			&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
			&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
			&& a.parameterHints === b.parameterHints
			&& 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.snippetSuggestions === b.snippetSuggestions
			&& a.wordBasedSuggestions === b.wordBasedSuggestions
			&& a.suggestFontSize === b.suggestFontSize
			&& a.suggestLineHeight === b.suggestLineHeight
			&& a.selectionHighlight === b.selectionHighlight
			&& a.occurrencesHighlight === b.occurrencesHighlight
			&& a.codeLens === b.codeLens
			&& a.folding === b.folding
1155
			&& a.showFoldingControls === b.showFoldingControls
A
Alex Dima 已提交
1156
			&& a.matchBrackets === b.matchBrackets
1157
			&& this._equalFindOptions(a.find, b.find)
R
rebornix 已提交
1158
			&& a.colorDecorators === b.colorDecorators
1159
			&& a.lightbulbEnabled === b.lightbulbEnabled
A
Alex Dima 已提交
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172
		);
	}

	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;
		}
1173
		return (
A
Alex Dima 已提交
1174 1175 1176
			a.comments === b.comments
			&& a.other === b.other
			&& a.strings === b.strings
1177 1178 1179 1180
		);
	}
}

A
Alex Dima 已提交
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
/**
 * 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;
}

1203 1204 1205
/**
 * The internal layout details of the editor.
 */
A
Alex Dima 已提交
1206
export interface EditorLayoutInfo {
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302

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

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

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

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

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

	/**
	 * The 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 {
1303
	readonly canUseLayerHinting: boolean;
1304
	readonly pixelRatio: boolean;
A
Alex Dima 已提交
1305
	readonly editorClassName: boolean;
1306 1307
	readonly lineHeight: boolean;
	readonly readOnly: boolean;
1308
	readonly accessibilitySupport: boolean;
1309
	readonly multiCursorModifier: boolean;
1310 1311
	readonly wordSeparators: boolean;
	readonly autoClosingBrackets: boolean;
1312
	readonly autoIndent: boolean;
1313 1314 1315
	readonly useTabStops: boolean;
	readonly tabFocusMode: boolean;
	readonly dragAndDrop: boolean;
1316
	readonly emptySelectionClipboard: boolean;
1317 1318
	readonly layoutInfo: boolean;
	readonly fontInfo: boolean;
A
Alex Dima 已提交
1319
	readonly viewInfo: boolean;
1320 1321 1322
	readonly wrappingInfo: boolean;
	readonly contribInfo: boolean;
}
1323 1324 1325 1326

/**
 * @internal
 */
A
Alex Dima 已提交
1327 1328 1329 1330
export interface IEnvironmentalOptions {
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
1331
	readonly extraEditorClassName: string;
A
Alex Dima 已提交
1332 1333
	readonly isDominatedByLongLines: boolean;
	readonly lineNumbersDigitCount: number;
1334
	readonly emptySelectionClipboard: boolean;
A
Alex Dima 已提交
1335 1336
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
1337
	readonly accessibilitySupport: platform.AccessibilitySupport;
1338
}
1339

1340 1341 1342 1343 1344 1345 1346 1347 1348 1349
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);
}
1350

1351 1352 1353 1354 1355 1356
function _string(value: any, defaultValue: string): string {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	return value;
}
1357

1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375
function _stringSet<T>(value: any, defaultValue: T, allowedValues: string[]): T {
	if (typeof value !== 'string') {
		return defaultValue;
	}
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
	}
	return <T><any>value;
}

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;
1376
		}
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447
	}
	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;
	}
	if (wrappingIndent === 'indent') {
		return WrappingIndent.Indent;
	} else if (wrappingIndent === 'same') {
		return WrappingIndent.Same;
	} 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 已提交
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460
		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);
1461
		const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
A
Alex Dima 已提交
1462

1463
		let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey';
1464
		if (typeof opts.multiCursorModifier === 'string') {
1465 1466
			if (opts.multiCursorModifier === 'ctrlCmd') {
				configuredMulticursorModifier = platform.isMacintosh ? 'metaKey' : 'ctrlKey';
1467
			} else {
1468
				configuredMulticursorModifier = 'altKey';
1469 1470
			}
		}
1471
		const multiCursorModifier = _stringSet<'altKey' | 'metaKey' | 'ctrlKey'>(configuredMulticursorModifier, defaults.multiCursorModifier, ['altKey', 'metaKey', 'ctrlKey']);
1472

A
Alex Dima 已提交
1473 1474 1475 1476 1477 1478 1479
		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']),
1480
			disableLayerHinting: _boolean(opts.disableLayerHinting, defaults.disableLayerHinting),
A
Alex Dima 已提交
1481 1482 1483 1484 1485 1486 1487 1488 1489
			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),
			autoClosingBrackets: _boolean(opts.autoClosingBrackets, defaults.autoClosingBrackets),
1490
			autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
A
Alex Dima 已提交
1491
			dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
1492
			emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard),
A
Alex Dima 已提交
1493
			useTabStops: _boolean(opts.useTabStops, defaults.useTabStops),
1494
			multiCursorModifier: multiCursorModifier,
1495
			accessibilitySupport: _stringSet<'auto' | 'on' | 'off'>(opts.accessibilitySupport, defaults.accessibilitySupport, ['auto', 'on', 'off']),
A
Alex Dima 已提交
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 1528 1529 1530 1531 1532 1533
			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),
1534
			showSlider: _stringSet<'always' | 'mouseover'>(opts.showSlider, defaults.showSlider, ['always', 'mouseover']),
A
Alex Dima 已提交
1535 1536 1537 1538 1539
			renderCharacters: _boolean(opts.renderCharacters, defaults.renderCharacters),
			maxColumn: _clampedInt(opts.maxColumn, defaults.maxColumn, 1, 10000),
		};
	}

1540 1541 1542 1543 1544 1545
	private static _santizeFindOpts(opts: IEditorFindOptions, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
		if (typeof opts !== 'object') {
			return defaults;
		}

		return {
R
rebornix 已提交
1546 1547
			seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
			autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection)
1548 1549 1550
		};
	}

A
Alex Dima 已提交
1551
	private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
1552 1553 1554 1555 1556 1557 1558

		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();
1559 1560
		}

1561 1562 1563 1564 1565
		let renderLineNumbers: boolean = defaults.renderLineNumbers;
		let renderCustomLineNumbers: (lineNumber: number) => string = defaults.renderCustomLineNumbers;
		let renderRelativeLineNumbers: boolean = defaults.renderRelativeLineNumbers;

		if (typeof opts.lineNumbers !== 'undefined') {
1566
			let lineNumbers = opts.lineNumbers;
1567

1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593
			// Compatibility with old true or false values
			if (<any>lineNumbers === true) {
				lineNumbers = 'on';
			} else if (<any>lineNumbers === false) {
				lineNumbers = 'off';
			}

			if (typeof lineNumbers === 'function') {
				renderLineNumbers = true;
				renderCustomLineNumbers = lineNumbers;
				renderRelativeLineNumbers = false;
			} else if (lineNumbers === 'relative') {
				renderLineNumbers = true;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = true;
			} else if (lineNumbers === 'on') {
				renderLineNumbers = true;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = false;
			} else {
				renderLineNumbers = false;
				renderCustomLineNumbers = null;
				renderRelativeLineNumbers = false;
			}
		}

A
Alex Dima 已提交
1594 1595
		const fontLigatures = _boolean(opts.fontLigatures, defaults.fontLigatures);
		const disableMonospaceOptimizations = _boolean(opts.disableMonospaceOptimizations, defaults.disableMonospaceOptimizations) || fontLigatures;
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618

		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 已提交
1619 1620
		const mouseWheelScrollSensitivity = _float(opts.mouseWheelScrollSensitivity, defaults.scrollbar.mouseWheelScrollSensitivity);
		const scrollbar = this._sanitizeScrollbarOpts(opts.scrollbar, defaults.scrollbar, mouseWheelScrollSensitivity);
1621 1622 1623
		const minimap = this._sanitizeMinimapOpts(opts.minimap, defaults.minimap);

		return {
1624
			extraEditorClassName: _string(opts.extraEditorClassName, defaults.extraEditorClassName),
A
Alex Dima 已提交
1625
			disableMonospaceOptimizations: disableMonospaceOptimizations,
1626
			rulers: rulers,
A
Alex Dima 已提交
1627
			ariaLabel: _string(opts.ariaLabel, defaults.ariaLabel),
1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
			renderLineNumbers: renderLineNumbers,
			renderCustomLineNumbers: renderCustomLineNumbers,
			renderRelativeLineNumbers: renderRelativeLineNumbers,
			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),
			hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler),
			scrollBeyondLastLine: _boolean(opts.scrollBeyondLastLine, defaults.scrollBeyondLastLine),
1642
			smoothScrolling: _boolean(opts.smoothScrolling, defaults.smoothScrolling),
1643
			stopRenderingLineAfter: _clampedInt(opts.stopRenderingLineAfter, defaults.stopRenderingLineAfter, -1, Constants.MAX_SAFE_SMALL_INTEGER),
A
Alex Dima 已提交
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654
			renderWhitespace: renderWhitespace,
			renderControlCharacters: _boolean(opts.renderControlCharacters, defaults.renderControlCharacters),
			fontLigatures: fontLigatures,
			renderIndentGuides: _boolean(opts.renderIndentGuides, defaults.renderIndentGuides),
			renderLineHighlight: renderLineHighlight,
			scrollbar: scrollbar,
			minimap: minimap,
			fixedOverflowWidgets: _boolean(opts.fixedOverflowWidgets, defaults.fixedOverflowWidgets),
		};
	}

1655
	private static _sanitizeContribInfo(opts: IEditorOptions, defaults: EditorContribOptions): EditorContribOptions {
A
Alex Dima 已提交
1656 1657 1658 1659 1660 1661
		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);
		}
1662
		const find = this._santizeFindOpts(opts.find, defaults.find);
A
Alex Dima 已提交
1663 1664
		return {
			selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard),
1665
			hover: _boolean(opts.hover, defaults.hover),
1666
			links: _boolean(opts.links, defaults.links),
1667 1668 1669 1670 1671 1672 1673 1674
			contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
			quickSuggestions: quickSuggestions,
			quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
			parameterHints: _boolean(opts.parameterHints, defaults.parameterHints),
			iconsInSuggestions: _boolean(opts.iconsInSuggestions, defaults.iconsInSuggestions),
			formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
			formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
			suggestOnTriggerCharacters: _boolean(opts.suggestOnTriggerCharacters, defaults.suggestOnTriggerCharacters),
J
Johannes Rieken 已提交
1675
			acceptSuggestionOnEnter: typeof opts.acceptSuggestionOnEnter === 'string' ? _stringSet<'on' | 'smart' | 'off'>(opts.acceptSuggestionOnEnter, defaults.acceptSuggestionOnEnter, ['on', 'smart', 'off']) : opts.acceptSuggestionOnEnter ? 'on' : 'off',
1676 1677 1678 1679 1680
			acceptSuggestionOnCommitCharacter: _boolean(opts.acceptSuggestionOnCommitCharacter, defaults.acceptSuggestionOnCommitCharacter),
			snippetSuggestions: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippetSuggestions, ['top', 'bottom', 'inline', 'none']),
			wordBasedSuggestions: _boolean(opts.wordBasedSuggestions, defaults.wordBasedSuggestions),
			suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
			suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
1681 1682 1683 1684
			selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
			occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
			codeLens: _boolean(opts.codeLens, defaults.codeLens) && _boolean(opts.referenceInfos, true),
			folding: _boolean(opts.folding, defaults.folding),
1685
			showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
1686
			matchBrackets: _boolean(opts.matchBrackets, defaults.matchBrackets),
1687
			find: find,
R
rebornix 已提交
1688
			colorDecorators: _boolean(opts.colorDecorators, defaults.colorDecorators),
I
isidor 已提交
1689
			lightbulbEnabled: _boolean(opts.lightbulb ? opts.lightbulb.enabled : false, defaults.lightbulbEnabled)
1690 1691 1692 1693 1694 1695 1696 1697 1698
		};
	}
}

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

1699 1700 1701
	private static _tweakValidatedOptions(opts: IValidatedEditorOptions, accessibilitySupport: platform.AccessibilitySupport): IValidatedEditorOptions {
		const accessibilityIsOn = (accessibilitySupport === platform.AccessibilitySupport.Enabled);
		const accessibilityIsOff = (accessibilitySupport === platform.AccessibilitySupport.Disabled);
1702 1703 1704 1705 1706 1707 1708
		return {
			inDiffEditor: opts.inDiffEditor,
			wordSeparators: opts.wordSeparators,
			lineNumbersMinChars: opts.lineNumbersMinChars,
			lineDecorationsWidth: opts.lineDecorationsWidth,
			readOnly: opts.readOnly,
			mouseStyle: opts.mouseStyle,
1709
			disableLayerHinting: opts.disableLayerHinting,
1710 1711 1712 1713 1714 1715 1716 1717 1718
			automaticLayout: opts.automaticLayout,
			wordWrap: opts.wordWrap,
			wordWrapColumn: opts.wordWrapColumn,
			wordWrapMinified: opts.wordWrapMinified,
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
			autoClosingBrackets: opts.autoClosingBrackets,
1719
			autoIndent: opts.autoIndent,
1720 1721 1722
			dragAndDrop: opts.dragAndDrop,
			emptySelectionClipboard: opts.emptySelectionClipboard,
			useTabStops: opts.useTabStops,
1723
			multiCursorModifier: opts.multiCursorModifier,
1724
			accessibilitySupport: opts.accessibilitySupport,
1725 1726 1727 1728 1729

			viewInfo: {
				extraEditorClassName: opts.viewInfo.extraEditorClassName,
				disableMonospaceOptimizations: opts.viewInfo.disableMonospaceOptimizations,
				rulers: opts.viewInfo.rulers,
1730
				ariaLabel: (accessibilityIsOff ? nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.") : opts.viewInfo.ariaLabel),
1731 1732 1733 1734 1735 1736
				renderLineNumbers: opts.viewInfo.renderLineNumbers,
				renderCustomLineNumbers: opts.viewInfo.renderCustomLineNumbers,
				renderRelativeLineNumbers: opts.viewInfo.renderRelativeLineNumbers,
				selectOnLineNumbers: opts.viewInfo.selectOnLineNumbers,
				glyphMargin: opts.viewInfo.glyphMargin,
				revealHorizontalRightPadding: opts.viewInfo.revealHorizontalRightPadding,
1737
				roundedSelection: (accessibilityIsOn ? false : opts.viewInfo.roundedSelection), // DISABLED WHEN SCREEN READER IS ATTACHED
1738 1739 1740 1741 1742 1743 1744
				overviewRulerLanes: opts.viewInfo.overviewRulerLanes,
				overviewRulerBorder: opts.viewInfo.overviewRulerBorder,
				cursorBlinking: opts.viewInfo.cursorBlinking,
				mouseWheelZoom: opts.viewInfo.mouseWheelZoom,
				cursorStyle: opts.viewInfo.cursorStyle,
				hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler,
				scrollBeyondLastLine: opts.viewInfo.scrollBeyondLastLine,
1745
				smoothScrolling: opts.viewInfo.smoothScrolling,
1746
				stopRenderingLineAfter: opts.viewInfo.stopRenderingLineAfter,
1747 1748 1749 1750 1751
				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
				renderLineHighlight: (accessibilityIsOn ? 'none' : opts.viewInfo.renderLineHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
1752 1753
				scrollbar: opts.viewInfo.scrollbar,
				minimap: {
1754
					enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED
1755
					renderCharacters: opts.viewInfo.minimap.renderCharacters,
1756
					showSlider: opts.viewInfo.minimap.showSlider,
1757 1758 1759 1760 1761 1762 1763 1764
					maxColumn: opts.viewInfo.minimap.maxColumn
				},
				fixedOverflowWidgets: opts.viewInfo.fixedOverflowWidgets
			},

			contribInfo: {
				selectionClipboard: opts.contribInfo.selectionClipboard,
				hover: opts.contribInfo.hover,
1765
				links: (accessibilityIsOn ? false : opts.contribInfo.links), // DISABLED WHEN SCREEN READER IS ATTACHED
1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779
				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,
				snippetSuggestions: opts.contribInfo.snippetSuggestions,
				wordBasedSuggestions: opts.contribInfo.wordBasedSuggestions,
				suggestFontSize: opts.contribInfo.suggestFontSize,
				suggestLineHeight: opts.contribInfo.suggestLineHeight,
1780 1781 1782 1783
				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
1784
				showFoldingControls: opts.contribInfo.showFoldingControls,
1785
				matchBrackets: (accessibilityIsOn ? false : opts.contribInfo.matchBrackets), // DISABLED WHEN SCREEN READER IS ATTACHED
1786
				find: opts.contribInfo.find,
1787 1788
				colorDecorators: opts.contribInfo.colorDecorators,
				lightbulbEnabled: opts.contribInfo.lightbulbEnabled
1789 1790 1791 1792 1793 1794
			}
		};
	}

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

1795 1796 1797 1798 1799 1800 1801 1802 1803 1804
		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;
		}

1805 1806
		// Disable some non critical features to get as best performance as possible
		// See https://github.com/Microsoft/vscode/issues/26730
1807
		const opts = this._tweakValidatedOptions(_opts, accessibilitySupport);
1808 1809 1810 1811 1812 1813 1814 1815

		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 已提交
1816
		if (opts.contribInfo.folding) {
1817 1818 1819
			lineDecorationsWidth += 16;
		}

1820 1821 1822
		const layoutInfo = EditorLayoutProvider.compute({
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
A
Alex Dima 已提交
1823
			showGlyphMargin: opts.viewInfo.glyphMargin,
1824
			lineHeight: env.fontInfo.lineHeight,
A
Alex Dima 已提交
1825
			showLineNumbers: opts.viewInfo.renderLineNumbers,
1826
			lineNumbersMinChars: opts.lineNumbersMinChars,
1827 1828 1829 1830
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			lineDecorationsWidth: lineDecorationsWidth,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
A
Alex Dima 已提交
1831 1832 1833 1834 1835 1836 1837
			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,
			minimapRenderCharacters: opts.viewInfo.minimap.renderCharacters,
			minimapMaxColumn: opts.viewInfo.minimap.maxColumn,
1838 1839 1840 1841 1842
			pixelRatio: env.pixelRatio
		});

		let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } = null;
		{
A
Alex Dima 已提交
1843
			const wordWrap = opts.wordWrap;
1844 1845
			const wordWrapColumn = opts.wordWrapColumn;
			const wordWrapMinified = opts.wordWrapMinified;
1846

1847
			if (accessibilitySupport === platform.AccessibilitySupport.Enabled) {
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
				// 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) {
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890
				// 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 已提交
1891
		const wrappingInfo: EditorWrappingInfo = {
1892
			inDiffEditor: opts.inDiffEditor,
1893 1894 1895 1896
			isDominatedByLongLines: env.isDominatedByLongLines,
			isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
			isViewportWrapping: bareWrappingInfo.isViewportWrapping,
			wrappingColumn: bareWrappingInfo.wrappingColumn,
1897 1898 1899 1900
			wrappingIndent: opts.wrappingIndent,
			wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
			wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
			wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
A
Alex Dima 已提交
1901
		};
1902

1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918
		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';
		}

1919
		return new InternalEditorOptions({
1920
			canUseLayerHinting: opts.disableLayerHinting ? false : true,
1921
			pixelRatio: env.pixelRatio,
1922
			editorClassName: className,
A
Alex Dima 已提交
1923
			lineHeight: env.fontInfo.lineHeight,
1924
			readOnly: opts.readOnly,
1925
			accessibilitySupport: accessibilitySupport,
1926
			multiCursorModifier: opts.multiCursorModifier,
1927 1928
			wordSeparators: opts.wordSeparators,
			autoClosingBrackets: opts.autoClosingBrackets,
1929
			autoIndent: opts.autoIndent,
1930 1931 1932
			useTabStops: opts.useTabStops,
			tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
			dragAndDrop: opts.dragAndDrop,
1933
			emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard,
1934 1935
			layoutInfo: layoutInfo,
			fontInfo: env.fontInfo,
A
Alex Dima 已提交
1936
			viewInfo: opts.viewInfo,
1937
			wrappingInfo: wrappingInfo,
1938
			contribInfo: opts.contribInfo
1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
		});
	}
}

/**
 * @internal
 */
export interface IEditorLayoutProviderOpts {
	outerWidth: number;
	outerHeight: number;

	showGlyphMargin: boolean;
	lineHeight: number;

	showLineNumbers: boolean;
	lineNumbersMinChars: number;
	lineNumbersDigitCount: number;

	lineDecorationsWidth: number;

	typicalHalfwidthCharacterWidth: number;
	maxDigitWidth: number;

	verticalScrollbarWidth: number;
	verticalScrollbarHasArrows: boolean;
	scrollbarArrowSize: number;
	horizontalScrollbarHeight: number;

	minimap: boolean;
	minimapRenderCharacters: boolean;
	minimapMaxColumn: number;
	pixelRatio: number;
}

/**
 * @internal
 */
export class EditorLayoutProvider {
	public static compute(_opts: IEditorLayoutProviderOpts): EditorLayoutInfo {
		const outerWidth = _opts.outerWidth | 0;
		const outerHeight = _opts.outerHeight | 0;
A
Alex Dima 已提交
1980
		const showGlyphMargin = _opts.showGlyphMargin;
1981
		const lineHeight = _opts.lineHeight | 0;
A
Alex Dima 已提交
1982
		const showLineNumbers = _opts.showLineNumbers;
1983 1984 1985
		const lineNumbersMinChars = _opts.lineNumbersMinChars | 0;
		const lineNumbersDigitCount = _opts.lineNumbersDigitCount | 0;
		const lineDecorationsWidth = _opts.lineDecorationsWidth | 0;
A
Alex Dima 已提交
1986 1987
		const typicalHalfwidthCharacterWidth = _opts.typicalHalfwidthCharacterWidth;
		const maxDigitWidth = _opts.maxDigitWidth;
1988
		const verticalScrollbarWidth = _opts.verticalScrollbarWidth | 0;
A
Alex Dima 已提交
1989
		const verticalScrollbarHasArrows = _opts.verticalScrollbarHasArrows;
1990 1991
		const scrollbarArrowSize = _opts.scrollbarArrowSize | 0;
		const horizontalScrollbarHeight = _opts.horizontalScrollbarHeight | 0;
A
Alex Dima 已提交
1992 1993
		const minimap = _opts.minimap;
		const minimapRenderCharacters = _opts.minimapRenderCharacters;
1994
		const minimapMaxColumn = _opts.minimapMaxColumn | 0;
A
Alex Dima 已提交
1995
		const pixelRatio = _opts.pixelRatio;
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055

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

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

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

		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;

		let renderMinimap: RenderMinimap;
		let minimapWidth: number;
		let contentWidth: number;
		if (!minimap) {
			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:
			// viewportColumn = (contentWidth - verticalScrollbarWidth) / typicalHalfwidthCharacterWidth
			// minimapWidth = viewportColumn * minimapCharWidth
			// contentWidth = remainingWidth - minimapWidth
			// What are good values for contentWidth and minimapWidth ?

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

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

		const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth) / typicalHalfwidthCharacterWidth));

		const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);

A
Alex Dima 已提交
2056
		return {
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083
			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,
			minimapWidth: minimapWidth,

			viewportColumn: viewportColumn,

			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

A
Alex Dima 已提交
2084
			overviewRuler: {
2085 2086 2087 2088
				top: verticalArrowSize,
				width: verticalScrollbarWidth,
				height: (outerHeight - 2 * verticalArrowSize),
				right: 0
A
Alex Dima 已提交
2089 2090
			}
		};
2091 2092
	}
}
2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109

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\', \'Courier New\', monospace, \'Droid Sans Fallback\'';

/**
 * @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,
2110
	letterSpacing: 0,
2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132
};

/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
	insertSpaces: true,
	detectIndentation: true,
	trimAutoWhitespace: true
};

/**
 * @internal
 */
export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
	inDiffEditor: false,
	wordSeparators: USUAL_WORD_SEPARATORS,
	lineNumbersMinChars: 5,
	lineDecorationsWidth: 10,
	readOnly: false,
	mouseStyle: 'text',
2133
	disableLayerHinting: false,
2134 2135 2136 2137 2138 2139
	automaticLayout: false,
	wordWrap: 'off',
	wordWrapColumn: 80,
	wordWrapMinified: true,
	wrappingIndent: WrappingIndent.Same,
	wordWrapBreakBeforeCharacters: '([{‘“〈《「『【〔([{「£¥$£¥++',
2140
	wordWrapBreakAfterCharacters: ' \t})]?|&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
2141 2142
	wordWrapBreakObtrusiveCharacters: '.',
	autoClosingBrackets: true,
R
rebornix 已提交
2143
	autoIndent: true,
2144
	dragAndDrop: true,
2145
	emptySelectionClipboard: true,
2146
	useTabStops: true,
2147
	multiCursorModifier: 'altKey',
2148
	accessibilitySupport: 'auto',
A
Alex Dima 已提交
2149 2150

	viewInfo: {
2151
		extraEditorClassName: '',
A
Alex Dima 已提交
2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168
		disableMonospaceOptimizations: false,
		rulers: [],
		ariaLabel: nls.localize('editorViewAccessibleLabel', "Editor content"),
		renderLineNumbers: true,
		renderCustomLineNumbers: null,
		renderRelativeLineNumbers: false,
		selectOnLineNumbers: true,
		glyphMargin: true,
		revealHorizontalRightPadding: 30,
		roundedSelection: true,
		overviewRulerLanes: 2,
		overviewRulerBorder: true,
		cursorBlinking: TextEditorCursorBlinkingStyle.Blink,
		mouseWheelZoom: false,
		cursorStyle: TextEditorCursorStyle.Line,
		hideCursorInOverviewRuler: false,
		scrollBeyondLastLine: true,
2169
		smoothScrolling: false,
A
Alex Dima 已提交
2170 2171 2172 2173
		stopRenderingLineAfter: 10000,
		renderWhitespace: 'none',
		renderControlCharacters: false,
		fontLigatures: false,
2174
		renderIndentGuides: true,
A
Alex Dima 已提交
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190
		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: {
2191
			enabled: true,
2192
			showSlider: 'mouseover',
A
Alex Dima 已提交
2193 2194 2195 2196 2197 2198 2199 2200 2201
			renderCharacters: true,
			maxColumn: 120
		},
		fixedOverflowWidgets: false,
	},

	contribInfo: {
		selectionClipboard: true,
		hover: true,
2202
		links: true,
A
Alex Dima 已提交
2203 2204 2205 2206 2207 2208
		contextmenu: true,
		quickSuggestions: { other: true, comments: false, strings: false },
		quickSuggestionsDelay: 10,
		parameterHints: true,
		iconsInSuggestions: true,
		formatOnType: false,
2209
		formatOnPaste: false,
A
Alex Dima 已提交
2210
		suggestOnTriggerCharacters: true,
2211
		acceptSuggestionOnEnter: 'on',
A
Alex Dima 已提交
2212 2213 2214 2215 2216 2217 2218 2219 2220
		acceptSuggestionOnCommitCharacter: true,
		snippetSuggestions: 'inline',
		wordBasedSuggestions: true,
		suggestFontSize: 0,
		suggestLineHeight: 0,
		selectionHighlight: true,
		occurrencesHighlight: true,
		codeLens: true,
		folding: true,
2221
		showFoldingControls: 'mouseover',
A
Alex Dima 已提交
2222
		matchBrackets: true,
2223
		find: {
R
rebornix 已提交
2224 2225
			seedSearchStringFromSelection: true,
			autoFindInSelection: false
2226
		},
2227 2228
		colorDecorators: true,
		lightbulbEnabled: true
A
Alex Dima 已提交
2229
	},
2230
};