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

6 7
import * as nls from 'vs/nls';
import * as platform from 'vs/base/common/platform';
8 9
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
10
import { Constants } from 'vs/base/common/uint';
11
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
12
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
13
import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
M
Matt Bierner 已提交
14
import { IJSONSchema } from 'vs/base/common/jsonSchema';
15

A
Alex Dima 已提交
16
//#region typed options
17

J
Jackson Kearl 已提交
18
/**
J
Jackson Kearl 已提交
19
 * Configuration options for auto closing quotes and brackets
J
Jackson Kearl 已提交
20
 */
J
Jackson Kearl 已提交
21 22 23 24 25
export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';

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

28
/**
29
 * Configuration options for typing over closing quotes or brackets
30
 */
31
export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never';
32

A
wip  
Alexandru Dima 已提交
33 34 35 36 37 38 39 40 41 42 43
/**
 * Configuration options for auto indentation in the editor
 */
export const enum EditorAutoIndentStrategy {
	None = 0,
	Keep = 1,
	Brackets = 2,
	Advanced = 3,
	Full = 4
}

44 45 46 47 48 49 50 51 52 53 54 55
/**
 * Configuration options for the editor.
 */
export interface IEditorOptions {
	/**
	 * This editor is used inside a diff editor.
	 */
	inDiffEditor?: boolean;
	/**
	 * The aria label for the editor's textarea (when it is focused).
	 */
	ariaLabel?: string;
56 57 58 59
	/**
	 * The `tabindex` property of the editor's textarea
	 */
	tabIndex?: number;
60 61 62 63
	/**
	 * Render vertical lines at the specified columns.
	 * Defaults to empty array.
	 */
64
	rulers?: (number | IRulerOption)[];
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	/**
	 * 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.
R
rebornix 已提交
80
	 * Defaults to `on`.
81
	 */
A
Alex Dima 已提交
82
	lineNumbers?: LineNumbersType;
P
Peng Lyu 已提交
83
	/**
84
	 * Controls the minimal number of visible leading and trailing lines surrounding the cursor.
P
Peng Lyu 已提交
85 86
	 * Defaults to 0.
	*/
87
	cursorSurroundingLines?: number;
88 89 90 91 92 93
	/**
	 * Controls when `cursorSurroundingLines` should be enforced
	 * Defaults to `default`, `cursorSurroundingLines` is not enforced when cursor position is changed
	 * by mouse.
	*/
	cursorSurroundingLinesStyle?: 'default' | 'all';
A
Alex Dima 已提交
94 95
	/**
	 * Render last line number when the file ends with a newline.
A
Alex Dima 已提交
96
	 * Defaults to true.
97
	*/
A
Alex Dima 已提交
98
	renderFinalNewline?: boolean;
99
	/**
100
	 * Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
101
	 * Defaults to 'prompt'.
102
	 */
103
	unusualLineTerminators?: 'auto' | 'off' | 'prompt';
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
	/**
	 * 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;
	/**
138
	 * Class name to be added to the editor.
139
	 */
140
	extraEditorClassName?: string;
141 142 143 144 145
	/**
	 * Should the editor be read only.
	 * Defaults to false.
	 */
	readOnly?: boolean;
P
Rename  
Pine Wu 已提交
146 147 148 149 150
	/**
	 * Rename matching regions on type.
	 * Defaults to false.
	 */
	renameOnType?: boolean;
151 152 153 154 155
	/**
	 * Should the editor render validation decorations.
	 * Defaults to editable.
	 */
	renderValidationDecorations?: 'editable' | 'on' | 'off';
156 157 158 159 160 161 162 163
	/**
	 * Control the behavior and rendering of the scrollbars.
	 */
	scrollbar?: IEditorScrollbarOptions;
	/**
	 * Control the behavior and rendering of the minimap.
	 */
	minimap?: IEditorMinimapOptions;
164 165 166 167
	/**
	 * Control the behavior of the find widget.
	 */
	find?: IEditorFindOptions;
168 169 170 171 172 173 174
	/**
	 * Display overflow widgets as `fixed`.
	 * Defaults to `false`.
	 */
	fixedOverflowWidgets?: boolean;
	/**
	 * The number of vertical lanes the overview ruler should render.
175
	 * Defaults to 3.
176 177 178 179 180 181 182 183 184 185 186
	 */
	overviewRulerLanes?: number;
	/**
	 * Controls if a border should be drawn around the overview ruler.
	 * Defaults to `true`.
	 */
	overviewRulerBorder?: boolean;
	/**
	 * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
	 * Defaults to 'blink'.
	 */
A
Alex Dima 已提交
187
	cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
188 189 190 191 192 193 194 195 196 197
	/**
	 * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
	 * Defaults to false.
	 */
	mouseWheelZoom?: boolean;
	/**
	 * Control the mouse pointer style, either 'text' or 'default' or 'copy'
	 * Defaults to 'text'
	 */
	mouseStyle?: 'text' | 'default' | 'copy';
198 199 200 201 202
	/**
	 * Enable smooth caret animation.
	 * Defaults to false.
	 */
	cursorSmoothCaretAnimation?: boolean;
203 204 205 206
	/**
	 * Control the cursor style, either 'block' or 'line'.
	 * Defaults to 'line'.
	 */
A
Alex Dima 已提交
207
	cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
208 209 210
	/**
	 * Control the width of the cursor when cursorStyle is set to 'line'
	 */
211
	cursorWidth?: number;
212 213 214 215
	/**
	 * Enable font ligatures.
	 * Defaults to false.
	 */
216
	fontLigatures?: boolean | string;
217
	/**
218 219
	 * Disable the use of `transform: translate3d(0px, 0px, 0px)` for the editor margin and lines layers.
	 * The usage of `transform: translate3d(0px, 0px, 0px)` acts as a hint for browsers to create an extra layer.
220 221
	 * Defaults to false.
	 */
222
	disableLayerHinting?: boolean;
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
	/**
	 * 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;
238 239 240 241 242
	/**
	 * Enable that scrolling can go beyond the last column by a number of columns.
	 * Defaults to 5.
	 */
	scrollBeyondLastColumn?: number;
243 244
	/**
	 * Enable that the editor animates scrolling to a position.
245
	 * Defaults to false.
246 247
	 */
	smoothScrolling?: boolean;
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
	/**
	 * 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;
	/**
278
	 * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
279 280
	 * Defaults to 'same' in vscode and to 'none' in monaco-editor.
	 */
A
Alex Dima 已提交
281
	wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
282
	/**
283 284
	 * Controls the wrapping strategy to use.
	 * Defaults to 'simple'.
285
	 */
286
	wrappingStrategy?: 'simple' | 'advanced';
287 288
	/**
	 * Configure word wrapping characters. A break will be introduced before these characters.
289
	 * Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
290 291 292 293
	 */
	wordWrapBreakBeforeCharacters?: string;
	/**
	 * Configure word wrapping characters. A break will be introduced after these characters.
294
	 * Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
295 296 297 298 299 300 301 302 303
	 */
	wordWrapBreakAfterCharacters?: string;
	/**
	 * Performance guard: Stop rendering a line after x characters.
	 * Defaults to 10000.
	 * Use -1 to never stop rendering
	 */
	stopRenderingLineAfter?: number;
	/**
A
Alex Dima 已提交
304
	 * Configure the editor's hover.
305
	 */
A
Alex Dima 已提交
306
	hover?: IEditorHoverOptions;
307 308 309 310 311
	/**
	 * Enable detecting links and making them clickable.
	 * Defaults to true.
	 */
	links?: boolean;
312
	/**
313
	 * Enable inline color decorators and color picker rendering.
314
	 */
R
rebornix 已提交
315
	colorDecorators?: boolean;
A
Alex Dima 已提交
316 317 318 319
	/**
	 * Control the behaviour of comments in the editor.
	 */
	comments?: IEditorCommentsOptions;
320 321 322 323 324 325 326 327 328 329
	/**
	 * Enable custom contextmenu.
	 * Defaults to true.
	 */
	contextmenu?: boolean;
	/**
	 * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
	 * Defaults to 1.
	 */
	mouseWheelScrollSensitivity?: number;
T
Tiago Ribeiro 已提交
330
	/**
331 332
	 * FastScrolling mulitplier speed when pressing `Alt`
	 * Defaults to 5.
T
Tiago Ribeiro 已提交
333 334
	 */
	fastScrollSensitivity?: number;
335 336 337 338
	/**
	 * Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad.
	 * Defaults to true.
	 */
339
	scrollPredominantAxis?: boolean;
340 341 342 343 344
	/**
	 * Enable that the selection with the mouse and keys is doing column selection.
	 * Defaults to false.
	 */
	columnSelection?: boolean;
345 346 347 348
	/**
	 * The modifier to be used to add multiple cursors with the mouse.
	 * Defaults to 'alt'
	 */
349
	multiCursorModifier?: 'ctrlCmd' | 'alt';
350
	/**
A
Alex Dima 已提交
351
	 * Merge overlapping selections.
352 353
	 * Defaults to true
	 */
A
Alex Dima 已提交
354
	multiCursorMergeOverlapping?: boolean;
355 356 357 358 359
	/**
	 * Configure the behaviour when pasting a text with the line count equal to the cursor count.
	 * Defaults to 'spread'.
	 */
	multiCursorPaste?: 'spread' | 'full';
360 361 362 363 364
	/**
	 * Configure the editor's accessibility support.
	 * Defaults to 'auto'. It is best to leave this to 'auto'.
	 */
	accessibilitySupport?: 'auto' | 'off' | 'on';
I
isidor 已提交
365 366 367
	/**
	 * Controls the number of lines in the editor that can be read out by a screen reader
	 */
I
isidor 已提交
368
	accessibilityPageSize?: number;
369 370 371 372
	/**
	 * Suggest options.
	 */
	suggest?: ISuggestOptions;
373 374 375 376
	/**
	 * Smart select opptions;
	 */
	smartSelect?: ISmartSelectOptions;
377 378 379 380
	/**
	 *
	 */
	gotoLocation?: IGotoLocationOptions;
381 382 383 384
	/**
	 * Enable quick suggestions (shadow suggestions)
	 * Defaults to true.
	 */
A
Alex Dima 已提交
385
	quickSuggestions?: boolean | IQuickSuggestionsOptions;
386 387
	/**
	 * Quick suggestions show delay (in ms)
A
Alex Dima 已提交
388
	 * Defaults to 10 (ms)
389 390
	 */
	quickSuggestionsDelay?: number;
B
Bailey 已提交
391
	/**
B
Bailey 已提交
392
	 * Controls the spacing around the editor.
B
Bailey 已提交
393
	 */
B
Bailey 已提交
394
	padding?: IEditorPaddingOptions;
395
	/**
396
	 * Parameter hint options.
397
	 */
398
	parameterHints?: IEditorParameterHintOptions;
399
	/**
400
	 * Options for auto closing brackets.
401
	 * Defaults to language defined behavior.
402
	 */
J
Jackson Kearl 已提交
403
	autoClosingBrackets?: EditorAutoClosingStrategy;
404
	/**
405
	 * Options for auto closing quotes.
406
	 * Defaults to language defined behavior.
J
Jackson Kearl 已提交
407 408
	 */
	autoClosingQuotes?: EditorAutoClosingStrategy;
409 410 411 412
	/**
	 * Options for typing over closing quotes or brackets.
	 */
	autoClosingOvertype?: EditorAutoClosingOvertypeStrategy;
J
Jackson Kearl 已提交
413
	/**
414 415
	 * Options for auto surrounding.
	 * Defaults to always allowing auto surrounding.
416
	 */
417
	autoSurround?: EditorAutoSurroundStrategy;
418
	/**
R
rebornix 已提交
419 420
	 * Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.
	 * Defaults to advanced.
421
	 */
A
wip  
Alexandru Dima 已提交
422
	autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
	/**
	 * 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.
445
	 * Defaults to 'on'.
446
	 */
A
Alex Dima 已提交
447
	acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
448 449 450 451 452 453 454 455 456 457 458 459 460
	/**
	 * 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;
461
	/**
462
	 * Syntax highlighting is copied.
463
	 */
464
	copyWithSyntaxHighlighting?: boolean;
465 466 467
	/**
	 * The history mode for suggestions.
	 */
M
Martin Aeschlimann 已提交
468
	suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
469 470 471 472 473 474 475 476 477 478
	/**
	 * 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;
479 480 481
	/**
	 * Enable tab completion.
	 */
A
Alex Dima 已提交
482
	tabCompletion?: 'on' | 'off' | 'onlySnippets';
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
	/**
	 * 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;
498 499 500 501
	/**
	 * Control the behavior and rendering of the code action lightbulb.
	 */
	lightbulb?: IEditorLightbulbOptions;
502 503 504 505
	/**
	 * Timeout for running code actions on save.
	 */
	codeActionsOnSaveTimeout?: number;
506
	/**
507
	 * Enable code folding.
A
Alex Dima 已提交
508
	 * Defaults to true.
509 510
	 */
	folding?: boolean;
511 512 513 514 515
	/**
	 * 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';
516 517 518 519 520
	/**
	 * Enable highlight for folded regions.
	 * Defaults to true.
	 */
	foldingHighlight?: boolean;
521
	/**
522 523
	 * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
	 * Defaults to 'mouseover'.
524
	 */
525
	showFoldingControls?: 'always' | 'mouseover';
526 527 528 529
	/**
	 * Controls whether clicking on the empty content after a folded line will unfold the line.
	 * Defaults to false.
	 */
530
	unfoldOnClickAfterEndOfLine?: boolean;
531 532
	/**
	 * Enable highlighting of matching brackets.
533
	 * Defaults to 'always'.
534
	 */
535
	matchBrackets?: 'never' | 'near' | 'always';
536 537 538 539
	/**
	 * Enable rendering of whitespace.
	 * Defaults to none.
	 */
540
	renderWhitespace?: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
541 542 543 544 545 546 547
	/**
	 * Enable rendering of control characters.
	 * Defaults to false.
	 */
	renderControlCharacters?: boolean;
	/**
	 * Enable rendering of indent guides.
548
	 * Defaults to true.
549 550
	 */
	renderIndentGuides?: boolean;
551
	/**
C
typo  
Coenraad Stijne 已提交
552
	 * Enable highlighting of the active indent guide.
553 554 555
	 * Defaults to true.
	 */
	highlightActiveIndentGuide?: boolean;
556 557 558 559 560
	/**
	 * Enable rendering of current line highlight.
	 * Defaults to all.
	 */
	renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
561 562 563 564 565
	/**
	 * Control if the current line highlight should be rendered only the editor is focused.
	 * Defaults to false.
	 */
	renderLineHighlightOnlyWhenFocus?: boolean;
566 567 568 569 570 571 572 573 574 575 576
	/**
	 * Inserting and deleting whitespace follows tab stops.
	 */
	useTabStops?: boolean;
	/**
	 * The font family
	 */
	fontFamily?: string;
	/**
	 * The font weight
	 */
577
	fontWeight?: string;
578 579 580 581 582 583 584 585
	/**
	 * The font size
	 */
	fontSize?: number;
	/**
	 * The line height
	 */
	lineHeight?: number;
586 587 588 589
	/**
	 * The letter spacing
	 */
	letterSpacing?: number;
590 591 592 593
	/**
	 * Controls fading out of unused variables.
	 */
	showUnused?: boolean;
594 595 596 597
	/**
	 * Controls whether to focus the inline editor in the peek widget by default.
	 * Defaults to false.
	 */
598
	peekWidgetDefaultFocus?: 'tree' | 'editor';
599
	/**
600
	 * Controls whether the definition link opens element in the peek widget.
601 602
	 * Defaults to false.
	 */
603
	definitionLinkOpensInPeek?: boolean;
604
	/**
605
	 * Controls strikethrough deprecated variables.
606
	 */
607
	showDeprecated?: boolean;
608 609
}

610 611 612 613 614 615
/**
 * @internal
 * The width of the minimap gutter, in pixels.
 */
export const MINIMAP_GUTTER_WIDTH = 8;

616 617 618 619 620 621 622 623 624 625 626 627 628 629
/**
 * 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;
630 631 632 633
	/**
	 * Timeout in milliseconds after which diff computation is cancelled.
	 * Defaults to 5000.
	 */
634
	maxComputationTime?: number;
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
	/**
	 * 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;
650 651 652 653 654 655
	/**
	 * Original editor should be have code lens enabled?
	 * Defaults to false.
	 */
	originalCodeLens?: boolean;
	/**
656
	 * Modified editor should be have code lens enabled?
657 658 659
	 * Defaults to false.
	 */
	modifiedCodeLens?: boolean;
660 661
}

A
Alex Dima 已提交
662
//#endregion
663 664

/**
665
 * An event describing that the configuration of the editor has changed.
666
 */
667 668
export class ConfigurationChangedEvent {
	private readonly _values: boolean[];
669 670 671
	/**
	 * @internal
	 */
672 673
	constructor(values: boolean[]) {
		this._values = values;
674
	}
675 676
	public hasChanged(id: EditorOption): boolean {
		return this._values[id];
677 678 679 680
	}
}

/**
681
 * @internal
682
 */
683 684
export class ValidatedEditorOptions {
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
685
	public _read<T>(option: EditorOption): T {
686 687
		return this._values[option];
	}
A
Alex Dima 已提交
688 689 690
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
691
	public _write<T>(option: EditorOption, value: T): void {
692 693
		this._values[option] = value;
	}
694
}
695

696
/**
697
 * All computed editor options.
698
 */
A
Alex Dima 已提交
699
export interface IComputedEditorOptions {
A
renames  
Alex Dima 已提交
700
	get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
701
}
702

A
Alex Dima 已提交
703 704
//#region IEditorOption

705
/**
A
Alex Dima 已提交
706
 * @internal
707
 */
A
Alex Dima 已提交
708
export interface IEnvironmentalOptions {
709
	readonly memory: ComputeOptionsMemory | null;
A
Alex Dima 已提交
710 711 712 713 714
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
	readonly extraEditorClassName: string;
	readonly isDominatedByLongLines: boolean;
715
	readonly viewLineCount: number;
A
Alex Dima 已提交
716 717 718 719 720 721 722
	readonly lineNumbersDigitCount: number;
	readonly emptySelectionClipboard: boolean;
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
	readonly accessibilitySupport: AccessibilitySupport;
}

723 724 725
/**
 * @internal
 */
726 727
export class ComputeOptionsMemory {

A
Alex Dima 已提交
728 729 730
	public stableMinimapLayoutInput: IMinimapLayoutInput | null;
	public stableFitMaxMinimapScale: number;
	public stableFitRemainingWidth: number;
731 732

	constructor() {
A
Alex Dima 已提交
733 734 735
		this.stableMinimapLayoutInput = null;
		this.stableFitMaxMinimapScale = 0;
		this.stableFitRemainingWidth = 0;
736
	}
737 738
}

A
Alex Dima 已提交
739 740 741
export interface IEditorOption<K1 extends EditorOption, V> {
	readonly id: K1;
	readonly name: string;
742
	defaultValue: V;
743
	/**
744
	 * @internal
745
	 */
746
	readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; } | undefined;
747
	/**
A
Alex Dima 已提交
748
	 * @internal
749
	 */
A
Alex Dima 已提交
750
	validate(input: any): V;
751
	/**
A
Alex Dima 已提交
752
	 * @internal
753
	 */
A
Alex Dima 已提交
754 755 756
	compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
}

A
Alex Dima 已提交
757
type PossibleKeyName0<V> = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions];
758
type PossibleKeyName<V> = NonNullable<PossibleKeyName0<V>>;
759

760 761 762
/**
 * @internal
 */
763
abstract class BaseEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {
A
Alex Dima 已提交
764 765

	public readonly id: K1;
766
	public readonly name: string;
A
Alex Dima 已提交
767
	public readonly defaultValue: V;
768
	public readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; } | undefined;
A
Alex Dima 已提交
769

770
	constructor(id: K1, name: string, defaultValue: V, schema?: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; }) {
A
Alex Dima 已提交
771 772 773
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
774
		this.schema = schema;
A
Alex Dima 已提交
775 776 777 778 779 780 781
	}

	public abstract validate(input: any): V;

	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
	}
782 783 784 785 786
}

/**
 * @internal
 */
A
Alex Dima 已提交
787
abstract class ComputedEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {
A
Alex Dima 已提交
788

789
	public readonly id: K1;
A
Alex Dima 已提交
790 791 792
	public readonly name: '_never_';
	public readonly defaultValue: V;
	public readonly deps: EditorOption[] | null;
793
	public readonly schema: IConfigurationPropertySchema | undefined = undefined;
A
Alex Dima 已提交
794 795 796 797 798 799

	constructor(id: K1, deps: EditorOption[] | null = null) {
		this.id = id;
		this.name = '_never_';
		this.defaultValue = <any>undefined;
		this.deps = deps;
A
Alex Dima 已提交
800 801
	}

A
Alex Dima 已提交
802 803 804
	public validate(input: any): V {
		return this.defaultValue;
	}
805

A
Alex Dima 已提交
806
	public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
807 808
}

A
Alex Dima 已提交
809
class SimpleEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {
810

A
Alex Dima 已提交
811 812 813
	public readonly id: K1;
	public readonly name: PossibleKeyName<V>;
	public readonly defaultValue: V;
814
	public readonly schema: IConfigurationPropertySchema | undefined;
A
Alex Dima 已提交
815

816
	constructor(id: K1, name: PossibleKeyName<V>, defaultValue: V, schema?: IConfigurationPropertySchema) {
817 818 819
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
820
		this.schema = schema;
A
Alex Dima 已提交
821
	}
822

A
Alex Dima 已提交
823 824 825
	public validate(input: any): V {
		if (typeof input === 'undefined') {
			return this.defaultValue;
A
Alex Dima 已提交
826
		}
A
Alex Dima 已提交
827 828
		return input as any;
	}
829

A
Alex Dima 已提交
830 831
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
832
	}
833 834
}

A
Alex Dima 已提交
835
class EditorBooleanOption<K1 extends EditorOption> extends SimpleEditorOption<K1, boolean> {
836

A
Alex Dima 已提交
837 838 839 840 841 842 843 844 845
	public static boolean(value: any, defaultValue: boolean): boolean {
		if (typeof value === 'undefined') {
			return defaultValue;
		}
		if (value === 'false') {
			// treat the string 'false' as false
			return false;
		}
		return Boolean(value);
A
Alex Dima 已提交
846
	}
847

848
	constructor(id: K1, name: PossibleKeyName<boolean>, defaultValue: boolean, schema: IConfigurationPropertySchema | undefined = undefined) {
849 850 851 852
		if (typeof schema !== 'undefined') {
			schema.type = 'boolean';
			schema.default = defaultValue;
		}
853
		super(id, name, defaultValue, schema);
854
	}
855

A
Alex Dima 已提交
856
	public validate(input: any): boolean {
A
Alex Dima 已提交
857
		return EditorBooleanOption.boolean(input, this.defaultValue);
858
	}
859 860
}

A
Alex Dima 已提交
861
class EditorIntOption<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
862

A
Alex Dima 已提交
863
	public static clampedInt<T>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
A
Alex Dima 已提交
864
		if (typeof value === 'undefined') {
A
Alex Dima 已提交
865 866 867 868 869
			return defaultValue;
		}
		let r = parseInt(value, 10);
		if (isNaN(r)) {
			return defaultValue;
A
Alex Dima 已提交
870 871 872 873 874
		}
		r = Math.max(minimum, r);
		r = Math.min(maximum, r);
		return r | 0;
	}
A
Alex Dima 已提交
875

A
Alex Dima 已提交
876 877
	public readonly minimum: number;
	public readonly maximum: number;
878

879 880 881 882 883 884 885 886
	constructor(id: K1, name: PossibleKeyName<number>, defaultValue: number, minimum: number, maximum: number, schema: IConfigurationPropertySchema | undefined = undefined) {
		if (typeof schema !== 'undefined') {
			schema.type = 'integer';
			schema.default = defaultValue;
			schema.minimum = minimum;
			schema.maximum = maximum;
		}
		super(id, name, defaultValue, schema);
A
Alex Dima 已提交
887 888
		this.minimum = minimum;
		this.maximum = maximum;
889 890
	}

A
Alex Dima 已提交
891
	public validate(input: any): number {
A
Alex Dima 已提交
892
		return EditorIntOption.clampedInt(input, this.defaultValue, this.minimum, this.maximum);
893
	}
A
Alex Dima 已提交
894
}
895

A
Alex Dima 已提交
896
class EditorFloatOption<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
A
Alex Dima 已提交
897 898 899 900 901 902 903 904 905

	public static clamp(n: number, min: number, max: number): number {
		if (n < min) {
			return min;
		}
		if (n > max) {
			return max;
		}
		return n;
906 907
	}

A
Alex Dima 已提交
908 909 910 911 912 913 914 915 916
	public static float(value: any, defaultValue: number): number {
		if (typeof value === 'number') {
			return value;
		}
		if (typeof value === 'undefined') {
			return defaultValue;
		}
		const r = parseFloat(value);
		return (isNaN(r) ? defaultValue : r);
A
Alex Dima 已提交
917
	}
918

A
Alex Dima 已提交
919
	public readonly validationFn: (value: number) => number;
920 921 922 923 924 925 926

	constructor(id: K1, name: PossibleKeyName<number>, defaultValue: number, validationFn: (value: number) => number, schema?: IConfigurationPropertySchema) {
		if (typeof schema !== 'undefined') {
			schema.type = 'number';
			schema.default = defaultValue;
		}
		super(id, name, defaultValue, schema);
A
Alex Dima 已提交
927
		this.validationFn = validationFn;
A
Alex Dima 已提交
928 929
	}

A
Alex Dima 已提交
930
	public validate(input: any): number {
A
Alex Dima 已提交
931
		return this.validationFn(EditorFloatOption.float(input, this.defaultValue));
A
Alex Dima 已提交
932
	}
933
}
A
Alex Dima 已提交
934

A
Alex Dima 已提交
935
class EditorStringOption<K1 extends EditorOption> extends SimpleEditorOption<K1, string> {
A
Alex Dima 已提交
936 937 938 939 940 941

	public static string(value: any, defaultValue: string): string {
		if (typeof value !== 'string') {
			return defaultValue;
		}
		return value;
A
Alex Dima 已提交
942 943
	}

944 945 946 947 948 949
	constructor(id: K1, name: PossibleKeyName<string>, defaultValue: string, schema: IConfigurationPropertySchema | undefined = undefined) {
		if (typeof schema !== 'undefined') {
			schema.type = 'string';
			schema.default = defaultValue;
		}
		super(id, name, defaultValue, schema);
A
Alex Dima 已提交
950 951
	}

A
Alex Dima 已提交
952
	public validate(input: any): string {
A
Alex Dima 已提交
953
		return EditorStringOption.string(input, this.defaultValue);
954
	}
A
Alex Dima 已提交
955
}
956

A
Alex Dima 已提交
957
class EditorStringEnumOption<K1 extends EditorOption, V extends string> extends SimpleEditorOption<K1, V> {
A
Alex Dima 已提交
958 959 960 961 962 963 964 965 966

	public static stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: ReadonlyArray<T>): T {
		if (typeof value !== 'string') {
			return defaultValue;
		}
		if (allowedValues.indexOf(value) === -1) {
			return defaultValue;
		}
		return value;
967 968
	}

969 970 971 972 973 974 975 976 977 978
	private readonly _allowedValues: ReadonlyArray<V>;

	constructor(id: K1, name: PossibleKeyName<V>, defaultValue: V, allowedValues: ReadonlyArray<V>, schema: IConfigurationPropertySchema | undefined = undefined) {
		if (typeof schema !== 'undefined') {
			schema.type = 'string';
			schema.enum = <any>allowedValues;
			schema.default = defaultValue;
		}
		super(id, name, defaultValue, schema);
		this._allowedValues = allowedValues;
A
Alex Dima 已提交
979 980
	}

A
Alex Dima 已提交
981
	public validate(input: any): V {
982
		return EditorStringEnumOption.stringSet<V>(input, this.defaultValue, this._allowedValues);
A
Alex Dima 已提交
983 984 985
	}
}

986 987 988 989 990 991 992 993 994
class EditorEnumOption<K1 extends EditorOption, T extends string, V> extends BaseEditorOption<K1, V> {

	private readonly _allowedValues: T[];
	private readonly _convert: (value: T) => V;

	constructor(id: K1, name: PossibleKeyName<T>, defaultValue: V, defaultStringValue: string, allowedValues: T[], convert: (value: T) => V, schema: IConfigurationPropertySchema | undefined = undefined) {
		if (typeof schema !== 'undefined') {
			schema.type = 'string';
			schema.enum = allowedValues;
995
			schema.default = defaultStringValue;
996
		}
997 998 999
		super(id, name, defaultValue, schema);
		this._allowedValues = allowedValues;
		this._convert = convert;
1000 1001
	}

A
Alex Dima 已提交
1002 1003
	public validate(input: any): V {
		if (typeof input !== 'string') {
A
Alex Dima 已提交
1004 1005
			return this.defaultValue;
		}
1006
		if (this._allowedValues.indexOf(<T>input) === -1) {
A
Alex Dima 已提交
1007 1008
			return this.defaultValue;
		}
1009
		return this._convert(<any>input);
1010
	}
A
Alex Dima 已提交
1011
}
1012

A
Alex Dima 已提交
1013
//#endregion
A
Alex Dima 已提交
1014

A
wip  
Alexandru Dima 已提交
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
//#region autoIndent

function _autoIndentFromString(autoIndent: 'none' | 'keep' | 'brackets' | 'advanced' | 'full'): EditorAutoIndentStrategy {
	switch (autoIndent) {
		case 'none': return EditorAutoIndentStrategy.None;
		case 'keep': return EditorAutoIndentStrategy.Keep;
		case 'brackets': return EditorAutoIndentStrategy.Brackets;
		case 'advanced': return EditorAutoIndentStrategy.Advanced;
		case 'full': return EditorAutoIndentStrategy.Full;
	}
}

//#endregion

A
Alex Dima 已提交
1029 1030
//#region accessibilitySupport

1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
class EditorAccessibilitySupport extends BaseEditorOption<EditorOption.accessibilitySupport, AccessibilitySupport> {

	constructor() {
		super(
			EditorOption.accessibilitySupport, 'accessibilitySupport', AccessibilitySupport.Unknown,
			{
				type: 'string',
				enum: ['auto', 'on', 'off'],
				enumDescriptions: [
					nls.localize('accessibilitySupport.auto', "The editor will use platform APIs to detect when a Screen Reader is attached."),
A
Alex Dima 已提交
1041
					nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader. Word wrapping will be disabled."),
1042 1043 1044
					nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."),
				],
				default: 'auto',
A
Alex Dima 已提交
1045
				description: nls.localize('accessibilitySupport', "Controls whether the editor should run in a mode where it is optimized for screen readers. Setting to on will disable word wrapping.")
1046
			}
A
Alex Dima 已提交
1047 1048 1049
		);
	}

A
Alex Dima 已提交
1050 1051 1052 1053 1054
	public validate(input: any): AccessibilitySupport {
		switch (input) {
			case 'auto': return AccessibilitySupport.Unknown;
			case 'off': return AccessibilitySupport.Disabled;
			case 'on': return AccessibilitySupport.Enabled;
A
Alex Dima 已提交
1055
		}
A
Alex Dima 已提交
1056
		return this.defaultValue;
A
Alex Dima 已提交
1057
	}
1058

A
Alex Dima 已提交
1059 1060
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: AccessibilitySupport): AccessibilitySupport {
		if (value === AccessibilitySupport.Unknown) {
A
Alex Dima 已提交
1061 1062
			// The editor reads the `accessibilitySupport` from the environment
			return env.accessibilitySupport;
A
Alex Dima 已提交
1063
		}
A
Alex Dima 已提交
1064
		return value;
1065 1066 1067
	}
}

A
Alex Dima 已提交
1068 1069
//#endregion

A
Alex Dima 已提交
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080
//#region comments

/**
 * Configuration options for editor comments
 */
export interface IEditorCommentsOptions {
	/**
	 * Insert a space after the line comment token and inside the block comments tokens.
	 * Defaults to true.
	 */
	insertSpace?: boolean;
1081
	/**
1082 1083
	 * Ignore empty lines when inserting line comments.
	 * Defaults to true.
1084
	 */
1085
	ignoreEmptyLines?: boolean;
A
Alex Dima 已提交
1086 1087 1088 1089 1090 1091 1092 1093 1094
}

export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;

class EditorComments extends BaseEditorOption<EditorOption.comments, EditorCommentsOptions> {

	constructor() {
		const defaults: EditorCommentsOptions = {
			insertSpace: true,
1095
			ignoreEmptyLines: true,
A
Alex Dima 已提交
1096 1097 1098 1099 1100 1101 1102 1103 1104
		};
		super(
			EditorOption.comments, 'comments', defaults,
			{
				'editor.comments.insertSpace': {
					type: 'boolean',
					default: defaults.insertSpace,
					description: nls.localize('comments.insertSpace', "Controls whether a space character is inserted when commenting.")
				},
1105
				'editor.comments.ignoreEmptyLines': {
1106
					type: 'boolean',
1107 1108
					default: defaults.ignoreEmptyLines,
					description: nls.localize('comments.ignoreEmptyLines', 'Controls if empty lines should be ignored with toggle, add or remove actions for line comments.')
1109
				},
A
Alex Dima 已提交
1110 1111 1112 1113 1114
			}
		);
	}

	public validate(_input: any): EditorCommentsOptions {
A
Alex Dima 已提交
1115
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1116 1117 1118 1119 1120
			return this.defaultValue;
		}
		const input = _input as IEditorCommentsOptions;
		return {
			insertSpace: EditorBooleanOption.boolean(input.insertSpace, this.defaultValue.insertSpace),
1121
			ignoreEmptyLines: EditorBooleanOption.boolean(input.ignoreEmptyLines, this.defaultValue.ignoreEmptyLines),
A
Alex Dima 已提交
1122 1123 1124 1125 1126 1127
		};
	}
}

//#endregion

1128
//#region cursorBlinking
A
Alex Dima 已提交
1129

A
Alex Dima 已提交
1130
/**
A
Alex Dima 已提交
1131
 * The kind of animation in which the editor's cursor should be rendered.
A
Alex Dima 已提交
1132
 */
A
Alex Dima 已提交
1133
export const enum TextEditorCursorBlinkingStyle {
A
Alex Dima 已提交
1134
	/**
A
Alex Dima 已提交
1135
	 * Hidden
A
Alex Dima 已提交
1136
	 */
A
Alex Dima 已提交
1137
	Hidden = 0,
A
Alex Dima 已提交
1138
	/**
A
Alex Dima 已提交
1139
	 * Blinking
A
Alex Dima 已提交
1140
	 */
A
Alex Dima 已提交
1141
	Blink = 1,
A
Alex Dima 已提交
1142
	/**
A
Alex Dima 已提交
1143
	 * Blinking with smooth fading
A
Alex Dima 已提交
1144
	 */
A
Alex Dima 已提交
1145
	Smooth = 2,
A
Alex Dima 已提交
1146
	/**
A
Alex Dima 已提交
1147
	 * Blinking with prolonged filled state and smooth fading
A
Alex Dima 已提交
1148
	 */
A
Alex Dima 已提交
1149
	Phase = 3,
1150
	/**
A
Alex Dima 已提交
1151
	 * Expand collapse animation on the y axis
1152
	 */
A
Alex Dima 已提交
1153
	Expand = 4,
1154
	/**
A
Alex Dima 已提交
1155
	 * No-Blinking
1156
	 */
A
Alex Dima 已提交
1157 1158
	Solid = 5
}
1159

A
Alex Dima 已提交
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle {
	switch (cursorBlinkingStyle) {
		case 'blink': return TextEditorCursorBlinkingStyle.Blink;
		case 'smooth': return TextEditorCursorBlinkingStyle.Smooth;
		case 'phase': return TextEditorCursorBlinkingStyle.Phase;
		case 'expand': return TextEditorCursorBlinkingStyle.Expand;
		case 'solid': return TextEditorCursorBlinkingStyle.Solid;
	}
}

//#endregion

//#region cursorStyle

/**
 * 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): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' {
	switch (cursorStyle) {
		case TextEditorCursorStyle.Line: return 'line';
		case TextEditorCursorStyle.Block: return 'block';
		case TextEditorCursorStyle.Underline: return 'underline';
		case TextEditorCursorStyle.LineThin: return 'line-thin';
		case TextEditorCursorStyle.BlockOutline: return 'block-outline';
		case TextEditorCursorStyle.UnderlineThin: return 'underline-thin';
	}
}

function _cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle {
	switch (cursorStyle) {
		case 'line': return TextEditorCursorStyle.Line;
		case 'block': return TextEditorCursorStyle.Block;
		case 'underline': return TextEditorCursorStyle.Underline;
		case 'line-thin': return TextEditorCursorStyle.LineThin;
		case 'block-outline': return TextEditorCursorStyle.BlockOutline;
		case 'underline-thin': return TextEditorCursorStyle.UnderlineThin;
	}
}

//#endregion

1231
//#region editorClassName
A
Alex Dima 已提交
1232

1233
class EditorClassName extends ComputedEditorOption<EditorOption.editorClassName, string> {
A
Alex Dima 已提交
1234

1235
	constructor() {
1236
		super(EditorOption.editorClassName, [EditorOption.mouseStyle, EditorOption.extraEditorClassName]);
1237
	}
A
Alex Dima 已提交
1238

A
Alex Dima 已提交
1239
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string {
1240
		const classNames = ['monaco-editor'];
A
Alex Dima 已提交
1241
		if (options.get(EditorOption.extraEditorClassName)) {
1242
			classNames.push(options.get(EditorOption.extraEditorClassName));
A
Alex Dima 已提交
1243 1244
		}
		if (env.extraEditorClassName) {
1245
			classNames.push(env.extraEditorClassName);
A
Alex Dima 已提交
1246 1247
		}
		if (options.get(EditorOption.mouseStyle) === 'default') {
1248
			classNames.push('mouse-default');
A
Alex Dima 已提交
1249
		} else if (options.get(EditorOption.mouseStyle) === 'copy') {
1250
			classNames.push('mouse-copy');
A
Alex Dima 已提交
1251
		}
1252

1253
		if (options.get(EditorOption.showUnused)) {
1254
			classNames.push('showUnused');
1255
		}
1256 1257

		if (options.get(EditorOption.showDeprecated)) {
1258
			classNames.push('showDeprecated');
1259
		}
1260 1261

		return classNames.join(' ');
A
Alex Dima 已提交
1262 1263 1264 1265 1266
	}
}

//#endregion

A
Alex Dima 已提交
1267
//#region emptySelectionClipboard
1268

1269 1270 1271 1272 1273 1274 1275 1276 1277
class EditorEmptySelectionClipboard extends EditorBooleanOption<EditorOption.emptySelectionClipboard> {

	constructor() {
		super(
			EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true,
			{ description: nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.") }
		);
	}

A
Alex Dima 已提交
1278 1279
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
		return value && env.emptySelectionClipboard;
1280 1281 1282 1283 1284
	}
}

//#endregion

A
Alex Dima 已提交
1285
//#region find
A
Alex Dima 已提交
1286

1287 1288 1289 1290
/**
 * Configuration options for editor find widget
 */
export interface IEditorFindOptions {
T
Ted Goldman 已提交
1291 1292 1293
	/**
	* Controls whether the cursor should move to find matches while typing.
	*/
R
rebornix 已提交
1294
	cursorMoveOnType?: boolean;
1295 1296 1297 1298 1299
	/**
	 * Controls if we seed search string in the Find Widget with editor selection.
	 */
	seedSearchStringFromSelection?: boolean;
	/**
P
Peng Lyu 已提交
1300
	 * Controls if Find in Selection flag is turned on in the editor.
1301
	 */
P
Peng Lyu 已提交
1302
	autoFindInSelection?: 'never' | 'always' | 'multiline';
1303 1304 1305 1306 1307 1308 1309 1310 1311
	/*
	 * Controls whether the Find Widget should add extra lines on top of the editor.
	 */
	addExtraSpaceOnTop?: boolean;
	/**
	 * @internal
	 * Controls if the Find Widget should read or modify the shared find clipboard on macOS
	 */
	globalFindClipboard?: boolean;
1312 1313 1314 1315
	/**
	 * Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found
	 */
	loop?: boolean;
1316 1317
}

A
Alex Dima 已提交
1318
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
A
Alex Dima 已提交
1319

1320 1321 1322 1323
class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions> {

	constructor() {
		const defaults: EditorFindOptions = {
R
rebornix 已提交
1324
			cursorMoveOnType: true,
1325
			seedSearchStringFromSelection: true,
P
Peng Lyu 已提交
1326
			autoFindInSelection: 'never',
1327
			globalFindClipboard: false,
1328 1329
			addExtraSpaceOnTop: true,
			loop: true
1330 1331 1332 1333
		};
		super(
			EditorOption.find, 'find', defaults,
			{
R
rebornix 已提交
1334
				'editor.find.cursorMoveOnType': {
T
Ted Goldman 已提交
1335
					type: 'boolean',
R
rebornix 已提交
1336 1337
					default: defaults.cursorMoveOnType,
					description: nls.localize('find.cursorMoveOnType', "Controls whether the cursor should jump to find matches while typing.")
T
Ted Goldman 已提交
1338
				},
1339 1340 1341 1342 1343 1344
				'editor.find.seedSearchStringFromSelection': {
					type: 'boolean',
					default: defaults.seedSearchStringFromSelection,
					description: nls.localize('find.seedSearchStringFromSelection', "Controls whether the search string in the Find Widget is seeded from the editor selection.")
				},
				'editor.find.autoFindInSelection': {
P
Peng Lyu 已提交
1345 1346
					type: 'string',
					enum: ['never', 'always', 'multiline'],
1347
					default: defaults.autoFindInSelection,
P
Peng Lyu 已提交
1348 1349 1350 1351 1352
					enumDescriptions: [
						nls.localize('editor.find.autoFindInSelection.never', 'Never turn on Find in selection automatically (default)'),
						nls.localize('editor.find.autoFindInSelection.always', 'Always turn on Find in selection automatically'),
						nls.localize('editor.find.autoFindInSelection.multiline', 'Turn on Find in selection automatically when multiple lines of content are selected.')
					],
1353
					description: nls.localize('find.autoFindInSelection', "Controls the condition for turning on find in selection automatically.")
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
				},
				'editor.find.globalFindClipboard': {
					type: 'boolean',
					default: defaults.globalFindClipboard,
					description: nls.localize('find.globalFindClipboard', "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."),
					included: platform.isMacintosh
				},
				'editor.find.addExtraSpaceOnTop': {
					type: 'boolean',
					default: defaults.addExtraSpaceOnTop,
					description: nls.localize('find.addExtraSpaceOnTop', "Controls whether the Find Widget should add extra lines on top of the editor. When true, you can scroll beyond the first line when the Find Widget is visible.")
1365 1366 1367 1368 1369 1370 1371
				},
				'editor.find.loop': {
					type: 'boolean',
					default: defaults.loop,
					description: nls.localize('find.loop', "Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found.")
				},

1372 1373 1374 1375
			}
		);
	}

A
Alex Dima 已提交
1376
	public validate(_input: any): EditorFindOptions {
A
Alex Dima 已提交
1377
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1378 1379 1380 1381
			return this.defaultValue;
		}
		const input = _input as IEditorFindOptions;
		return {
R
rebornix 已提交
1382
			cursorMoveOnType: EditorBooleanOption.boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
A
Alex Dima 已提交
1383
			seedSearchStringFromSelection: EditorBooleanOption.boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection),
P
Peng Lyu 已提交
1384 1385 1386
			autoFindInSelection: typeof _input.autoFindInSelection === 'boolean'
				? (_input.autoFindInSelection ? 'always' : 'never')
				: EditorStringEnumOption.stringSet<'never' | 'always' | 'multiline'>(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ['never', 'always', 'multiline']),
A
Alex Dima 已提交
1387
			globalFindClipboard: EditorBooleanOption.boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
1388 1389
			addExtraSpaceOnTop: EditorBooleanOption.boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop),
			loop: EditorBooleanOption.boolean(input.loop, this.defaultValue.loop),
A
Alex Dima 已提交
1390
		};
A
Alex Dima 已提交
1391 1392 1393 1394 1395
	}
}

//#endregion

1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
//#region fontLigatures

/**
 * @internal
 */
export class EditorFontLigatures extends BaseEditorOption<EditorOption.fontLigatures, string> {

	public static OFF = '"liga" off, "calt" off';
	public static ON = '"liga" on, "calt" on';

	constructor() {
		super(
			EditorOption.fontLigatures, 'fontLigatures', EditorFontLigatures.OFF,
			{
				anyOf: [
					{
						type: 'boolean',
						description: nls.localize('fontLigatures', "Enables/Disables font ligatures."),
					},
					{
						type: 'string',
						description: nls.localize('fontFeatureSettings', "Explicit font-feature-settings.")
					}
				],
1420
				description: nls.localize('fontLigaturesGeneral', "Configures font ligatures or font features."),
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
				default: false
			}
		);
	}

	public validate(input: any): string {
		if (typeof input === 'undefined') {
			return this.defaultValue;
		}
		if (typeof input === 'string') {
			if (input === 'false') {
				return EditorFontLigatures.OFF;
			}
			if (input === 'true') {
				return EditorFontLigatures.ON;
			}
			return input;
		}
		if (Boolean(input)) {
			return EditorFontLigatures.ON;
		}
		return EditorFontLigatures.OFF;
	}
}

//#endregion

A
Alex Dima 已提交
1448
//#region fontInfo
A
Alex Dima 已提交
1449

1450 1451 1452 1453 1454 1455
class EditorFontInfo extends ComputedEditorOption<EditorOption.fontInfo, FontInfo> {

	constructor() {
		super(EditorOption.fontInfo);
	}

A
Alex Dima 已提交
1456 1457
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo {
		return env.fontInfo;
A
Alex Dima 已提交
1458 1459 1460 1461 1462
	}
}

//#endregion

A
Alex Dima 已提交
1463 1464
//#region fontSize

1465 1466 1467 1468 1469 1470 1471
class EditorFontSize extends SimpleEditorOption<EditorOption.fontSize, number> {

	constructor() {
		super(
			EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize,
			{
				type: 'number',
1472 1473
				minimum: 6,
				maximum: 100,
1474 1475 1476 1477 1478 1479
				default: EDITOR_FONT_DEFAULTS.fontSize,
				description: nls.localize('fontSize', "Controls the font size in pixels.")
			}
		);
	}

A
Alex Dima 已提交
1480
	public validate(input: any): number {
A
Alex Dima 已提交
1481
		let r = EditorFloatOption.float(input, this.defaultValue);
A
Alex Dima 已提交
1482 1483 1484
		if (r === 0) {
			return EDITOR_FONT_DEFAULTS.fontSize;
		}
1485
		return EditorFloatOption.clamp(r, 6, 100);
A
Alex Dima 已提交
1486 1487
	}
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
A
Alex Dima 已提交
1488 1489 1490
		// The final fontSize respects the editor zoom level.
		// So take the result from env.fontInfo
		return env.fontInfo.fontSize;
A
Alex Dima 已提交
1491 1492 1493 1494 1495
	}
}

//#endregion

1496 1497 1498
//#region fontWeight

class EditorFontWeight extends BaseEditorOption<EditorOption.fontWeight, string> {
1499
	private static SUGGESTION_VALUES = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
	private static MINIMUM_VALUE = 1;
	private static MAXIMUM_VALUE = 1000;

	constructor() {
		super(
			EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight,
			{
				anyOf: [
					{
						type: 'number',
						minimum: EditorFontWeight.MINIMUM_VALUE,
1511 1512
						maximum: EditorFontWeight.MAXIMUM_VALUE,
						errorMessage: nls.localize('fontWeightErrorMessage', "Only \"normal\" and \"bold\" keywords or numbers between 1 and 1000 are allowed.")
1513 1514
					},
					{
1515 1516
						type: 'string',
						pattern: '^(normal|bold|1000|[1-9][0-9]{0,2})$'
1517 1518
					},
					{
1519
						enum: EditorFontWeight.SUGGESTION_VALUES
1520 1521 1522
					}
				],
				default: EDITOR_FONT_DEFAULTS.fontWeight,
1523
				description: nls.localize('fontWeight', "Controls the font weight. Accepts \"normal\" and \"bold\" keywords or numbers between 1 and 1000.")
1524 1525 1526 1527 1528
			}
		);
	}

	public validate(input: any): string {
1529 1530
		if (input === 'normal' || input === 'bold') {
			return input;
1531
		}
A
Alex Dima 已提交
1532
		return String(EditorIntOption.clampedInt(input, EDITOR_FONT_DEFAULTS.fontWeight, EditorFontWeight.MINIMUM_VALUE, EditorFontWeight.MAXIMUM_VALUE));
1533 1534 1535 1536 1537
	}
}

//#endregion

A
Alex Dima 已提交
1538
//#region gotoLocation
A
Alex Dima 已提交
1539

1540 1541
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';

1542 1543 1544 1545
/**
 * Configuration options for go to location
 */
export interface IGotoLocationOptions {
1546

1547
	multiple?: GoToLocationValues;
1548

1549 1550 1551
	multipleDefinitions?: GoToLocationValues;
	multipleTypeDefinitions?: GoToLocationValues;
	multipleDeclarations?: GoToLocationValues;
R
rzj17 已提交
1552
	multipleImplementations?: GoToLocationValues;
1553
	multipleReferences?: GoToLocationValues;
1554 1555 1556 1557 1558 1559

	alternativeDefinitionCommand?: string;
	alternativeTypeDefinitionCommand?: string;
	alternativeDeclarationCommand?: string;
	alternativeImplementationCommand?: string;
	alternativeReferenceCommand?: string;
1560 1561
}

A
Alex Dima 已提交
1562
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
A
Alex Dima 已提交
1563

1564 1565 1566
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> {

	constructor() {
1567 1568 1569 1570 1571
		const defaults: GoToLocationOptions = {
			multiple: 'peek',
			multipleDefinitions: 'peek',
			multipleTypeDefinitions: 'peek',
			multipleDeclarations: 'peek',
R
rzj17 已提交
1572
			multipleImplementations: 'peek',
1573
			multipleReferences: 'peek',
1574 1575 1576 1577 1578
			alternativeDefinitionCommand: 'editor.action.goToReferences',
			alternativeTypeDefinitionCommand: 'editor.action.goToReferences',
			alternativeDeclarationCommand: 'editor.action.goToReferences',
			alternativeImplementationCommand: '',
			alternativeReferenceCommand: '',
1579
		};
M
Matt Bierner 已提交
1580
		const jsonSubset: IJSONSchema = {
1581 1582 1583 1584 1585 1586 1587 1588 1589
			type: 'string',
			enum: ['peek', 'gotoAndPeek', 'goto'],
			default: defaults.multiple,
			enumDescriptions: [
				nls.localize('editor.gotoLocation.multiple.peek', 'Show peek view of the results (default)'),
				nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a peek view'),
				nls.localize('editor.gotoLocation.multiple.goto', 'Go to the primary result and enable peek-less navigation to others')
			]
		};
1590 1591 1592 1593
		super(
			EditorOption.gotoLocation, 'gotoLocation', defaults,
			{
				'editor.gotoLocation.multiple': {
R
rzj17 已提交
1594
					deprecationMessage: nls.localize('editor.gotoLocation.multiple.deprecated', "This setting is deprecated, please use separate settings like 'editor.editor.gotoLocation.multipleDefinitions' or 'editor.editor.gotoLocation.multipleImplementations' instead."),
1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607
				},
				'editor.gotoLocation.multipleDefinitions': {
					description: nls.localize('editor.editor.gotoLocation.multipleDefinitions', "Controls the behavior the 'Go to Definition'-command when multiple target locations exist."),
					...jsonSubset,
				},
				'editor.gotoLocation.multipleTypeDefinitions': {
					description: nls.localize('editor.editor.gotoLocation.multipleTypeDefinitions', "Controls the behavior the 'Go to Type Definition'-command when multiple target locations exist."),
					...jsonSubset,
				},
				'editor.gotoLocation.multipleDeclarations': {
					description: nls.localize('editor.editor.gotoLocation.multipleDeclarations', "Controls the behavior the 'Go to Declaration'-command when multiple target locations exist."),
					...jsonSubset,
				},
R
rzj17 已提交
1608 1609
				'editor.gotoLocation.multipleImplementations': {
					description: nls.localize('editor.editor.gotoLocation.multipleImplemenattions', "Controls the behavior the 'Go to Implementations'-command when multiple target locations exist."),
1610 1611 1612 1613 1614
					...jsonSubset,
				},
				'editor.gotoLocation.multipleReferences': {
					description: nls.localize('editor.editor.gotoLocation.multipleReferences', "Controls the behavior the 'Go to References'-command when multiple target locations exist."),
					...jsonSubset,
1615
				},
1616
				'editor.gotoLocation.alternativeDefinitionCommand': {
1617
					type: 'string',
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639
					default: defaults.alternativeDefinitionCommand,
					description: nls.localize('alternativeDefinitionCommand', "Alternative command id that is being executed when the result of 'Go to Definition' is the current location.")
				},
				'editor.gotoLocation.alternativeTypeDefinitionCommand': {
					type: 'string',
					default: defaults.alternativeTypeDefinitionCommand,
					description: nls.localize('alternativeTypeDefinitionCommand', "Alternative command id that is being executed when the result of 'Go to Type Definition' is the current location.")
				},
				'editor.gotoLocation.alternativeDeclarationCommand': {
					type: 'string',
					default: defaults.alternativeDeclarationCommand,
					description: nls.localize('alternativeDeclarationCommand', "Alternative command id that is being executed when the result of 'Go to Declaration' is the current location.")
				},
				'editor.gotoLocation.alternativeImplementationCommand': {
					type: 'string',
					default: defaults.alternativeImplementationCommand,
					description: nls.localize('alternativeImplementationCommand', "Alternative command id that is being executed when the result of 'Go to Implementation' is the current location.")
				},
				'editor.gotoLocation.alternativeReferenceCommand': {
					type: 'string',
					default: defaults.alternativeReferenceCommand,
					description: nls.localize('alternativeReferenceCommand', "Alternative command id that is being executed when the result of 'Go to Reference' is the current location.")
1640 1641 1642 1643 1644
				},
			}
		);
	}

A
Alex Dima 已提交
1645
	public validate(_input: any): GoToLocationOptions {
A
Alex Dima 已提交
1646
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1647 1648
			return this.defaultValue;
		}
A
Alex Dima 已提交
1649
		const input = _input as IGotoLocationOptions;
A
Alex Dima 已提交
1650
		return {
1651 1652 1653 1654
			multiple: EditorStringEnumOption.stringSet<GoToLocationValues>(input.multiple, this.defaultValue.multiple!, ['peek', 'gotoAndPeek', 'goto']),
			multipleDefinitions: input.multipleDefinitions ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleTypeDefinitions: input.multipleTypeDefinitions ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleTypeDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleDeclarations: input.multipleDeclarations ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleDeclarations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
R
rzj17 已提交
1655
			multipleImplementations: input.multipleImplementations ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleImplementations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
1656
			multipleReferences: input.multipleReferences ?? EditorStringEnumOption.stringSet<GoToLocationValues>(input.multipleReferences, 'peek', ['peek', 'gotoAndPeek', 'goto']),
1657 1658 1659 1660 1661
			alternativeDefinitionCommand: EditorStringOption.string(input.alternativeDefinitionCommand, this.defaultValue.alternativeDefinitionCommand),
			alternativeTypeDefinitionCommand: EditorStringOption.string(input.alternativeTypeDefinitionCommand, this.defaultValue.alternativeTypeDefinitionCommand),
			alternativeDeclarationCommand: EditorStringOption.string(input.alternativeDeclarationCommand, this.defaultValue.alternativeDeclarationCommand),
			alternativeImplementationCommand: EditorStringOption.string(input.alternativeImplementationCommand, this.defaultValue.alternativeImplementationCommand),
			alternativeReferenceCommand: EditorStringOption.string(input.alternativeReferenceCommand, this.defaultValue.alternativeReferenceCommand),
A
Alex Dima 已提交
1662 1663 1664 1665 1666 1667
		};
	}
}

//#endregion

A
Alex Dima 已提交
1668
//#region hover
A
Alex Dima 已提交
1669

1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690
/**
 * Configuration options for editor hover
 */
export interface IEditorHoverOptions {
	/**
	 * Enable the hover.
	 * Defaults to true.
	 */
	enabled?: boolean;
	/**
	 * Delay for showing the hover.
	 * Defaults to 300.
	 */
	delay?: number;
	/**
	 * Is the hover sticky such that it can be clicked and its contents selected?
	 * Defaults to true.
	 */
	sticky?: boolean;
}

A
Alex Dima 已提交
1691
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
A
Alex Dima 已提交
1692

1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722
class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOptions> {

	constructor() {
		const defaults: EditorHoverOptions = {
			enabled: true,
			delay: 300,
			sticky: true
		};
		super(
			EditorOption.hover, 'hover', defaults,
			{
				'editor.hover.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('hover.enabled', "Controls whether the hover is shown.")
				},
				'editor.hover.delay': {
					type: 'number',
					default: defaults.delay,
					description: nls.localize('hover.delay', "Controls the delay in milliseconds after which the hover is shown.")
				},
				'editor.hover.sticky': {
					type: 'boolean',
					default: defaults.sticky,
					description: nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.")
				},
			}
		);
	}

A
Alex Dima 已提交
1723
	public validate(_input: any): EditorHoverOptions {
A
Alex Dima 已提交
1724
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1725 1726
			return this.defaultValue;
		}
A
Alex Dima 已提交
1727
		const input = _input as IEditorHoverOptions;
A
Alex Dima 已提交
1728
		return {
A
Alex Dima 已提交
1729
			enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
A
Alex Dima 已提交
1730
			delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
A
Alex Dima 已提交
1731
			sticky: EditorBooleanOption.boolean(input.sticky, this.defaultValue.sticky)
A
Alex Dima 已提交
1732 1733 1734 1735 1736 1737
		};
	}
}

//#endregion

A
Alex Dima 已提交
1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761
//#region layoutInfo

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

A
Alex Dima 已提交
1762 1763
export const enum RenderMinimap {
	None = 0,
1764 1765
	Text = 1,
	Blocks = 2,
A
Alex Dima 已提交
1766 1767
}

A
Alex Dima 已提交
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785
/**
 * The internal layout details of the editor.
 */
export interface EditorLayoutInfo {

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

	/**
	 * Left position for the glyph margin.
	 */
	readonly glyphMarginLeft: number;
1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817
	/**
	 * The width of the glyph margin.
	 */
	readonly glyphMarginWidth: number;

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

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

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

1818
	/**
A
Alex Dima 已提交
1819
	 * Layout information for the minimap
1820
	 */
A
Alex Dima 已提交
1821
	readonly minimap: EditorMinimapLayoutInfo;
1822 1823 1824 1825 1826 1827

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

1828 1829 1830 1831
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;

1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846
	/**
	 * 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;
}

A
Alex Dima 已提交
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
/**
 * The internal layout details of the editor.
 */
export interface EditorMinimapLayoutInfo {
	readonly renderMinimap: RenderMinimap;
	readonly minimapLeft: number;
	readonly minimapWidth: number;
	readonly minimapHeightIsEditorHeight: boolean;
	readonly minimapIsSampling: boolean;
	readonly minimapScale: number;
	readonly minimapLineHeight: number;
	readonly minimapCanvasInnerWidth: number;
	readonly minimapCanvasInnerHeight: number;
	readonly minimapCanvasOuterWidth: number;
	readonly minimapCanvasOuterHeight: number;
}

1864
/**
A
Alex Dima 已提交
1865
 * @internal
1866
 */
A
Alex Dima 已提交
1867
export interface EditorLayoutInfoComputerEnv {
1868
	readonly memory: ComputeOptionsMemory | null;
1869 1870
	readonly outerWidth: number;
	readonly outerHeight: number;
1871
	readonly isDominatedByLongLines: boolean;
1872 1873 1874 1875 1876 1877
	readonly lineHeight: number;
	readonly viewLineCount: number;
	readonly lineNumbersDigitCount: number;
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
	readonly pixelRatio: number;
1878
}
1879

1880 1881 1882 1883 1884 1885
/**
 * @internal
 */
export interface IEditorLayoutComputerInput {
	readonly outerWidth: number;
	readonly outerHeight: number;
1886
	readonly isDominatedByLongLines: boolean;
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905
	readonly lineHeight: number;
	readonly lineNumbersDigitCount: number;
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
	readonly pixelRatio: number;
	readonly glyphMargin: boolean;
	readonly lineDecorationsWidth: string | number;
	readonly folding: boolean;
	readonly minimap: Readonly<Required<IEditorMinimapOptions>>;
	readonly scrollbar: InternalEditorScrollbarOptions;
	readonly lineNumbers: InternalEditorRenderLineNumbersOptions;
	readonly lineNumbersMinChars: number;
	readonly scrollBeyondLastLine: boolean;
	readonly wordWrap: 'wordWrapColumn' | 'on' | 'off' | 'bounded';
	readonly wordWrapColumn: number;
	readonly wordWrapMinified: boolean;
	readonly accessibilitySupport: AccessibilitySupport;
}

A
Alex Dima 已提交
1906 1907 1908 1909
/**
 * @internal
 */
export interface IMinimapLayoutInput {
A
Alex Dima 已提交
1910
	readonly outerWidth: number;
A
Alex Dima 已提交
1911 1912 1913 1914 1915 1916 1917 1918 1919 1920
	readonly outerHeight: number;
	readonly lineHeight: number;
	readonly typicalHalfwidthCharacterWidth: number;
	readonly pixelRatio: number;
	readonly scrollBeyondLastLine: boolean;
	readonly minimap: Readonly<Required<IEditorMinimapOptions>>;
	readonly verticalScrollbarWidth: number;
	readonly viewLineCount: number;
	readonly remainingWidth: number;
	readonly isViewportWrapping: boolean;
1921
}
1922 1923 1924 1925

/**
 * @internal
 */
1926
export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.layoutInfo, EditorLayoutInfo> {
1927

1928 1929 1930
	constructor() {
		super(
			EditorOption.layoutInfo,
1931 1932 1933
			[
				EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding,
				EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers,
1934
				EditorOption.lineNumbersMinChars, EditorOption.scrollBeyondLastLine,
1935 1936 1937
				EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapMinified,
				EditorOption.accessibilitySupport
			]
1938
		);
1939
	}
1940

A
Alex Dima 已提交
1941
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorLayoutInfo): EditorLayoutInfo {
A
Alex Dima 已提交
1942
		return EditorLayoutInfoComputer.computeLayout(options, {
1943
			memory: env.memory,
A
Alex Dima 已提交
1944 1945
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
1946
			isDominatedByLongLines: env.isDominatedByLongLines,
A
Alex Dima 已提交
1947
			lineHeight: env.fontInfo.lineHeight,
1948
			viewLineCount: env.viewLineCount,
A
Alex Dima 已提交
1949 1950 1951 1952 1953
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
			pixelRatio: env.pixelRatio
		});
1954 1955
	}

A
Alex Dima 已提交
1956
	public static computeContainedMinimapLineCount(input: {
1957
		viewLineCount: number;
A
Alex Dima 已提交
1958 1959 1960 1961
		scrollBeyondLastLine: boolean;
		height: number;
		lineHeight: number;
		pixelRatio: number;
1962 1963 1964
	}): { typicalViewportLineCount: number; extraLinesBeyondLastLine: number; desiredRatio: number; minimapLineCount: number; } {
		const typicalViewportLineCount = input.height / input.lineHeight;
		const extraLinesBeyondLastLine = input.scrollBeyondLastLine ? (typicalViewportLineCount - 1) : 0;
1965 1966
		const desiredRatio = (input.viewLineCount + extraLinesBeyondLastLine) / (input.pixelRatio * input.height);
		const minimapLineCount = Math.floor(input.viewLineCount / desiredRatio);
1967
		return { typicalViewportLineCount, extraLinesBeyondLastLine, desiredRatio, minimapLineCount };
A
Alex Dima 已提交
1968 1969
	}

A
Alex Dima 已提交
1970 1971
	private static _computeMinimapLayout(input: IMinimapLayoutInput, memory: ComputeOptionsMemory): EditorMinimapLayoutInfo {
		const outerWidth = input.outerWidth;
A
Alex Dima 已提交
1972 1973 1974
		const outerHeight = input.outerHeight;
		const pixelRatio = input.pixelRatio;

A
Alex Dima 已提交
1975 1976
		if (!input.minimap.enabled) {
			return {
A
Alex Dima 已提交
1977 1978
				renderMinimap: RenderMinimap.None,
				minimapLeft: 0,
A
Alex Dima 已提交
1979 1980 1981 1982 1983 1984
				minimapWidth: 0,
				minimapHeightIsEditorHeight: false,
				minimapIsSampling: false,
				minimapScale: 1,
				minimapLineHeight: 1,
				minimapCanvasInnerWidth: 0,
A
Alex Dima 已提交
1985
				minimapCanvasInnerHeight: Math.floor(pixelRatio * outerHeight),
A
Alex Dima 已提交
1986
				minimapCanvasOuterWidth: 0,
A
Alex Dima 已提交
1987
				minimapCanvasOuterHeight: outerHeight,
A
Alex Dima 已提交
1988 1989 1990
			};
		}

A
Alex Dima 已提交
1991 1992 1993 1994
		// Can use memory if only the `viewLineCount` and `remainingWidth` have changed
		const stableMinimapLayoutInput = memory.stableMinimapLayoutInput;
		const couldUseMemory = (
			stableMinimapLayoutInput
A
Alex Dima 已提交
1995
			// && input.outerWidth === lastMinimapLayoutInput.outerWidth !!! INTENTIONAL OMITTED
A
Alex Dima 已提交
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
			&& input.outerHeight === stableMinimapLayoutInput.outerHeight
			&& input.lineHeight === stableMinimapLayoutInput.lineHeight
			&& input.typicalHalfwidthCharacterWidth === stableMinimapLayoutInput.typicalHalfwidthCharacterWidth
			&& input.pixelRatio === stableMinimapLayoutInput.pixelRatio
			&& input.scrollBeyondLastLine === stableMinimapLayoutInput.scrollBeyondLastLine
			&& input.minimap.enabled === stableMinimapLayoutInput.minimap.enabled
			&& input.minimap.side === stableMinimapLayoutInput.minimap.side
			&& input.minimap.size === stableMinimapLayoutInput.minimap.size
			&& input.minimap.showSlider === stableMinimapLayoutInput.minimap.showSlider
			&& input.minimap.renderCharacters === stableMinimapLayoutInput.minimap.renderCharacters
			&& input.minimap.maxColumn === stableMinimapLayoutInput.minimap.maxColumn
			&& input.minimap.scale === stableMinimapLayoutInput.minimap.scale
			&& input.verticalScrollbarWidth === stableMinimapLayoutInput.verticalScrollbarWidth
			// && input.viewLineCount === lastMinimapLayoutInput.viewLineCount !!! INTENTIONAL OMITTED
			// && input.remainingWidth === lastMinimapLayoutInput.remainingWidth !!! INTENTIONAL OMITTED
			&& input.isViewportWrapping === stableMinimapLayoutInput.isViewportWrapping
		);

2014 2015 2016 2017 2018 2019 2020
		const lineHeight = input.lineHeight;
		const typicalHalfwidthCharacterWidth = input.typicalHalfwidthCharacterWidth;
		const scrollBeyondLastLine = input.scrollBeyondLastLine;
		const minimapRenderCharacters = input.minimap.renderCharacters;
		let minimapScale = (pixelRatio >= 2 ? Math.round(input.minimap.scale * 2) : input.minimap.scale);
		const minimapMaxColumn = input.minimap.maxColumn;
		const minimapSize = input.minimap.size;
A
Alex Dima 已提交
2021
		const minimapSide = input.minimap.side;
A
Alex Dima 已提交
2022 2023 2024 2025
		const verticalScrollbarWidth = input.verticalScrollbarWidth;
		const viewLineCount = input.viewLineCount;
		const remainingWidth = input.remainingWidth;
		const isViewportWrapping = input.isViewportWrapping;
2026

2027
		const baseCharHeight = minimapRenderCharacters ? 2 : 3;
2028 2029
		let minimapCanvasInnerHeight = Math.floor(pixelRatio * outerHeight);
		const minimapCanvasOuterHeight = minimapCanvasInnerHeight / pixelRatio;
A
Alex Dima 已提交
2030
		let minimapHeightIsEditorHeight = false;
2031
		let minimapIsSampling = false;
2032
		let minimapLineHeight = baseCharHeight * minimapScale;
A
Alex Dima 已提交
2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054
		let minimapCharWidth = minimapScale / pixelRatio;
		let minimapWidthMultiplier: number = 1;

		if (minimapSize === 'fill' || minimapSize === 'fit') {
			const { typicalViewportLineCount, extraLinesBeyondLastLine, desiredRatio, minimapLineCount } = EditorLayoutInfoComputer.computeContainedMinimapLineCount({
				viewLineCount: viewLineCount,
				scrollBeyondLastLine: scrollBeyondLastLine,
				height: outerHeight,
				lineHeight: lineHeight,
				pixelRatio: pixelRatio
			});
			// ratio is intentionally not part of the layout to avoid the layout changing all the time
			// when doing sampling
			const ratio = viewLineCount / minimapLineCount;

			if (ratio > 1) {
				minimapHeightIsEditorHeight = true;
				minimapIsSampling = true;
				minimapScale = 1;
				minimapLineHeight = 1;
				minimapCharWidth = minimapScale / pixelRatio;
			} else {
A
Alex Dima 已提交
2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077
				let fitBecomesFill = false;
				let maxMinimapScale = minimapScale + 1;

				if (minimapSize === 'fit') {
					const effectiveMinimapHeight = Math.ceil((viewLineCount + extraLinesBeyondLastLine) * minimapLineHeight);
					if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
						// There is a loop when using `fit` and viewport wrapping:
						// - view line count impacts minimap layout
						// - minimap layout impacts viewport width
						// - viewport width impacts view line count
						// To break the loop, once we go to a smaller minimap scale, we try to stick with it.
						fitBecomesFill = true;
						maxMinimapScale = memory.stableFitMaxMinimapScale;
					} else {
						fitBecomesFill = (effectiveMinimapHeight > minimapCanvasInnerHeight);
						if (isViewportWrapping && fitBecomesFill) {
							// remember for next time
							memory.stableMinimapLayoutInput = input;
							memory.stableFitRemainingWidth = remainingWidth;
						} else {
							memory.stableMinimapLayoutInput = null;
							memory.stableFitRemainingWidth = 0;
						}
A
Alex Dima 已提交
2078
					}
A
Alex Dima 已提交
2079 2080 2081
				}

				if (minimapSize === 'fill' || fitBecomesFill) {
A
Alex Dima 已提交
2082
					minimapHeightIsEditorHeight = true;
A
Alex Dima 已提交
2083
					const configuredMinimapScale = minimapScale;
A
Alex Dima 已提交
2084
					minimapLineHeight = Math.min(lineHeight * pixelRatio, Math.max(1, Math.floor(1 / desiredRatio)));
A
Alex Dima 已提交
2085 2086 2087
					minimapScale = Math.min(maxMinimapScale, Math.max(1, Math.floor(minimapLineHeight / baseCharHeight)));
					if (minimapScale > configuredMinimapScale) {
						minimapWidthMultiplier = Math.min(2, minimapScale / configuredMinimapScale);
2088
					}
A
Alex Dima 已提交
2089 2090
					minimapCharWidth = minimapScale / pixelRatio / minimapWidthMultiplier;
					minimapCanvasInnerHeight = Math.ceil((Math.max(typicalViewportLineCount, viewLineCount + extraLinesBeyondLastLine)) * minimapLineHeight);
A
Alex Dima 已提交
2091 2092 2093
					if (isViewportWrapping && fitBecomesFill) {
						memory.stableFitMaxMinimapScale = minimapScale;
					}
2094 2095
				}
			}
A
Alex Dima 已提交
2096
		}
2097

A
Alex Dima 已提交
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110
		// Given:
		// (leaving 2px for the cursor to have space after the last character)
		// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
		// minimapWidth = viewportColumn * minimapCharWidth
		// contentWidth = remainingWidth - minimapWidth
		// What are good values for contentWidth and minimapWidth ?

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

A
Alex Dima 已提交
2111 2112
		const minimapMaxWidth = Math.floor(minimapMaxColumn * minimapCharWidth);
		const minimapWidth = Math.min(minimapMaxWidth, Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth))) + MINIMAP_GUTTER_WIDTH);
A
Alex Dima 已提交
2113

A
Alex Dima 已提交
2114 2115
		let minimapCanvasInnerWidth = Math.floor(pixelRatio * minimapWidth);
		const minimapCanvasOuterWidth = minimapCanvasInnerWidth / pixelRatio;
A
Alex Dima 已提交
2116 2117
		minimapCanvasInnerWidth = Math.floor(minimapCanvasInnerWidth * minimapWidthMultiplier);

A
Alex Dima 已提交
2118 2119 2120
		const renderMinimap = (minimapRenderCharacters ? RenderMinimap.Text : RenderMinimap.Blocks);
		const minimapLeft = (minimapSide === 'left' ? 0 : (outerWidth - minimapWidth - verticalScrollbarWidth));

A
Alex Dima 已提交
2121
		return {
A
Alex Dima 已提交
2122 2123
			renderMinimap,
			minimapLeft,
A
Alex Dima 已提交
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135
			minimapWidth,
			minimapHeightIsEditorHeight,
			minimapIsSampling,
			minimapScale,
			minimapLineHeight,
			minimapCanvasInnerWidth,
			minimapCanvasInnerHeight,
			minimapCanvasOuterWidth,
			minimapCanvasOuterHeight,
		};
	}

A
Alex Dima 已提交
2136 2137 2138 2139 2140 2141 2142 2143
	public static computeLayout(options: IComputedEditorOptions, env: EditorLayoutInfoComputerEnv): EditorLayoutInfo {
		const outerWidth = env.outerWidth | 0;
		const outerHeight = env.outerHeight | 0;
		const lineHeight = env.lineHeight | 0;
		const lineNumbersDigitCount = env.lineNumbersDigitCount | 0;
		const typicalHalfwidthCharacterWidth = env.typicalHalfwidthCharacterWidth;
		const maxDigitWidth = env.maxDigitWidth;
		const pixelRatio = env.pixelRatio;
A
Alex Dima 已提交
2144 2145 2146 2147 2148 2149 2150
		const viewLineCount = env.viewLineCount;

		const wordWrap = options.get(EditorOption.wordWrap);
		const wordWrapColumn = options.get(EditorOption.wordWrapColumn);
		const wordWrapMinified = options.get(EditorOption.wordWrapMinified);
		const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
		const isDominatedByLongLines = env.isDominatedByLongLines;
A
Alex Dima 已提交
2151 2152 2153

		const showGlyphMargin = options.get(EditorOption.glyphMargin);
		const showLineNumbers = (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off);
A
Alex Dima 已提交
2154
		const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars);
2155
		const scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine);
A
renames  
Alex Dima 已提交
2156
		const minimap = options.get(EditorOption.minimap);
A
Alex Dima 已提交
2157

A
renames  
Alex Dima 已提交
2158
		const scrollbar = options.get(EditorOption.scrollbar);
A
Alex Dima 已提交
2159
		const verticalScrollbarWidth = scrollbar.verticalScrollbarSize;
A
Alex Dima 已提交
2160
		const verticalScrollbarHasArrows = scrollbar.verticalHasArrows;
A
Alex Dima 已提交
2161 2162
		const scrollbarArrowSize = scrollbar.arrowSize;
		const horizontalScrollbarHeight = scrollbar.horizontalScrollbarSize;
A
Alex Dima 已提交
2163 2164 2165

		const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth);
		const folding = options.get(EditorOption.folding);
A
Alex Dima 已提交
2166 2167 2168 2169

		let lineDecorationsWidth: number;
		if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) {
			const multiple = parseFloat(rawLineDecorationsWidth.substr(0, rawLineDecorationsWidth.length - 2));
A
Alex Dima 已提交
2170
			lineDecorationsWidth = EditorIntOption.clampedInt(multiple * typicalHalfwidthCharacterWidth, 0, 0, 1000);
A
Alex Dima 已提交
2171
		} else {
A
Alex Dima 已提交
2172
			lineDecorationsWidth = EditorIntOption.clampedInt(rawLineDecorationsWidth, 0, 0, 1000);
A
Alex Dima 已提交
2173 2174 2175
		}
		if (folding) {
			lineDecorationsWidth += 16;
2176 2177
		}

A
Alex Dima 已提交
2178 2179 2180 2181 2182
		let lineNumbersWidth = 0;
		if (showLineNumbers) {
			const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars);
			lineNumbersWidth = Math.round(digitCount * maxDigitWidth);
		}
2183

A
Alex Dima 已提交
2184 2185 2186 2187
		let glyphMarginWidth = 0;
		if (showGlyphMargin) {
			glyphMarginWidth = lineHeight;
		}
2188

A
Alex Dima 已提交
2189 2190 2191 2192 2193 2194 2195
		let glyphMarginLeft = 0;
		let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
		let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
		let contentLeft = decorationsLeft + lineDecorationsWidth;

		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;

A
Alex Dima 已提交
2196 2197 2198
		let isWordWrapMinified = false;
		let isViewportWrapping = false;
		let wrappingColumn = -1;
2199

A
Alex Dima 已提交
2200
		if (accessibilitySupport !== AccessibilitySupport.Enabled) {
C
ChaseKnowlden 已提交
2201
			// See https://github.com/microsoft/vscode/issues/27766
A
Alex Dima 已提交
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212
			// 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.
			if (wordWrapMinified && isDominatedByLongLines) {
				// Force viewport width wrapping if model is dominated by long lines
				isWordWrapMinified = true;
				isViewportWrapping = true;
			} else if (wordWrap === 'on' || wordWrap === 'bounded') {
				isViewportWrapping = true;
			} else if (wordWrap === 'wordWrapColumn') {
				wrappingColumn = wordWrapColumn;
A
Alex Dima 已提交
2213
			}
A
Alex Dima 已提交
2214
		}
2215

A
Alex Dima 已提交
2216 2217
		const minimapLayout = EditorLayoutInfoComputer._computeMinimapLayout({
			outerWidth: outerWidth,
A
Alex Dima 已提交
2218 2219 2220 2221 2222 2223 2224 2225 2226 2227
			outerHeight: outerHeight,
			lineHeight: lineHeight,
			typicalHalfwidthCharacterWidth: typicalHalfwidthCharacterWidth,
			pixelRatio: pixelRatio,
			scrollBeyondLastLine: scrollBeyondLastLine,
			minimap: minimap,
			verticalScrollbarWidth: verticalScrollbarWidth,
			viewLineCount: viewLineCount,
			remainingWidth: remainingWidth,
			isViewportWrapping: isViewportWrapping,
A
Alex Dima 已提交
2228
		}, env.memory || new ComputeOptionsMemory());
A
Alex Dima 已提交
2229

A
Alex Dima 已提交
2230 2231 2232 2233 2234 2235
		if (minimapLayout.renderMinimap !== RenderMinimap.None && minimapLayout.minimapLeft === 0) {
			// the minimap is rendered to the left, so move everything to the right
			glyphMarginLeft += minimapLayout.minimapWidth;
			lineNumbersLeft += minimapLayout.minimapWidth;
			decorationsLeft += minimapLayout.minimapWidth;
			contentLeft += minimapLayout.minimapWidth;
2236
		}
A
Alex Dima 已提交
2237
		const contentWidth = remainingWidth - minimapLayout.minimapWidth;
2238

A
Alex Dima 已提交
2239 2240 2241 2242 2243
		// (leaving 2px for the cursor to have space after the last character)
		const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth));

		const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);

2244 2245 2246 2247 2248
		if (isViewportWrapping) {
			// compute the actual wrappingColumn
			wrappingColumn = Math.max(1, viewportColumn);
			if (wordWrap === 'bounded') {
				wrappingColumn = Math.min(wrappingColumn, wordWrapColumn);
2249 2250 2251
			}
		}

A
Alex Dima 已提交
2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267
		return {
			width: outerWidth,
			height: outerHeight,

			glyphMarginLeft: glyphMarginLeft,
			glyphMarginWidth: glyphMarginWidth,

			lineNumbersLeft: lineNumbersLeft,
			lineNumbersWidth: lineNumbersWidth,

			decorationsLeft: decorationsLeft,
			decorationsWidth: lineDecorationsWidth,

			contentLeft: contentLeft,
			contentWidth: contentWidth,

A
Alex Dima 已提交
2268
			minimap: minimapLayout,
A
Alex Dima 已提交
2269 2270 2271

			viewportColumn: viewportColumn,

2272 2273 2274
			isWordWrapMinified: isWordWrapMinified,
			isViewportWrapping: isViewportWrapping,
			wrappingColumn: wrappingColumn,
2275

A
Alex Dima 已提交
2276 2277 2278 2279 2280 2281 2282 2283 2284 2285
			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

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

A
Alex Dima 已提交
2289 2290
//#endregion

A
Alex Dima 已提交
2291 2292
//#region lightbulb

2293 2294 2295 2296 2297 2298 2299 2300 2301
/**
 * Configuration options for editor lightbulb
 */
export interface IEditorLightbulbOptions {
	/**
	 * Enable the lightbulb code action.
	 * Defaults to true.
	 */
	enabled?: boolean;
2302 2303
}

A
Alex Dima 已提交
2304
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
A
Alex Dima 已提交
2305

2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319
class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, EditorLightbulbOptions> {

	constructor() {
		const defaults: EditorLightbulbOptions = { enabled: true };
		super(
			EditorOption.lightbulb, 'lightbulb', defaults,
			{
				'editor.lightbulb.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('codeActions', "Enables the code action lightbulb in the editor.")
				},
			}
		);
2320
	}
2321

A
Alex Dima 已提交
2322
	public validate(_input: any): EditorLightbulbOptions {
A
Alex Dima 已提交
2323
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2324 2325 2326 2327
			return this.defaultValue;
		}
		const input = _input as IEditorLightbulbOptions;
		return {
A
Alex Dima 已提交
2328
			enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled)
A
Alex Dima 已提交
2329
		};
2330 2331 2332
	}
}

A
Alex Dima 已提交
2333 2334 2335 2336
//#endregion

//#region lineHeight

2337 2338 2339 2340 2341 2342 2343 2344
class EditorLineHeight extends EditorIntOption<EditorOption.lineHeight> {

	constructor() {
		super(
			EditorOption.lineHeight, 'lineHeight',
			EDITOR_FONT_DEFAULTS.lineHeight, 0, 150,
			{ description: nls.localize('lineHeight', "Controls the line height. Use 0 to compute the line height from the font size.") }
		);
2345
	}
2346

A
Alex Dima 已提交
2347 2348 2349 2350 2351
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
		// The lineHeight is computed from the fontSize if it is 0.
		// Moreover, the final lineHeight respects the editor zoom level.
		// So take the result from env.fontInfo
		return env.fontInfo.lineHeight;
2352 2353 2354
	}
}

A
Alex Dima 已提交
2355 2356 2357 2358
//#endregion

//#region minimap

2359
/**
2360
 * Configuration options for editor minimap
2361
 */
2362
export interface IEditorMinimapOptions {
2363
	/**
2364 2365
	 * Enable the rendering of the minimap.
	 * Defaults to true.
2366
	 */
2367 2368 2369 2370 2371 2372
	enabled?: boolean;
	/**
	 * Control the side of the minimap in editor.
	 * Defaults to 'right'.
	 */
	side?: 'right' | 'left';
A
Alex Dima 已提交
2373 2374 2375 2376
	/**
	 * Control the minimap rendering mode.
	 * Defaults to 'actual'.
	 */
2377
	size?: 'proportional' | 'fill' | 'fit';
2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392
	/**
	 * Control the rendering of the minimap slider.
	 * Defaults to 'mouseover'.
	 */
	showSlider?: 'always' | 'mouseover';
	/**
	 * 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;
2393 2394 2395 2396
	/**
	 * Relative size of the font in the minimap. Defaults to 1.
	 */
	scale?: number;
2397
}
A
Alex Dima 已提交
2398

A
Alex Dima 已提交
2399
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
A
Alex Dima 已提交
2400

2401
class EditorMinimap extends BaseEditorOption<EditorOption.minimap, EditorMinimapOptions> {
A
Alex Dima 已提交
2402

2403 2404 2405
	constructor() {
		const defaults: EditorMinimapOptions = {
			enabled: true,
2406
			size: 'proportional',
2407 2408 2409 2410
			side: 'right',
			showSlider: 'mouseover',
			renderCharacters: true,
			maxColumn: 120,
2411
			scale: 1,
2412 2413 2414 2415 2416 2417 2418 2419 2420
		};
		super(
			EditorOption.minimap, 'minimap', defaults,
			{
				'editor.minimap.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('minimap.enabled', "Controls whether the minimap is shown.")
				},
2421
				'editor.minimap.size': {
A
Alex Dima 已提交
2422
					type: 'string',
2423
					enum: ['proportional', 'fill', 'fit'],
A
Alex Dima 已提交
2424
					enumDescriptions: [
2425 2426 2427
						nls.localize('minimap.size.proportional', "The minimap has the same size as the editor contents (and might scroll)."),
						nls.localize('minimap.size.fill', "The minimap will stretch or shrink as necessary to fill the height of the editor (no scrolling)."),
						nls.localize('minimap.size.fit', "The minimap will shrink as necessary to never be larger than the editor (no scrolling)."),
A
Alex Dima 已提交
2428
					],
2429 2430
					default: defaults.size,
					description: nls.localize('minimap.size', "Controls the size of the minimap.")
A
Alex Dima 已提交
2431
				},
2432 2433 2434 2435 2436 2437 2438 2439 2440 2441
				'editor.minimap.side': {
					type: 'string',
					enum: ['left', 'right'],
					default: defaults.side,
					description: nls.localize('minimap.side', "Controls the side where to render the minimap.")
				},
				'editor.minimap.showSlider': {
					type: 'string',
					enum: ['always', 'mouseover'],
					default: defaults.showSlider,
2442
					description: nls.localize('minimap.showSlider', "Controls when the minimap slider is shown.")
2443
				},
2444 2445 2446 2447 2448
				'editor.minimap.scale': {
					type: 'number',
					default: defaults.scale,
					minimum: 1,
					maximum: 3,
2449 2450
					enum: [1, 2, 3],
					description: nls.localize('minimap.scale', "Scale of content drawn in the minimap: 1, 2 or 3.")
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460
				},
				'editor.minimap.renderCharacters': {
					type: 'boolean',
					default: defaults.renderCharacters,
					description: nls.localize('minimap.renderCharacters', "Render the actual characters on a line as opposed to color blocks.")
				},
				'editor.minimap.maxColumn': {
					type: 'number',
					default: defaults.maxColumn,
					description: nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.")
A
Alex Dima 已提交
2461
				}
2462
			}
2463 2464
		);
	}
J
Jackson Kearl 已提交
2465

A
Alex Dima 已提交
2466
	public validate(_input: any): EditorMinimapOptions {
A
Alex Dima 已提交
2467
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2468 2469 2470
			return this.defaultValue;
		}
		const input = _input as IEditorMinimapOptions;
A
Alex Dima 已提交
2471
		return {
A
Alex Dima 已提交
2472
			enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
2473
			size: EditorStringEnumOption.stringSet<'proportional' | 'fill' | 'fit'>(input.size, this.defaultValue.size, ['proportional', 'fill', 'fit']),
A
Alex Dima 已提交
2474 2475
			side: EditorStringEnumOption.stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']),
			showSlider: EditorStringEnumOption.stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
A
Alex Dima 已提交
2476
			renderCharacters: EditorBooleanOption.boolean(input.renderCharacters, this.defaultValue.renderCharacters),
2477
			scale: EditorIntOption.clampedInt(input.scale, 1, 1, 3),
A
Alex Dima 已提交
2478
			maxColumn: EditorIntOption.clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000),
A
Alex Dima 已提交
2479 2480
		};
	}
A
Alex Dima 已提交
2481
}
A
Alex Dima 已提交
2482

A
Alex Dima 已提交
2483
//#endregion
A
Alex Dima 已提交
2484

A
Alex Dima 已提交
2485
//#region multiCursorModifier
A
Alex Dima 已提交
2486

A
Alex Dima 已提交
2487 2488 2489 2490 2491
function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): 'altKey' | 'metaKey' | 'ctrlKey' {
	if (multiCursorModifier === 'ctrlCmd') {
		return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
	}
	return 'altKey';
A
Alex Dima 已提交
2492
}
A
Alex Dima 已提交
2493

A
Alex Dima 已提交
2494
//#endregion
A
Alex Dima 已提交
2495

B
Bailey 已提交
2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525
//#region padding

/**
 * Configuration options for editor padding
 */
export interface IEditorPaddingOptions {
	/**
	 * Spacing between top edge of editor and first line.
	 */
	top?: number;
	/**
	 * Spacing between bottom edge of editor and last line.
	 */
	bottom?: number;
}

export interface InternalEditorPaddingOptions {
	readonly top: number;
	readonly bottom: number;
}

class EditorPadding extends BaseEditorOption<EditorOption.padding, InternalEditorPaddingOptions> {

	constructor() {
		super(
			EditorOption.padding, 'padding', { top: 0, bottom: 0 },
			{
				'editor.padding.top': {
					type: 'number',
					default: 0,
B
Bailey 已提交
2526 2527
					minimum: 0,
					maximum: 1000,
B
Bailey 已提交
2528 2529 2530 2531 2532
					description: nls.localize('padding.top', "Controls the amount of space between the top edge of the editor and the first line.")
				},
				'editor.padding.bottom': {
					type: 'number',
					default: 0,
B
Bailey 已提交
2533 2534
					minimum: 0,
					maximum: 1000,
B
Bailey 已提交
2535 2536 2537 2538 2539 2540 2541
					description: nls.localize('padding.bottom', "Controls the amount of space between the bottom edge of the editor and the last line.")
				}
			}
		);
	}

	public validate(_input: any): InternalEditorPaddingOptions {
A
Alex Dima 已提交
2542
		if (!_input || typeof _input !== 'object') {
B
Bailey 已提交
2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554
			return this.defaultValue;
		}
		const input = _input as IEditorPaddingOptions;

		return {
			top: EditorIntOption.clampedInt(input.top, 0, 0, 1000),
			bottom: EditorIntOption.clampedInt(input.bottom, 0, 0, 1000)
		};
	}
}
//#endregion

A
Alex Dima 已提交
2555
//#region parameterHints
A
Alex Dima 已提交
2556

2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572
/**
 * 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;
}

A
Alex Dima 已提交
2573 2574
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;

2575 2576 2577 2578 2579 2580
class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, InternalParameterHintOptions> {

	constructor() {
		const defaults: InternalParameterHintOptions = {
			enabled: true,
			cycle: false
A
Alex Dima 已提交
2581
		};
2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596
		super(
			EditorOption.parameterHints, 'parameterHints', defaults,
			{
				'editor.parameterHints.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.")
				},
				'editor.parameterHints.cycle': {
					type: 'boolean',
					default: defaults.cycle,
					description: nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
				},
			}
		);
A
Alex Dima 已提交
2597 2598
	}

A
Alex Dima 已提交
2599
	public validate(_input: any): InternalParameterHintOptions {
A
Alex Dima 已提交
2600
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2601
			return this.defaultValue;
A
Alex Dima 已提交
2602
		}
A
Alex Dima 已提交
2603
		const input = _input as IEditorParameterHintOptions;
A
Alex Dima 已提交
2604
		return {
A
Alex Dima 已提交
2605 2606
			enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
			cycle: EditorBooleanOption.boolean(input.cycle, this.defaultValue.cycle)
A
Alex Dima 已提交
2607 2608
		};
	}
A
Alex Dima 已提交
2609
}
A
Alex Dima 已提交
2610

A
Alex Dima 已提交
2611
//#endregion
2612

A
Alex Dima 已提交
2613
//#region pixelRatio
2614

2615
class EditorPixelRatio extends ComputedEditorOption<EditorOption.pixelRatio, number> {
2616

2617 2618
	constructor() {
		super(EditorOption.pixelRatio);
2619 2620
	}

A
Alex Dima 已提交
2621 2622
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number {
		return env.pixelRatio;
A
Alex Dima 已提交
2623
	}
A
Alex Dima 已提交
2624
}
A
Alex Dima 已提交
2625

A
Alex Dima 已提交
2626 2627 2628 2629
//#endregion

//#region quickSuggestions

2630 2631 2632 2633
/**
 * Configuration options for quick suggestions
 */
export interface IQuickSuggestionsOptions {
A
Alex Dima 已提交
2634 2635 2636
	other?: boolean;
	comments?: boolean;
	strings?: boolean;
2637 2638
}

A
Alex Dima 已提交
2639 2640
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;

2641 2642
class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions> {

A
Alex Dima 已提交
2643
	public readonly defaultValue: Readonly<Required<IQuickSuggestionsOptions>>;
2644 2645 2646 2647 2648 2649

	constructor() {
		const defaults: ValidQuickSuggestionsOptions = {
			other: true,
			comments: false,
			strings: false
2650
		};
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682
		super(
			EditorOption.quickSuggestions, 'quickSuggestions', defaults,
			{
				anyOf: [
					{
						type: 'boolean',
					},
					{
						type: 'object',
						properties: {
							strings: {
								type: 'boolean',
								default: defaults.strings,
								description: nls.localize('quickSuggestions.strings', "Enable quick suggestions inside strings.")
							},
							comments: {
								type: 'boolean',
								default: defaults.comments,
								description: nls.localize('quickSuggestions.comments', "Enable quick suggestions inside comments.")
							},
							other: {
								type: 'boolean',
								default: defaults.other,
								description: nls.localize('quickSuggestions.other', "Enable quick suggestions outside of strings and comments.")
							},
						}
					}
				],
				default: defaults,
				description: nls.localize('quickSuggestions', "Controls whether suggestions should automatically show up while typing.")
			}
		);
2683
		this.defaultValue = defaults;
2684 2685
	}

A
Alex Dima 已提交
2686 2687 2688 2689
	public validate(_input: any): ValidQuickSuggestionsOptions {
		if (typeof _input === 'boolean') {
			return _input;
		}
A
Alex Dima 已提交
2690
		if (_input && typeof _input === 'object') {
A
Alex Dima 已提交
2691
			const input = _input as IQuickSuggestionsOptions;
2692
			const opts = {
A
Alex Dima 已提交
2693 2694 2695
				other: EditorBooleanOption.boolean(input.other, this.defaultValue.other),
				comments: EditorBooleanOption.boolean(input.comments, this.defaultValue.comments),
				strings: EditorBooleanOption.boolean(input.strings, this.defaultValue.strings),
A
Alex Dima 已提交
2696
			};
2697 2698 2699 2700 2701 2702 2703
			if (opts.other && opts.comments && opts.strings) {
				return true; // all on
			} else if (!opts.other && !opts.comments && !opts.strings) {
				return false; // all off
			} else {
				return opts;
			}
2704
		}
A
Alex Dima 已提交
2705
		return this.defaultValue;
2706
	}
A
Alex Dima 已提交
2707
}
2708

A
Alex Dima 已提交
2709
//#endregion
2710

A
Alex Dima 已提交
2711 2712 2713
//#region renderLineNumbers

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

A
Alex Dima 已提交
2715 2716 2717 2718 2719 2720 2721
export const enum RenderLineNumbersType {
	Off = 0,
	On = 1,
	Relative = 2,
	Interval = 3,
	Custom = 4
}
2722

A
Alex Dima 已提交
2723 2724 2725 2726
export interface InternalEditorRenderLineNumbersOptions {
	readonly renderType: RenderLineNumbersType;
	readonly renderFn: ((lineNumber: number) => string) | null;
}
2727

2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743
class EditorRenderLineNumbersOption extends BaseEditorOption<EditorOption.lineNumbers, InternalEditorRenderLineNumbersOptions> {

	constructor() {
		super(
			EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null },
			{
				type: 'string',
				enum: ['off', 'on', 'relative', 'interval'],
				enumDescriptions: [
					nls.localize('lineNumbers.off', "Line numbers are not rendered."),
					nls.localize('lineNumbers.on', "Line numbers are rendered as absolute number."),
					nls.localize('lineNumbers.relative', "Line numbers are rendered as distance in lines to cursor position."),
					nls.localize('lineNumbers.interval', "Line numbers are rendered every 10 lines.")
				],
				default: 'on',
				description: nls.localize('lineNumbers', "Controls the display of line numbers.")
2744
			}
2745 2746
		);
	}
2747

A
Alex Dima 已提交
2748 2749 2750 2751 2752
	public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions {
		let renderType: RenderLineNumbersType = this.defaultValue.renderType;
		let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn;

		if (typeof lineNumbers !== 'undefined') {
2753
			if (typeof lineNumbers === 'function') {
A
Alex Dima 已提交
2754 2755
				renderType = RenderLineNumbersType.Custom;
				renderFn = lineNumbers;
2756
			} else if (lineNumbers === 'interval') {
A
Alex Dima 已提交
2757
				renderType = RenderLineNumbersType.Interval;
2758
			} else if (lineNumbers === 'relative') {
A
Alex Dima 已提交
2759
				renderType = RenderLineNumbersType.Relative;
2760
			} else if (lineNumbers === 'on') {
A
Alex Dima 已提交
2761
				renderType = RenderLineNumbersType.On;
2762
			} else {
A
Alex Dima 已提交
2763
				renderType = RenderLineNumbersType.Off;
2764 2765 2766
			}
		}

A
Alex Dima 已提交
2767 2768 2769 2770 2771 2772
		return {
			renderType,
			renderFn
		};
	}
}
2773

A
Alex Dima 已提交
2774 2775
//#endregion

2776 2777 2778 2779 2780
//#region renderValidationDecorations

/**
 * @internal
 */
2781
export function filterValidationDecorations(options: IComputedEditorOptions): boolean {
2782 2783
	const renderValidationDecorations = options.get(EditorOption.renderValidationDecorations);
	if (renderValidationDecorations === 'editable') {
2784
		return options.get(EditorOption.readOnly);
2785
	}
2786
	return renderValidationDecorations === 'on' ? false : true;
2787 2788 2789 2790
}

//#endregion

A
Alex Dima 已提交
2791 2792
//#region rulers

2793 2794 2795
export interface IRulerOption {
	readonly column: number;
	readonly color: string | null;
2796 2797
}

2798
class EditorRulers extends BaseEditorOption<EditorOption.rulers, IRulerOption[]> {
2799 2800

	constructor() {
2801
		const defaults: IRulerOption[] = [];
2802
		const columnSchema: IJSONSchema = { type: 'number', description: nls.localize('rulers.size', "Number of monospace characters at which this editor ruler will render.") };
2803 2804 2805 2806 2807
		super(
			EditorOption.rulers, 'rulers', defaults,
			{
				type: 'array',
				items: {
2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820
					anyOf: [
						columnSchema,
						{
							type: [
								'object'
							],
							properties: {
								column: columnSchema,
								color: {
									type: 'string',
									description: nls.localize('rulers.color', "Color of this editor ruler."),
									format: 'color-hex'
								}
2821 2822
							}
						}
2823
					]
2824 2825 2826
				},
				default: defaults,
				description: nls.localize('rulers', "Render vertical rulers after a certain number of monospace characters. Use multiple values for multiple rulers. No rulers are drawn if array is empty.")
2827
			}
2828 2829
		);
	}
2830

2831
	public validate(input: any): IRulerOption[] {
A
Alex Dima 已提交
2832
		if (Array.isArray(input)) {
2833
			let rulers: IRulerOption[] = [];
2834 2835 2836 2837 2838 2839
			for (let _element of input) {
				if (typeof _element === 'number') {
					rulers.push({
						column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
						color: null
					});
A
Alex Dima 已提交
2840
				} else if (_element && typeof _element === 'object') {
2841 2842 2843 2844 2845
					const element = _element as IRulerOption;
					rulers.push({
						column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
						color: element.color
					});
2846
				}
2847
			}
2848
			rulers.sort((a, b) => a.column - b.column);
A
Alex Dima 已提交
2849
			return rulers;
2850
		}
A
Alex Dima 已提交
2851 2852 2853
		return this.defaultValue;
	}
}
2854

A
Alex Dima 已提交
2855
//#endregion
T
Tiago Ribeiro 已提交
2856

A
Alex Dima 已提交
2857
//#region scrollbar
2858

2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897
/**
 * Configuration options for editor scrollbars
 */
export interface IEditorScrollbarOptions {
	/**
	 * The size of arrows (if displayed).
	 * Defaults to 11.
	 */
	arrowSize?: number;
	/**
	 * Render vertical scrollbar.
	 * Defaults to 'auto'.
	 */
	vertical?: 'auto' | 'visible' | 'hidden';
	/**
	 * Render horizontal scrollbar.
	 * Defaults to 'auto'.
	 */
	horizontal?: 'auto' | 'visible' | 'hidden';
	/**
	 * 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;
2898 2899 2900 2901 2902
	/**
	 * Always consume mouse wheel events (always call preventDefault() and stopPropagation() on the browser events).
	 * Defaults to true.
	 */
	alwaysConsumeMouseWheel?: boolean;
2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922
	/**
	 * 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;
2923 2924 2925 2926
	/**
	 * Scroll gutter clicks move by page vs jump to position.
	 * Defaults to false.
	 */
A
Alex Dima 已提交
2927
	scrollByPage?: boolean;
2928 2929
}

A
Alex Dima 已提交
2930 2931 2932 2933 2934 2935 2936 2937
export interface InternalEditorScrollbarOptions {
	readonly arrowSize: number;
	readonly vertical: ScrollbarVisibility;
	readonly horizontal: ScrollbarVisibility;
	readonly useShadows: boolean;
	readonly verticalHasArrows: boolean;
	readonly horizontalHasArrows: boolean;
	readonly handleMouseWheel: boolean;
2938
	readonly alwaysConsumeMouseWheel: boolean;
A
Alex Dima 已提交
2939 2940 2941 2942
	readonly horizontalScrollbarSize: number;
	readonly horizontalSliderSize: number;
	readonly verticalScrollbarSize: number;
	readonly verticalSliderSize: number;
A
Alex Dima 已提交
2943
	readonly scrollByPage: boolean;
A
Alex Dima 已提交
2944 2945
}

A
Alex Dima 已提交
2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956
function _scrollbarVisibilityFromString(visibility: string | undefined, 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;
	}
}

2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968
class EditorScrollbar extends BaseEditorOption<EditorOption.scrollbar, InternalEditorScrollbarOptions> {

	constructor() {
		super(
			EditorOption.scrollbar, 'scrollbar',
			{
				vertical: ScrollbarVisibility.Auto,
				horizontal: ScrollbarVisibility.Auto,
				arrowSize: 11,
				useShadows: true,
				verticalHasArrows: false,
				horizontalHasArrows: false,
2969 2970
				horizontalScrollbarSize: 12,
				horizontalSliderSize: 12,
2971 2972 2973
				verticalScrollbarSize: 14,
				verticalSliderSize: 14,
				handleMouseWheel: true,
2974
				alwaysConsumeMouseWheel: true,
A
Alex Dima 已提交
2975
				scrollByPage: false
2976 2977 2978 2979
			}
		);
	}

A
Alex Dima 已提交
2980
	public validate(_input: any): InternalEditorScrollbarOptions {
A
Alex Dima 已提交
2981
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2982 2983 2984
			return this.defaultValue;
		}
		const input = _input as IEditorScrollbarOptions;
A
Alex Dima 已提交
2985 2986
		const horizontalScrollbarSize = EditorIntOption.clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000);
		const verticalScrollbarSize = EditorIntOption.clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000);
2987
		return {
A
Alex Dima 已提交
2988
			arrowSize: EditorIntOption.clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000),
A
Alex Dima 已提交
2989 2990
			vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical),
			horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal),
A
Alex Dima 已提交
2991 2992 2993 2994
			useShadows: EditorBooleanOption.boolean(input.useShadows, this.defaultValue.useShadows),
			verticalHasArrows: EditorBooleanOption.boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows),
			horizontalHasArrows: EditorBooleanOption.boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows),
			handleMouseWheel: EditorBooleanOption.boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel),
2995
			alwaysConsumeMouseWheel: EditorBooleanOption.boolean(input.alwaysConsumeMouseWheel, this.defaultValue.alwaysConsumeMouseWheel),
A
Alex Dima 已提交
2996
			horizontalScrollbarSize: horizontalScrollbarSize,
A
Alex Dima 已提交
2997
			horizontalSliderSize: EditorIntOption.clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),
A
Alex Dima 已提交
2998
			verticalScrollbarSize: verticalScrollbarSize,
A
Alex Dima 已提交
2999
			verticalSliderSize: EditorIntOption.clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000),
A
Alex Dima 已提交
3000
			scrollByPage: EditorBooleanOption.boolean(input.scrollByPage, this.defaultValue.scrollByPage),
A
Alex Dima 已提交
3001 3002
		};
	}
A
Alex Dima 已提交
3003
}
A
Alex Dima 已提交
3004

A
Alex Dima 已提交
3005 3006 3007 3008
//#endregion

//#region suggest

3009 3010 3011 3012
/**
 * Configuration options for editor suggest widget
 */
export interface ISuggestOptions {
3013 3014 3015
	/**
	 * Overwrite word ends on accept. Default to false.
	 */
3016
	insertMode?: 'insert' | 'replace';
3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037
	/**
	 * Enable graceful matching. Defaults to true.
	 */
	filterGraceful?: boolean;
	/**
	 * Prevent quick suggestions when a snippet is active. Defaults to true.
	 */
	snippetsPreventQuickSuggestions?: boolean;
	/**
	 * Favours words that appear close to the cursor.
	 */
	localityBonus?: boolean;
	/**
	 * Enable using global storage for remembering suggestions.
	 */
	shareSuggestSelections?: boolean;
	/**
	 * Enable or disable icons in suggestions. Defaults to true.
	 */
	showIcons?: boolean;
	/**
3038
	 * Enable or disable the suggest status bar.
3039
	 */
3040
	showStatusBar?: boolean;
3041 3042 3043
	/**
	 * Show details inline with the label. Defaults to true.
	 */
3044
	showInlineDetails?: boolean;
3045
	/**
3046
	 * Show method-suggestions.
3047
	 */
3048 3049 3050 3051 3052 3053 3054
	showMethods?: boolean;
	/**
	 * Show function-suggestions.
	 */
	showFunctions?: boolean;
	/**
	 * Show constructor-suggestions.
3055
	 */
3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140
	showConstructors?: boolean;
	/**
	 * Show field-suggestions.
	 */
	showFields?: boolean;
	/**
	 * Show variable-suggestions.
	 */
	showVariables?: boolean;
	/**
	 * Show class-suggestions.
	 */
	showClasses?: boolean;
	/**
	 * Show struct-suggestions.
	 */
	showStructs?: boolean;
	/**
	 * Show interface-suggestions.
	 */
	showInterfaces?: boolean;
	/**
	 * Show module-suggestions.
	 */
	showModules?: boolean;
	/**
	 * Show property-suggestions.
	 */
	showProperties?: boolean;
	/**
	 * Show event-suggestions.
	 */
	showEvents?: boolean;
	/**
	 * Show operator-suggestions.
	 */
	showOperators?: boolean;
	/**
	 * Show unit-suggestions.
	 */
	showUnits?: boolean;
	/**
	 * Show value-suggestions.
	 */
	showValues?: boolean;
	/**
	 * Show constant-suggestions.
	 */
	showConstants?: boolean;
	/**
	 * Show enum-suggestions.
	 */
	showEnums?: boolean;
	/**
	 * Show enumMember-suggestions.
	 */
	showEnumMembers?: boolean;
	/**
	 * Show keyword-suggestions.
	 */
	showKeywords?: boolean;
	/**
	 * Show text-suggestions.
	 */
	showWords?: boolean;
	/**
	 * Show color-suggestions.
	 */
	showColors?: boolean;
	/**
	 * Show file-suggestions.
	 */
	showFiles?: boolean;
	/**
	 * Show reference-suggestions.
	 */
	showReferences?: boolean;
	/**
	 * Show folder-suggestions.
	 */
	showFolders?: boolean;
	/**
	 * Show typeParameter-suggestions.
	 */
	showTypeParameters?: boolean;
3141 3142 3143 3144 3145 3146 3147 3148
	/**
	 * Show issue-suggestions.
	 */
	showIssues?: boolean;
	/**
	 * Show user-suggestions.
	 */
	showUsers?: boolean;
3149 3150 3151 3152
	/**
	 * Show snippet-suggestions.
	 */
	showSnippets?: boolean;
3153 3154
}

A
Alex Dima 已提交
3155
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
A
Alex Dima 已提交
3156

A
Alex Dima 已提交
3157
class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSuggestOptions> {
3158 3159 3160

	constructor() {
		const defaults: InternalSuggestOptions = {
3161
			insertMode: 'insert',
3162 3163 3164 3165 3166
			filterGraceful: true,
			snippetsPreventQuickSuggestions: true,
			localityBonus: false,
			shareSuggestSelections: false,
			showIcons: true,
3167
			showStatusBar: false,
3168
			showInlineDetails: true,
3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193
			showMethods: true,
			showFunctions: true,
			showConstructors: true,
			showFields: true,
			showVariables: true,
			showClasses: true,
			showStructs: true,
			showInterfaces: true,
			showModules: true,
			showProperties: true,
			showEvents: true,
			showOperators: true,
			showUnits: true,
			showValues: true,
			showConstants: true,
			showEnums: true,
			showEnumMembers: true,
			showKeywords: true,
			showWords: true,
			showColors: true,
			showFiles: true,
			showReferences: true,
			showFolders: true,
			showTypeParameters: true,
			showSnippets: true,
3194 3195
			showUsers: true,
			showIssues: true,
3196 3197 3198 3199
		};
		super(
			EditorOption.suggest, 'suggest', defaults,
			{
3200 3201 3202 3203 3204 3205 3206 3207 3208
				'editor.suggest.insertMode': {
					type: 'string',
					enum: ['insert', 'replace'],
					enumDescriptions: [
						nls.localize('suggest.insertMode.insert', "Insert suggestion without overwriting text right of the cursor."),
						nls.localize('suggest.insertMode.replace', "Insert suggestion and overwrite text right of the cursor."),
					],
					default: defaults.insertMode,
					description: nls.localize('suggest.insertMode', "Controls whether words are overwritten when accepting completions. Note that this depends on extensions opting into this feature.")
3209
				},
3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227
				'editor.suggest.filterGraceful': {
					type: 'boolean',
					default: defaults.filterGraceful,
					description: nls.localize('suggest.filterGraceful', "Controls whether filtering and sorting suggestions accounts for small typos.")
				},
				'editor.suggest.localityBonus': {
					type: 'boolean',
					default: defaults.localityBonus,
					description: nls.localize('suggest.localityBonus', "Controls whether sorting favours words that appear close to the cursor.")
				},
				'editor.suggest.shareSuggestSelections': {
					type: 'boolean',
					default: defaults.shareSuggestSelections,
					markdownDescription: nls.localize('suggest.shareSuggestSelections', "Controls whether remembered suggestion selections are shared between multiple workspaces and windows (needs `#editor.suggestSelection#`).")
				},
				'editor.suggest.snippetsPreventQuickSuggestions': {
					type: 'boolean',
					default: defaults.snippetsPreventQuickSuggestions,
P
Pine Wu 已提交
3228
					description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
3229 3230 3231 3232 3233 3234
				},
				'editor.suggest.showIcons': {
					type: 'boolean',
					default: defaults.showIcons,
					description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
				},
3235 3236 3237 3238 3239
				'editor.suggest.showStatusBar': {
					type: 'boolean',
					default: defaults.showStatusBar,
					description: nls.localize('suggest.showStatusBar', "Controls the visibility of the status bar at the bottom of the suggest widget.")
				},
3240

3241
				'editor.suggest.showInlineDetails': {
3242
					type: 'boolean',
3243 3244
					default: defaults.showInlineDetails,
					description: nls.localize('suggest.showInlineDetails', "Controls whether sugget details show inline with the label or only in the details widget")
3245
				},
3246 3247
				'editor.suggest.maxVisibleSuggestions': {
					type: 'number',
3248
					deprecationMessage: nls.localize('suggest.maxVisibleSuggestions.dep', "This setting is deprecated. The suggest widget can now be resized."),
3249 3250 3251
				},
				'editor.suggest.filteredTypes': {
					type: 'object',
3252
					deprecationMessage: nls.localize('deprecated', "This setting is deprecated, please use separate settings like 'editor.suggest.showKeywords' or 'editor.suggest.showSnippets' instead.")
J
Johannes Rieken 已提交
3253
				},
3254
				'editor.suggest.showMethods': {
3255 3256
					type: 'boolean',
					default: true,
3257
					markdownDescription: nls.localize('editor.suggest.showMethods', "When enabled IntelliSense shows `method`-suggestions.")
3258
				},
3259
				'editor.suggest.showFunctions': {
3260 3261
					type: 'boolean',
					default: true,
3262
					markdownDescription: nls.localize('editor.suggest.showFunctions', "When enabled IntelliSense shows `function`-suggestions.")
3263
				},
3264
				'editor.suggest.showConstructors': {
3265 3266
					type: 'boolean',
					default: true,
3267
					markdownDescription: nls.localize('editor.suggest.showConstructors', "When enabled IntelliSense shows `constructor`-suggestions.")
3268
				},
3269
				'editor.suggest.showFields': {
3270 3271
					type: 'boolean',
					default: true,
3272
					markdownDescription: nls.localize('editor.suggest.showFields', "When enabled IntelliSense shows `field`-suggestions.")
3273
				},
3274
				'editor.suggest.showVariables': {
3275 3276
					type: 'boolean',
					default: true,
3277
					markdownDescription: nls.localize('editor.suggest.showVariables', "When enabled IntelliSense shows `variable`-suggestions.")
3278
				},
3279
				'editor.suggest.showClasses': {
3280 3281
					type: 'boolean',
					default: true,
3282
					markdownDescription: nls.localize('editor.suggest.showClasss', "When enabled IntelliSense shows `class`-suggestions.")
3283
				},
3284
				'editor.suggest.showStructs': {
3285 3286
					type: 'boolean',
					default: true,
3287
					markdownDescription: nls.localize('editor.suggest.showStructs', "When enabled IntelliSense shows `struct`-suggestions.")
3288
				},
3289
				'editor.suggest.showInterfaces': {
3290 3291
					type: 'boolean',
					default: true,
3292
					markdownDescription: nls.localize('editor.suggest.showInterfaces', "When enabled IntelliSense shows `interface`-suggestions.")
3293
				},
3294
				'editor.suggest.showModules': {
3295 3296
					type: 'boolean',
					default: true,
3297
					markdownDescription: nls.localize('editor.suggest.showModules', "When enabled IntelliSense shows `module`-suggestions.")
3298
				},
3299
				'editor.suggest.showProperties': {
3300 3301
					type: 'boolean',
					default: true,
3302
					markdownDescription: nls.localize('editor.suggest.showPropertys', "When enabled IntelliSense shows `property`-suggestions.")
3303
				},
3304
				'editor.suggest.showEvents': {
3305 3306
					type: 'boolean',
					default: true,
3307
					markdownDescription: nls.localize('editor.suggest.showEvents', "When enabled IntelliSense shows `event`-suggestions.")
3308
				},
3309
				'editor.suggest.showOperators': {
3310 3311
					type: 'boolean',
					default: true,
3312
					markdownDescription: nls.localize('editor.suggest.showOperators', "When enabled IntelliSense shows `operator`-suggestions.")
3313
				},
3314
				'editor.suggest.showUnits': {
3315 3316
					type: 'boolean',
					default: true,
3317
					markdownDescription: nls.localize('editor.suggest.showUnits', "When enabled IntelliSense shows `unit`-suggestions.")
3318
				},
3319
				'editor.suggest.showValues': {
3320 3321
					type: 'boolean',
					default: true,
3322
					markdownDescription: nls.localize('editor.suggest.showValues', "When enabled IntelliSense shows `value`-suggestions.")
3323
				},
3324
				'editor.suggest.showConstants': {
3325 3326
					type: 'boolean',
					default: true,
3327
					markdownDescription: nls.localize('editor.suggest.showConstants', "When enabled IntelliSense shows `constant`-suggestions.")
3328
				},
3329
				'editor.suggest.showEnums': {
3330 3331
					type: 'boolean',
					default: true,
3332
					markdownDescription: nls.localize('editor.suggest.showEnums', "When enabled IntelliSense shows `enum`-suggestions.")
3333
				},
3334
				'editor.suggest.showEnumMembers': {
3335 3336
					type: 'boolean',
					default: true,
3337
					markdownDescription: nls.localize('editor.suggest.showEnumMembers', "When enabled IntelliSense shows `enumMember`-suggestions.")
3338
				},
3339
				'editor.suggest.showKeywords': {
3340 3341
					type: 'boolean',
					default: true,
3342
					markdownDescription: nls.localize('editor.suggest.showKeywords', "When enabled IntelliSense shows `keyword`-suggestions.")
3343
				},
3344
				'editor.suggest.showWords': {
3345 3346
					type: 'boolean',
					default: true,
3347
					markdownDescription: nls.localize('editor.suggest.showTexts', "When enabled IntelliSense shows `text`-suggestions.")
3348
				},
3349
				'editor.suggest.showColors': {
3350 3351
					type: 'boolean',
					default: true,
3352
					markdownDescription: nls.localize('editor.suggest.showColors', "When enabled IntelliSense shows `color`-suggestions.")
3353
				},
3354
				'editor.suggest.showFiles': {
3355 3356
					type: 'boolean',
					default: true,
3357
					markdownDescription: nls.localize('editor.suggest.showFiles', "When enabled IntelliSense shows `file`-suggestions.")
3358
				},
3359
				'editor.suggest.showReferences': {
3360 3361
					type: 'boolean',
					default: true,
3362
					markdownDescription: nls.localize('editor.suggest.showReferences', "When enabled IntelliSense shows `reference`-suggestions.")
3363
				},
3364
				'editor.suggest.showCustomcolors': {
3365 3366
					type: 'boolean',
					default: true,
3367
					markdownDescription: nls.localize('editor.suggest.showCustomcolors', "When enabled IntelliSense shows `customcolor`-suggestions.")
3368
				},
3369
				'editor.suggest.showFolders': {
3370 3371
					type: 'boolean',
					default: true,
3372
					markdownDescription: nls.localize('editor.suggest.showFolders', "When enabled IntelliSense shows `folder`-suggestions.")
3373
				},
3374
				'editor.suggest.showTypeParameters': {
3375 3376
					type: 'boolean',
					default: true,
3377
					markdownDescription: nls.localize('editor.suggest.showTypeParameters', "When enabled IntelliSense shows `typeParameter`-suggestions.")
3378
				},
3379
				'editor.suggest.showSnippets': {
3380 3381
					type: 'boolean',
					default: true,
3382
					markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
3383
				},
3384 3385 3386 3387 3388 3389 3390 3391 3392
				'editor.suggest.showUsers': {
					type: 'boolean',
					default: true,
					markdownDescription: nls.localize('editor.suggest.showUsers', "When enabled IntelliSense shows `user`-suggestions.")
				},
				'editor.suggest.showIssues': {
					type: 'boolean',
					default: true,
					markdownDescription: nls.localize('editor.suggest.showIssues', "When enabled IntelliSense shows `issues`-suggestions.")
3393
				}
3394 3395 3396 3397
			}
		);
	}

A
Alex Dima 已提交
3398
	public validate(_input: any): InternalSuggestOptions {
A
Alex Dima 已提交
3399
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
3400
			return this.defaultValue;
A
Alex Dima 已提交
3401
		}
A
Alex Dima 已提交
3402
		const input = _input as ISuggestOptions;
A
Alex Dima 已提交
3403
		return {
3404
			insertMode: EditorStringEnumOption.stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
A
Alex Dima 已提交
3405 3406 3407 3408 3409
			filterGraceful: EditorBooleanOption.boolean(input.filterGraceful, this.defaultValue.filterGraceful),
			snippetsPreventQuickSuggestions: EditorBooleanOption.boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
			localityBonus: EditorBooleanOption.boolean(input.localityBonus, this.defaultValue.localityBonus),
			shareSuggestSelections: EditorBooleanOption.boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
			showIcons: EditorBooleanOption.boolean(input.showIcons, this.defaultValue.showIcons),
3410
			showStatusBar: EditorBooleanOption.boolean(input.showStatusBar, this.defaultValue.showStatusBar),
3411
			showInlineDetails: EditorBooleanOption.boolean(input.showInlineDetails, this.defaultValue.showInlineDetails),
3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436
			showMethods: EditorBooleanOption.boolean(input.showMethods, this.defaultValue.showMethods),
			showFunctions: EditorBooleanOption.boolean(input.showFunctions, this.defaultValue.showFunctions),
			showConstructors: EditorBooleanOption.boolean(input.showConstructors, this.defaultValue.showConstructors),
			showFields: EditorBooleanOption.boolean(input.showFields, this.defaultValue.showFields),
			showVariables: EditorBooleanOption.boolean(input.showVariables, this.defaultValue.showVariables),
			showClasses: EditorBooleanOption.boolean(input.showClasses, this.defaultValue.showClasses),
			showStructs: EditorBooleanOption.boolean(input.showStructs, this.defaultValue.showStructs),
			showInterfaces: EditorBooleanOption.boolean(input.showInterfaces, this.defaultValue.showInterfaces),
			showModules: EditorBooleanOption.boolean(input.showModules, this.defaultValue.showModules),
			showProperties: EditorBooleanOption.boolean(input.showProperties, this.defaultValue.showProperties),
			showEvents: EditorBooleanOption.boolean(input.showEvents, this.defaultValue.showEvents),
			showOperators: EditorBooleanOption.boolean(input.showOperators, this.defaultValue.showOperators),
			showUnits: EditorBooleanOption.boolean(input.showUnits, this.defaultValue.showUnits),
			showValues: EditorBooleanOption.boolean(input.showValues, this.defaultValue.showValues),
			showConstants: EditorBooleanOption.boolean(input.showConstants, this.defaultValue.showConstants),
			showEnums: EditorBooleanOption.boolean(input.showEnums, this.defaultValue.showEnums),
			showEnumMembers: EditorBooleanOption.boolean(input.showEnumMembers, this.defaultValue.showEnumMembers),
			showKeywords: EditorBooleanOption.boolean(input.showKeywords, this.defaultValue.showKeywords),
			showWords: EditorBooleanOption.boolean(input.showWords, this.defaultValue.showWords),
			showColors: EditorBooleanOption.boolean(input.showColors, this.defaultValue.showColors),
			showFiles: EditorBooleanOption.boolean(input.showFiles, this.defaultValue.showFiles),
			showReferences: EditorBooleanOption.boolean(input.showReferences, this.defaultValue.showReferences),
			showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
			showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
			showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
3437 3438
			showUsers: EditorBooleanOption.boolean(input.showUsers, this.defaultValue.showUsers),
			showIssues: EditorBooleanOption.boolean(input.showIssues, this.defaultValue.showIssues),
3439 3440 3441 3442
		};
	}
}

A
Alex Dima 已提交
3443 3444
//#endregion

3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466
//#region smart select

export interface ISmartSelectOptions {
	selectLeadingAndTrailingWhitespace?: boolean
}

export type SmartSelectOptions = Readonly<Required<ISmartSelectOptions>>;

class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, SmartSelectOptions> {

	constructor() {
		super(
			EditorOption.smartSelect, 'smartSelect',
			{
				selectLeadingAndTrailingWhitespace: true
			},
			{
				'editor.smartSelect.selectLeadingAndTrailingWhitespace': {
					description: nls.localize('selectLeadingAndTrailingWhitespace', "Whether leading and trailing whitespace should always be selected."),
					default: true,
					type: 'boolean'
				}
P
Pine Wu 已提交
3467
			}
3468 3469 3470 3471 3472 3473 3474 3475 3476
		);
	}

	public validate(input: any): Readonly<Required<ISmartSelectOptions>> {
		if (!input || typeof input !== 'object') {
			return this.defaultValue;
		}
		return {
			selectLeadingAndTrailingWhitespace: EditorBooleanOption.boolean((input as ISmartSelectOptions).selectLeadingAndTrailingWhitespace, this.defaultValue.selectLeadingAndTrailingWhitespace)
3477 3478 3479 3480
		};
	}
}

A
Alex Dima 已提交
3481 3482 3483 3484
//#endregion

//#region tabFocusMode

A
Alex Dima 已提交
3485 3486 3487 3488 3489 3490
class EditorTabFocusMode extends ComputedEditorOption<EditorOption.tabFocusMode, boolean> {

	constructor() {
		super(EditorOption.tabFocusMode, [EditorOption.readOnly]);
	}

A
Alex Dima 已提交
3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: boolean): boolean {
		const readOnly = options.get(EditorOption.readOnly);
		return (readOnly ? true : env.tabFocusMode);
	}
}

//#endregion

//#region wrappingIndent

/**
 * Describes how to indent wrapped lines.
 */
export const 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 toward the parent.
	 */
	Indent = 2,
	/**
	 * DeepIndent => wrapped lines get +2 indentation toward the parent.
	 */
	DeepIndent = 3
}

function _wrappingIndentFromString(wrappingIndent: 'none' | 'same' | 'indent' | 'deepIndent'): WrappingIndent {
	switch (wrappingIndent) {
		case 'none': return WrappingIndent.None;
		case 'same': return WrappingIndent.Same;
		case 'indent': return WrappingIndent.Indent;
		case 'deepIndent': return WrappingIndent.DeepIndent;
3529
	}
A
Alex Dima 已提交
3530
}
3531

A
Alex Dima 已提交
3532
//#endregion
3533

A
Alex Dima 已提交
3534
//#region wrappingInfo
3535

A
Alex Dima 已提交
3536 3537 3538 3539 3540 3541
export interface EditorWrappingInfo {
	readonly isDominatedByLongLines: boolean;
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;
}
3542

A
Alex Dima 已提交
3543
class EditorWrappingInfoComputer extends ComputedEditorOption<EditorOption.wrappingInfo, EditorWrappingInfo> {
3544

A
Alex Dima 已提交
3545
	constructor() {
3546
		super(EditorOption.wrappingInfo, [EditorOption.layoutInfo]);
A
Alex Dima 已提交
3547 3548
	}

A
Alex Dima 已提交
3549
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorWrappingInfo): EditorWrappingInfo {
A
renames  
Alex Dima 已提交
3550
		const layoutInfo = options.get(EditorOption.layoutInfo);
3551

A
Alex Dima 已提交
3552
		return {
3553
			isDominatedByLongLines: env.isDominatedByLongLines,
3554 3555 3556
			isWordWrapMinified: layoutInfo.isWordWrapMinified,
			isViewportWrapping: layoutInfo.isViewportWrapping,
			wrappingColumn: layoutInfo.wrappingColumn,
A
Alex Dima 已提交
3557
		};
3558 3559 3560
	}
}

A
Alex Dima 已提交
3561
//#endregion
3562 3563 3564

const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
3565
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';
3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578

/**
 * @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,
3579
	letterSpacing: 0,
3580 3581 3582 3583 3584 3585 3586
};

/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
D
David Lechner 已提交
3587
	indentSize: 4,
3588 3589
	insertSpaces: true,
	detectIndentation: true,
3590
	trimAutoWhitespace: true,
3591
	largeFileOptimizations: true
3592 3593 3594 3595 3596
};

/**
 * @internal
 */
A
Alex Dima 已提交
3597 3598
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];

3599
function register<K1 extends EditorOption, V>(option: IEditorOption<K1, V>): IEditorOption<K1, V> {
A
Alex Dima 已提交
3600 3601 3602 3603
	editorOptionsRegistry[option.id] = option;
	return option;
}

A
renames  
Alex Dima 已提交
3604
export const enum EditorOption {
A
Alex Dima 已提交
3605 3606
	acceptSuggestionOnCommitCharacter,
	acceptSuggestionOnEnter,
A
Alex Dima 已提交
3607
	accessibilitySupport,
I
isidor 已提交
3608
	accessibilityPageSize,
3609
	ariaLabel,
A
Alex Dima 已提交
3610 3611 3612 3613 3614 3615
	autoClosingBrackets,
	autoClosingOvertype,
	autoClosingQuotes,
	autoIndent,
	automaticLayout,
	autoSurround,
A
Alex Dima 已提交
3616 3617
	codeLens,
	colorDecorators,
3618
	columnSelection,
A
Alex Dima 已提交
3619
	comments,
A
Alex Dima 已提交
3620
	contextmenu,
A
Alex Dima 已提交
3621 3622 3623 3624 3625
	copyWithSyntaxHighlighting,
	cursorBlinking,
	cursorSmoothCaretAnimation,
	cursorStyle,
	cursorSurroundingLines,
3626
	cursorSurroundingLinesStyle,
A
Alex Dima 已提交
3627 3628
	cursorWidth,
	disableLayerHinting,
3629
	disableMonospaceOptimizations,
A
Alex Dima 已提交
3630 3631 3632
	dragAndDrop,
	emptySelectionClipboard,
	extraEditorClassName,
A
Alex Dima 已提交
3633
	fastScrollSensitivity,
A
Alex Dima 已提交
3634
	find,
A
Alex Dima 已提交
3635
	fixedOverflowWidgets,
A
Alex Dima 已提交
3636
	folding,
A
Alex Dima 已提交
3637
	foldingStrategy,
3638
	foldingHighlight,
3639
	unfoldOnClickAfterEndOfLine,
3640 3641
	fontFamily,
	fontInfo,
A
Alex Dima 已提交
3642
	fontLigatures,
3643 3644
	fontSize,
	fontWeight,
A
Alex Dima 已提交
3645 3646
	formatOnPaste,
	formatOnType,
A
Alex Dima 已提交
3647
	glyphMargin,
A
Alex Dima 已提交
3648
	gotoLocation,
A
Alex Dima 已提交
3649 3650
	hideCursorInOverviewRuler,
	highlightActiveIndentGuide,
A
Alex Dima 已提交
3651
	hover,
A
Alex Dima 已提交
3652
	inDiffEditor,
3653
	letterSpacing,
A
Alex Dima 已提交
3654
	lightbulb,
A
Alex Dima 已提交
3655
	lineDecorationsWidth,
A
Alex Dima 已提交
3656
	lineHeight,
A
Alex Dima 已提交
3657
	lineNumbers,
A
Alex Dima 已提交
3658
	lineNumbersMinChars,
A
Alex Dima 已提交
3659 3660
	links,
	matchBrackets,
A
Alex Dima 已提交
3661
	minimap,
A
Alex Dima 已提交
3662
	mouseStyle,
A
Alex Dima 已提交
3663
	mouseWheelScrollSensitivity,
A
Alex Dima 已提交
3664 3665 3666
	mouseWheelZoom,
	multiCursorMergeOverlapping,
	multiCursorModifier,
3667
	multiCursorPaste,
A
Alex Dima 已提交
3668
	occurrencesHighlight,
A
Alex Dima 已提交
3669 3670
	overviewRulerBorder,
	overviewRulerLanes,
B
Bailey 已提交
3671
	padding,
A
Alex Dima 已提交
3672
	parameterHints,
3673
	peekWidgetDefaultFocus,
3674
	definitionLinkOpensInPeek,
A
Alex Dima 已提交
3675
	quickSuggestions,
A
Alex Dima 已提交
3676
	quickSuggestionsDelay,
3677
	readOnly,
P
Rename  
Pine Wu 已提交
3678
	renameOnType,
A
Alex Dima 已提交
3679 3680
	renderControlCharacters,
	renderIndentGuides,
A
Alex Dima 已提交
3681
	renderFinalNewline,
A
Alex Dima 已提交
3682
	renderLineHighlight,
3683
	renderLineHighlightOnlyWhenFocus,
3684
	renderValidationDecorations,
A
Alex Dima 已提交
3685 3686 3687 3688
	renderWhitespace,
	revealHorizontalRightPadding,
	roundedSelection,
	rulers,
A
Alex Dima 已提交
3689
	scrollbar,
A
Alex Dima 已提交
3690 3691
	scrollBeyondLastColumn,
	scrollBeyondLastLine,
3692
	scrollPredominantAxis,
A
Alex Dima 已提交
3693
	selectionClipboard,
A
Alex Dima 已提交
3694
	selectionHighlight,
A
Alex Dima 已提交
3695
	selectOnLineNumbers,
A
Alex Dima 已提交
3696
	showFoldingControls,
A
Alex Dima 已提交
3697
	showUnused,
A
Alex Dima 已提交
3698
	snippetSuggestions,
3699
	smartSelect,
A
Alex Dima 已提交
3700 3701
	smoothScrolling,
	stopRenderingLineAfter,
A
Alex Dima 已提交
3702
	suggest,
A
Alex Dima 已提交
3703 3704
	suggestFontSize,
	suggestLineHeight,
A
Alex Dima 已提交
3705
	suggestOnTriggerCharacters,
A
Alex Dima 已提交
3706 3707
	suggestSelection,
	tabCompletion,
3708
	tabIndex,
3709
	unusualLineTerminators,
A
Alex Dima 已提交
3710 3711
	useTabStops,
	wordSeparators,
A
Alex Dima 已提交
3712 3713 3714 3715 3716 3717
	wordWrap,
	wordWrapBreakAfterCharacters,
	wordWrapBreakBeforeCharacters,
	wordWrapColumn,
	wordWrapMinified,
	wrappingIndent,
3718
	wrappingStrategy,
3719
	showDeprecated,
A
Alex Dima 已提交
3720

A
Alex Dima 已提交
3721
	// Leave these at the end (because they have dependencies!)
A
Alex Dima 已提交
3722
	editorClassName,
A
Alex Dima 已提交
3723
	pixelRatio,
A
Alex Dima 已提交
3724
	tabFocusMode,
A
Alex Dima 已提交
3725 3726
	layoutInfo,
	wrappingInfo,
3727 3728
}

3729
/**
3730 3731 3732
 * WORKAROUND: TS emits "any" for complex editor options values (anything except string, bool, enum, etc. ends up being "any")
 * @monacodtsreplace
 * /accessibilitySupport, any/accessibilitySupport, AccessibilitySupport/
A
Alex Dima 已提交
3733
 * /comments, any/comments, EditorCommentsOptions/
3734 3735 3736 3737 3738 3739 3740 3741 3742
 * /find, any/find, EditorFindOptions/
 * /fontInfo, any/fontInfo, FontInfo/
 * /gotoLocation, any/gotoLocation, GoToLocationOptions/
 * /hover, any/hover, EditorHoverOptions/
 * /lightbulb, any/lightbulb, EditorLightbulbOptions/
 * /minimap, any/minimap, EditorMinimapOptions/
 * /parameterHints, any/parameterHints, InternalParameterHintOptions/
 * /quickSuggestions, any/quickSuggestions, ValidQuickSuggestionsOptions/
 * /suggest, any/suggest, InternalSuggestOptions/
3743
 */
A
renames  
Alex Dima 已提交
3744
export const EditorOptions = {
3745 3746 3747 3748
	acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption(
		EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true,
		{ markdownDescription: nls.localize('acceptSuggestionOnCommitCharacter', "Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.") }
	)),
3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762
	acceptSuggestionOnEnter: register(new EditorStringEnumOption(
		EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter',
		'on' as 'on' | 'smart' | 'off',
		['on', 'smart', 'off'] as const,
		{
			markdownEnumDescriptions: [
				'',
				nls.localize('acceptSuggestionOnEnterSmart', "Only accept a suggestion with `Enter` when it makes a textual change."),
				''
			],
			markdownDescription: nls.localize('acceptSuggestionOnEnter', "Controls whether suggestions should be accepted on `Enter`, in addition to `Tab`. Helps to avoid ambiguity between inserting new lines or accepting suggestions.")
		}
	)),
	accessibilitySupport: register(new EditorAccessibilitySupport()),
I
isidor 已提交
3763 3764
	accessibilityPageSize: register(new EditorIntOption(EditorOption.accessibilityPageSize, 'accessibilityPageSize', 10, 1, Constants.MAX_SAFE_SMALL_INTEGER,
		{ description: nls.localize('accessibilityPageSize', "Controls the number of lines in the editor that can be read out by a screen reader. Warning: this has a performance implication for numbers larger than the default.") })),
3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808
	ariaLabel: register(new EditorStringOption(
		EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content")
	)),
	autoClosingBrackets: register(new EditorStringEnumOption(
		EditorOption.autoClosingBrackets, 'autoClosingBrackets',
		'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',
		['always', 'languageDefined', 'beforeWhitespace', 'never'] as const,
		{
			enumDescriptions: [
				'',
				nls.localize('editor.autoClosingBrackets.languageDefined', "Use language configurations to determine when to autoclose brackets."),
				nls.localize('editor.autoClosingBrackets.beforeWhitespace', "Autoclose brackets only when the cursor is to the left of whitespace."),
				'',
			],
			description: nls.localize('autoClosingBrackets', "Controls whether the editor should automatically close brackets after the user adds an opening bracket.")
		}
	)),
	autoClosingOvertype: register(new EditorStringEnumOption(
		EditorOption.autoClosingOvertype, 'autoClosingOvertype',
		'auto' as 'always' | 'auto' | 'never',
		['always', 'auto', 'never'] as const,
		{
			enumDescriptions: [
				'',
				nls.localize('editor.autoClosingOvertype.auto', "Type over closing quotes or brackets only if they were automatically inserted."),
				'',
			],
			description: nls.localize('autoClosingOvertype', "Controls whether the editor should type over closing quotes or brackets.")
		}
	)),
	autoClosingQuotes: register(new EditorStringEnumOption(
		EditorOption.autoClosingQuotes, 'autoClosingQuotes',
		'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',
		['always', 'languageDefined', 'beforeWhitespace', 'never'] as const,
		{
			enumDescriptions: [
				'',
				nls.localize('editor.autoClosingQuotes.languageDefined', "Use language configurations to determine when to autoclose quotes."),
				nls.localize('editor.autoClosingQuotes.beforeWhitespace', "Autoclose quotes only when the cursor is to the left of whitespace."),
				'',
			],
			description: nls.localize('autoClosingQuotes', "Controls whether the editor should automatically close quotes after the user adds an opening quote.")
		}
	)),
A
wip  
Alexandru Dima 已提交
3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823
	autoIndent: register(new EditorEnumOption(
		EditorOption.autoIndent, 'autoIndent',
		EditorAutoIndentStrategy.Full, 'full',
		['none', 'keep', 'brackets', 'advanced', 'full'],
		_autoIndentFromString,
		{
			enumDescriptions: [
				nls.localize('editor.autoIndent.none', "The editor will not insert indentation automatically."),
				nls.localize('editor.autoIndent.keep', "The editor will keep the current line's indentation."),
				nls.localize('editor.autoIndent.brackets', "The editor will keep the current line's indentation and honor language defined brackets."),
				nls.localize('editor.autoIndent.advanced', "The editor will keep the current line's indentation, honor language defined brackets and invoke special onEnterRules defined by languages."),
				nls.localize('editor.autoIndent.full', "The editor will keep the current line's indentation, honor language defined brackets, invoke special onEnterRules defined by languages, and honor indentationRules defined by languages."),
			],
			description: nls.localize('autoIndent', "Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.")
		}
3824 3825 3826 3827
	)),
	automaticLayout: register(new EditorBooleanOption(
		EditorOption.automaticLayout, 'automaticLayout', false,
	)),
3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838
	autoSurround: register(new EditorStringEnumOption(
		EditorOption.autoSurround, 'autoSurround',
		'languageDefined' as 'languageDefined' | 'quotes' | 'brackets' | 'never',
		['languageDefined', 'quotes', 'brackets', 'never'] as const,
		{
			enumDescriptions: [
				nls.localize('editor.autoSurround.languageDefined', "Use language configurations to determine when to automatically surround selections."),
				nls.localize('editor.autoSurround.quotes', "Surround with quotes but not brackets."),
				nls.localize('editor.autoSurround.brackets', "Surround with brackets but not quotes."),
				''
			],
3839
			description: nls.localize('autoSurround', "Controls whether the editor should automatically surround selections when typing quotes or brackets.")
3840 3841
		}
	)),
3842 3843 3844 3845 3846 3847 3848 3849
	codeLens: register(new EditorBooleanOption(
		EditorOption.codeLens, 'codeLens', true,
		{ description: nls.localize('codeLens', "Controls whether the editor shows CodeLens.") }
	)),
	colorDecorators: register(new EditorBooleanOption(
		EditorOption.colorDecorators, 'colorDecorators', true,
		{ description: nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators and color picker.") }
	)),
3850 3851 3852 3853
	columnSelection: register(new EditorBooleanOption(
		EditorOption.columnSelection, 'columnSelection', false,
		{ description: nls.localize('columnSelection', "Enable that the selection with the mouse and keys is doing column selection.") }
	)),
A
Alex Dima 已提交
3854
	comments: register(new EditorComments()),
3855 3856 3857 3858 3859 3860 3861
	contextmenu: register(new EditorBooleanOption(
		EditorOption.contextmenu, 'contextmenu', true,
	)),
	copyWithSyntaxHighlighting: register(new EditorBooleanOption(
		EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true,
		{ description: nls.localize('copyWithSyntaxHighlighting', "Controls whether syntax highlighting should be copied into the clipboard.") }
	)),
3862 3863 3864 3865 3866 3867 3868
	cursorBlinking: register(new EditorEnumOption(
		EditorOption.cursorBlinking, 'cursorBlinking',
		TextEditorCursorBlinkingStyle.Blink, 'blink',
		['blink', 'smooth', 'phase', 'expand', 'solid'],
		_cursorBlinkingStyleFromString,
		{ description: nls.localize('cursorBlinking', "Control the cursor animation style.") }
	)),
3869 3870 3871 3872
	cursorSmoothCaretAnimation: register(new EditorBooleanOption(
		EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false,
		{ description: nls.localize('cursorSmoothCaretAnimation', "Controls whether the smooth caret animation should be enabled.") }
	)),
3873 3874 3875 3876 3877 3878 3879 3880 3881 3882
	cursorStyle: register(new EditorEnumOption(
		EditorOption.cursorStyle, 'cursorStyle',
		TextEditorCursorStyle.Line, 'line',
		['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'],
		_cursorStyleFromString,
		{ description: nls.localize('cursorStyle', "Controls the cursor style.") }
	)),
	cursorSurroundingLines: register(new EditorIntOption(
		EditorOption.cursorSurroundingLines, 'cursorSurroundingLines',
		0, 0, Constants.MAX_SAFE_SMALL_INTEGER,
3883
		{ description: nls.localize('cursorSurroundingLines', "Controls the minimal number of visible leading and trailing lines surrounding the cursor. Known as 'scrollOff' or 'scrollOffset' in some other editors.") }
3884
	)),
3885 3886 3887 3888 3889 3890
	cursorSurroundingLinesStyle: register(new EditorStringEnumOption(
		EditorOption.cursorSurroundingLinesStyle, 'cursorSurroundingLinesStyle',
		'default' as 'default' | 'all',
		['default', 'all'] as const,
		{
			enumDescriptions: [
G
Greg Van Liew 已提交
3891
				nls.localize('cursorSurroundingLinesStyle.default', "`cursorSurroundingLines` is enforced only when triggered via the keyboard or API."),
3892 3893
				nls.localize('cursorSurroundingLinesStyle.all', "`cursorSurroundingLines` is enforced always.")
			],
G
Greg Van Liew 已提交
3894
			description: nls.localize('cursorSurroundingLinesStyle', "Controls when `cursorSurroundingLines` should be enforced.")
3895 3896
		}
	)),
3897 3898 3899 3900 3901
	cursorWidth: register(new EditorIntOption(
		EditorOption.cursorWidth, 'cursorWidth',
		0, 0, Constants.MAX_SAFE_SMALL_INTEGER,
		{ markdownDescription: nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.") }
	)),
3902 3903 3904
	disableLayerHinting: register(new EditorBooleanOption(
		EditorOption.disableLayerHinting, 'disableLayerHinting', false,
	)),
3905 3906 3907
	disableMonospaceOptimizations: register(new EditorBooleanOption(
		EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false
	)),
3908 3909 3910 3911
	dragAndDrop: register(new EditorBooleanOption(
		EditorOption.dragAndDrop, 'dragAndDrop', true,
		{ description: nls.localize('dragAndDrop', "Controls whether the editor should allow moving selections via drag and drop.") }
	)),
3912 3913 3914 3915 3916 3917 3918 3919 3920 3921
	emptySelectionClipboard: register(new EditorEmptySelectionClipboard()),
	extraEditorClassName: register(new EditorStringOption(
		EditorOption.extraEditorClassName, 'extraEditorClassName', '',
	)),
	fastScrollSensitivity: register(new EditorFloatOption(
		EditorOption.fastScrollSensitivity, 'fastScrollSensitivity',
		5, x => (x <= 0 ? 5 : x),
		{ markdownDescription: nls.localize('fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`.") }
	)),
	find: register(new EditorFind()),
3922 3923 3924 3925 3926 3927 3928
	fixedOverflowWidgets: register(new EditorBooleanOption(
		EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false,
	)),
	folding: register(new EditorBooleanOption(
		EditorOption.folding, 'folding', true,
		{ description: nls.localize('folding', "Controls whether the editor has code folding enabled.") }
	)),
3929 3930 3931 3932
	foldingStrategy: register(new EditorStringEnumOption(
		EditorOption.foldingStrategy, 'foldingStrategy',
		'auto' as 'auto' | 'indentation',
		['auto', 'indentation'] as const,
3933 3934 3935 3936 3937 3938 3939
		{
			enumDescriptions: [
				nls.localize('foldingStrategy.auto', "Use a language-specific folding strategy if available, else the indentation-based one."),
				nls.localize('foldingStrategy.indentation', "Use the indentation-based folding strategy."),
			],
			description: nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges.")
		}
3940
	)),
3941 3942 3943
	foldingHighlight: register(new EditorBooleanOption(
		EditorOption.foldingHighlight, 'foldingHighlight', true,
		{ description: nls.localize('foldingHighlight', "Controls whether the editor should highlight folded ranges.") }
3944
	)),
3945 3946 3947
	unfoldOnClickAfterEndOfLine: register(new EditorBooleanOption(
		EditorOption.unfoldOnClickAfterEndOfLine, 'unfoldOnClickAfterEndOfLine', false,
		{ description: nls.localize('unfoldOnClickAfterEndOfLine', "Controls whether clicking on the empty content after a folded line will unfold the line.") }
3948
	)),
3949 3950 3951 3952 3953
	fontFamily: register(new EditorStringOption(
		EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
		{ description: nls.localize('fontFamily', "Controls the font family.") }
	)),
	fontInfo: register(new EditorFontInfo()),
3954
	fontLigatures2: register(new EditorFontLigatures()),
3955
	fontSize: register(new EditorFontSize()),
3956
	fontWeight: register(new EditorFontWeight()),
3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968
	formatOnPaste: register(new EditorBooleanOption(
		EditorOption.formatOnPaste, 'formatOnPaste', false,
		{ description: nls.localize('formatOnPaste', "Controls whether the editor should automatically format the pasted content. A formatter must be available and the formatter should be able to format a range in a document.") }
	)),
	formatOnType: register(new EditorBooleanOption(
		EditorOption.formatOnType, 'formatOnType', false,
		{ description: nls.localize('formatOnType', "Controls whether the editor should automatically format the line after typing.") }
	)),
	glyphMargin: register(new EditorBooleanOption(
		EditorOption.glyphMargin, 'glyphMargin', true,
		{ description: nls.localize('glyphMargin', "Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.") }
	)),
3969
	gotoLocation: register(new EditorGoToLocation()),
3970 3971 3972 3973 3974 3975 3976 3977
	hideCursorInOverviewRuler: register(new EditorBooleanOption(
		EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false,
		{ description: nls.localize('hideCursorInOverviewRuler', "Controls whether the cursor should be hidden in the overview ruler.") }
	)),
	highlightActiveIndentGuide: register(new EditorBooleanOption(
		EditorOption.highlightActiveIndentGuide, 'highlightActiveIndentGuide', true,
		{ description: nls.localize('highlightActiveIndentGuide', "Controls whether the editor should highlight the active indent guide.") }
	)),
3978
	hover: register(new EditorHover()),
3979 3980 3981
	inDiffEditor: register(new EditorBooleanOption(
		EditorOption.inDiffEditor, 'inDiffEditor', false,
	)),
3982 3983 3984 3985 3986 3987
	letterSpacing: register(new EditorFloatOption(
		EditorOption.letterSpacing, 'letterSpacing',
		EDITOR_FONT_DEFAULTS.letterSpacing, x => EditorFloatOption.clamp(x, -5, 20),
		{ description: nls.localize('letterSpacing', "Controls the letter spacing in pixels.") }
	)),
	lightbulb: register(new EditorLightbulb()),
3988
	lineDecorationsWidth: register(new SimpleEditorOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10 as number | string)),
3989 3990 3991 3992
	lineHeight: register(new EditorLineHeight()),
	lineNumbers: register(new EditorRenderLineNumbersOption()),
	lineNumbersMinChars: register(new EditorIntOption(
		EditorOption.lineNumbersMinChars, 'lineNumbersMinChars',
3993
		5, 1, 300
3994
	)),
3995 3996 3997 3998
	links: register(new EditorBooleanOption(
		EditorOption.links, 'links', true,
		{ description: nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }
	)),
3999 4000 4001 4002 4003
	matchBrackets: register(new EditorStringEnumOption(
		EditorOption.matchBrackets, 'matchBrackets',
		'always' as 'never' | 'near' | 'always',
		['always', 'near', 'never'] as const,
		{ description: nls.localize('matchBrackets', "Highlight matching brackets.") }
4004
	)),
4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015
	minimap: register(new EditorMinimap()),
	mouseStyle: register(new EditorStringEnumOption(
		EditorOption.mouseStyle, 'mouseStyle',
		'text' as 'text' | 'default' | 'copy',
		['text', 'default', 'copy'] as const,
	)),
	mouseWheelScrollSensitivity: register(new EditorFloatOption(
		EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity',
		1, x => (x === 0 ? 1 : x),
		{ markdownDescription: nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }
	)),
4016 4017 4018 4019 4020 4021 4022 4023
	mouseWheelZoom: register(new EditorBooleanOption(
		EditorOption.mouseWheelZoom, 'mouseWheelZoom', false,
		{ markdownDescription: nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding `Ctrl`.") }
	)),
	multiCursorMergeOverlapping: register(new EditorBooleanOption(
		EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true,
		{ description: nls.localize('multiCursorMergeOverlapping', "Merge multiple cursors when they are overlapping.") }
	)),
4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042
	multiCursorModifier: register(new EditorEnumOption(
		EditorOption.multiCursorModifier, 'multiCursorModifier',
		'altKey', 'alt',
		['ctrlCmd', 'alt'],
		_multiCursorModifierFromString,
		{
			markdownEnumDescriptions: [
				nls.localize('multiCursorModifier.ctrlCmd', "Maps to `Control` on Windows and Linux and to `Command` on macOS."),
				nls.localize('multiCursorModifier.alt', "Maps to `Alt` on Windows and Linux and to `Option` on macOS.")
			],
			markdownDescription: nls.localize({
				key: 'multiCursorModifier',
				comment: [
					'- `ctrlCmd` refers to a value the setting can take and should not be localized.',
					'- `Control` and `Command` refer to the modifier keys Ctrl or Cmd on the keyboard and can be localized.'
				]
			}, "The modifier to be used to add multiple cursors with the mouse. The Go To Definition and Open Link mouse gestures will adapt such that they do not conflict with the multicursor modifier. [Read more](https://code.visualstudio.com/docs/editor/codebasics#_multicursor-modifier).")
		}
	)),
4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054
	multiCursorPaste: register(new EditorStringEnumOption(
		EditorOption.multiCursorPaste, 'multiCursorPaste',
		'spread' as 'spread' | 'full',
		['spread', 'full'] as const,
		{
			markdownEnumDescriptions: [
				nls.localize('multiCursorPaste.spread', "Each cursor pastes a single line of the text."),
				nls.localize('multiCursorPaste.full', "Each cursor pastes the full text.")
			],
			markdownDescription: nls.localize('multiCursorPaste', "Controls pasting when the line count of the pasted text matches the cursor count.")
		}
	)),
4055 4056 4057 4058 4059 4060 4061 4062
	occurrencesHighlight: register(new EditorBooleanOption(
		EditorOption.occurrencesHighlight, 'occurrencesHighlight', true,
		{ description: nls.localize('occurrencesHighlight', "Controls whether the editor should highlight semantic symbol occurrences.") }
	)),
	overviewRulerBorder: register(new EditorBooleanOption(
		EditorOption.overviewRulerBorder, 'overviewRulerBorder', true,
		{ description: nls.localize('overviewRulerBorder', "Controls whether a border should be drawn around the overview ruler.") }
	)),
4063 4064
	overviewRulerLanes: register(new EditorIntOption(
		EditorOption.overviewRulerLanes, 'overviewRulerLanes',
4065
		3, 0, 3
4066
	)),
B
Bailey 已提交
4067
	padding: register(new EditorPadding()),
4068
	parameterHints: register(new EditorParameterHints()),
4069 4070 4071 4072 4073 4074
	peekWidgetDefaultFocus: register(new EditorStringEnumOption(
		EditorOption.peekWidgetDefaultFocus, 'peekWidgetDefaultFocus',
		'tree' as 'tree' | 'editor',
		['tree', 'editor'] as const,
		{
			enumDescriptions: [
4075
				nls.localize('peekWidgetDefaultFocus.tree', "Focus the tree when opening peek"),
4076 4077 4078 4079
				nls.localize('peekWidgetDefaultFocus.editor', "Focus the editor when opening peek")
			],
			description: nls.localize('peekWidgetDefaultFocus', "Controls whether to focus the inline editor or the tree in the peek widget.")
		}
4080
	)),
4081 4082
	definitionLinkOpensInPeek: register(new EditorBooleanOption(
		EditorOption.definitionLinkOpensInPeek, 'definitionLinkOpensInPeek', false,
4083
		{ description: nls.localize('definitionLinkOpensInPeek', "Controls whether the Go to Definition mouse gesture always opens the peek widget.") }
4084
	)),
4085 4086 4087 4088 4089 4090
	quickSuggestions: register(new EditorQuickSuggestions()),
	quickSuggestionsDelay: register(new EditorIntOption(
		EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay',
		10, 0, Constants.MAX_SAFE_SMALL_INTEGER,
		{ description: nls.localize('quickSuggestionsDelay', "Controls the delay in milliseconds after which quick suggestions will show up.") }
	)),
4091 4092 4093
	readOnly: register(new EditorBooleanOption(
		EditorOption.readOnly, 'readOnly', false,
	)),
P
Rename  
Pine Wu 已提交
4094 4095 4096 4097
	renameOnType: register(new EditorBooleanOption(
		EditorOption.renameOnType, 'renameOnType', false,
		{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type.") }
	)),
4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109
	renderControlCharacters: register(new EditorBooleanOption(
		EditorOption.renderControlCharacters, 'renderControlCharacters', false,
		{ description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters.") }
	)),
	renderIndentGuides: register(new EditorBooleanOption(
		EditorOption.renderIndentGuides, 'renderIndentGuides', true,
		{ description: nls.localize('renderIndentGuides', "Controls whether the editor should render indent guides.") }
	)),
	renderFinalNewline: register(new EditorBooleanOption(
		EditorOption.renderFinalNewline, 'renderFinalNewline', true,
		{ description: nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }
	)),
4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123
	renderLineHighlight: register(new EditorStringEnumOption(
		EditorOption.renderLineHighlight, 'renderLineHighlight',
		'line' as 'none' | 'gutter' | 'line' | 'all',
		['none', 'gutter', 'line', 'all'] as const,
		{
			enumDescriptions: [
				'',
				'',
				'',
				nls.localize('renderLineHighlight.all', "Highlights both the gutter and the current line."),
			],
			description: nls.localize('renderLineHighlight', "Controls how the editor should render the current line highlight.")
		}
	)),
4124 4125 4126 4127
	renderLineHighlightOnlyWhenFocus: register(new EditorBooleanOption(
		EditorOption.renderLineHighlightOnlyWhenFocus, 'renderLineHighlightOnlyWhenFocus', false,
		{ description: nls.localize('renderLineHighlightOnlyWhenFocus', "Controls if the editor should render the current line highlight only when the editor is focused") }
	)),
4128 4129 4130 4131 4132
	renderValidationDecorations: register(new EditorStringEnumOption(
		EditorOption.renderValidationDecorations, 'renderValidationDecorations',
		'editable' as 'editable' | 'on' | 'off',
		['editable', 'on', 'off'] as const
	)),
4133 4134
	renderWhitespace: register(new EditorStringEnumOption(
		EditorOption.renderWhitespace, 'renderWhitespace',
4135 4136
		'selection' as 'selection' | 'none' | 'boundary' | 'trailing' | 'all',
		['none', 'boundary', 'selection', 'trailing', 'all'] as const,
4137 4138 4139 4140 4141
		{
			enumDescriptions: [
				'',
				nls.localize('renderWhitespace.boundary', "Render whitespace characters except for single spaces between words."),
				nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."),
4142
				nls.localize('renderWhitespace.trailing', "Render only trailing whitespace characters"),
4143 4144 4145 4146 4147 4148 4149 4150 4151
				''
			],
			description: nls.localize('renderWhitespace', "Controls how the editor should render whitespace characters.")
		}
	)),
	revealHorizontalRightPadding: register(new EditorIntOption(
		EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding',
		30, 0, 1000,
	)),
4152 4153 4154 4155
	roundedSelection: register(new EditorBooleanOption(
		EditorOption.roundedSelection, 'roundedSelection', true,
		{ description: nls.localize('roundedSelection', "Controls whether selections should have rounded corners.") }
	)),
4156 4157 4158 4159 4160 4161 4162
	rulers: register(new EditorRulers()),
	scrollbar: register(new EditorScrollbar()),
	scrollBeyondLastColumn: register(new EditorIntOption(
		EditorOption.scrollBeyondLastColumn, 'scrollBeyondLastColumn',
		5, 0, Constants.MAX_SAFE_SMALL_INTEGER,
		{ description: nls.localize('scrollBeyondLastColumn', "Controls the number of extra characters beyond which the editor will scroll horizontally.") }
	)),
4163 4164 4165 4166
	scrollBeyondLastLine: register(new EditorBooleanOption(
		EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true,
		{ description: nls.localize('scrollBeyondLastLine', "Controls whether the editor will scroll beyond the last line.") }
	)),
4167 4168 4169
	scrollPredominantAxis: register(new EditorBooleanOption(
		EditorOption.scrollPredominantAxis, 'scrollPredominantAxis', true,
		{ description: nls.localize('scrollPredominantAxis', "Scroll only along the predominant axis when scrolling both vertically and horizontally at the same time. Prevents horizontal drift when scrolling vertically on a trackpad.") }
4170
	)),
4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184
	selectionClipboard: register(new EditorBooleanOption(
		EditorOption.selectionClipboard, 'selectionClipboard', true,
		{
			description: nls.localize('selectionClipboard', "Controls whether the Linux primary clipboard should be supported."),
			included: platform.isLinux
		}
	)),
	selectionHighlight: register(new EditorBooleanOption(
		EditorOption.selectionHighlight, 'selectionHighlight', true,
		{ description: nls.localize('selectionHighlight', "Controls whether the editor should highlight matches similar to the selection.") }
	)),
	selectOnLineNumbers: register(new EditorBooleanOption(
		EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true,
	)),
4185 4186 4187 4188
	showFoldingControls: register(new EditorStringEnumOption(
		EditorOption.showFoldingControls, 'showFoldingControls',
		'mouseover' as 'always' | 'mouseover',
		['always', 'mouseover'] as const,
4189 4190 4191 4192 4193 4194 4195
		{
			enumDescriptions: [
				nls.localize('showFoldingControls.always', "Always show the folding controls."),
				nls.localize('showFoldingControls.mouseover', "Only show the folding controls when the mouse is over the gutter."),
			],
			description: nls.localize('showFoldingControls', "Controls when the folding controls on the gutter are shown.")
		}
4196
	)),
4197 4198 4199 4200
	showUnused: register(new EditorBooleanOption(
		EditorOption.showUnused, 'showUnused', true,
		{ description: nls.localize('showUnused', "Controls fading out of unused code.") }
	)),
4201 4202 4203 4204
	showDeprecated: register(new EditorBooleanOption(
		EditorOption.showDeprecated, 'showDeprecated', true,
		{ description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") }
	)),
4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218
	snippetSuggestions: register(new EditorStringEnumOption(
		EditorOption.snippetSuggestions, 'snippetSuggestions',
		'inline' as 'top' | 'bottom' | 'inline' | 'none',
		['top', 'bottom', 'inline', 'none'] as const,
		{
			enumDescriptions: [
				nls.localize('snippetSuggestions.top', "Show snippet suggestions on top of other suggestions."),
				nls.localize('snippetSuggestions.bottom', "Show snippet suggestions below other suggestions."),
				nls.localize('snippetSuggestions.inline', "Show snippets suggestions with other suggestions."),
				nls.localize('snippetSuggestions.none', "Do not show snippet suggestions."),
			],
			description: nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.")
		}
	)),
4219
	smartSelect: register(new SmartSelect()),
4220 4221 4222 4223
	smoothScrolling: register(new EditorBooleanOption(
		EditorOption.smoothScrolling, 'smoothScrolling', false,
		{ description: nls.localize('smoothScrolling', "Controls whether the editor will scroll using an animation.") }
	)),
4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238
	stopRenderingLineAfter: register(new EditorIntOption(
		EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter',
		10000, -1, Constants.MAX_SAFE_SMALL_INTEGER,
	)),
	suggest: register(new EditorSuggest()),
	suggestFontSize: register(new EditorIntOption(
		EditorOption.suggestFontSize, 'suggestFontSize',
		0, 0, 1000,
		{ markdownDescription: nls.localize('suggestFontSize', "Font size for the suggest widget. When set to `0`, the value of `#editor.fontSize#` is used.") }
	)),
	suggestLineHeight: register(new EditorIntOption(
		EditorOption.suggestLineHeight, 'suggestLineHeight',
		0, 0, 1000,
		{ markdownDescription: nls.localize('suggestLineHeight', "Line height for the suggest widget. When set to `0`, the value of `#editor.lineHeight#` is used.") }
	)),
4239 4240 4241 4242
	suggestOnTriggerCharacters: register(new EditorBooleanOption(
		EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true,
		{ description: nls.localize('suggestOnTriggerCharacters', "Controls whether suggestions should automatically show up when typing trigger characters.") }
	)),
4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268
	suggestSelection: register(new EditorStringEnumOption(
		EditorOption.suggestSelection, 'suggestSelection',
		'recentlyUsed' as 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix',
		['first', 'recentlyUsed', 'recentlyUsedByPrefix'] as const,
		{
			markdownEnumDescriptions: [
				nls.localize('suggestSelection.first', "Always select the first suggestion."),
				nls.localize('suggestSelection.recentlyUsed', "Select recent suggestions unless further typing selects one, e.g. `console.| -> console.log` because `log` has been completed recently."),
				nls.localize('suggestSelection.recentlyUsedByPrefix', "Select suggestions based on previous prefixes that have completed those suggestions, e.g. `co -> console` and `con -> const`."),
			],
			description: nls.localize('suggestSelection', "Controls how suggestions are pre-selected when showing the suggest list.")
		}
	)),
	tabCompletion: register(new EditorStringEnumOption(
		EditorOption.tabCompletion, 'tabCompletion',
		'off' as 'on' | 'off' | 'onlySnippets',
		['on', 'off', 'onlySnippets'] as const,
		{
			enumDescriptions: [
				nls.localize('tabCompletion.on', "Tab complete will insert the best matching suggestion when pressing tab."),
				nls.localize('tabCompletion.off', "Disable tab completions."),
				nls.localize('tabCompletion.onlySnippets', "Tab complete snippets when their prefix match. Works best when 'quickSuggestions' aren't enabled."),
			],
			description: nls.localize('tabCompletion', "Enables tab completions.")
		}
	)),
4269 4270 4271 4272
	tabIndex: register(new EditorIntOption(
		EditorOption.tabIndex, 'tabIndex',
		0, -1, Constants.MAX_SAFE_SMALL_INTEGER
	)),
4273 4274
	unusualLineTerminators: register(new EditorStringEnumOption(
		EditorOption.unusualLineTerminators, 'unusualLineTerminators',
4275 4276
		'prompt' as 'auto' | 'off' | 'prompt',
		['auto', 'off', 'prompt'] as const,
4277 4278
		{
			enumDescriptions: [
4279
				nls.localize('unusualLineTerminators.auto', "Unusual line terminators are automatically removed."),
4280 4281 4282 4283 4284 4285
				nls.localize('unusualLineTerminators.off', "Unusual line terminators are ignored."),
				nls.localize('unusualLineTerminators.prompt', "Unusual line terminators prompt to be removed."),
			],
			description: nls.localize('unusualLineTerminators', "Remove unusual line terminators that might cause problems.")
		}
	)),
4286 4287 4288 4289
	useTabStops: register(new EditorBooleanOption(
		EditorOption.useTabStops, 'useTabStops', true,
		{ description: nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops.") }
	)),
4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326
	wordSeparators: register(new EditorStringOption(
		EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS,
		{ description: nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations.") }
	)),
	wordWrap: register(new EditorStringEnumOption(
		EditorOption.wordWrap, 'wordWrap',
		'off' as 'off' | 'on' | 'wordWrapColumn' | 'bounded',
		['off', 'on', 'wordWrapColumn', 'bounded'] as const,
		{
			markdownEnumDescriptions: [
				nls.localize('wordWrap.off', "Lines will never wrap."),
				nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
				nls.localize({
					key: 'wordWrap.wordWrapColumn',
					comment: [
						'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
					]
				}, "Lines will wrap at `#editor.wordWrapColumn#`."),
				nls.localize({
					key: 'wordWrap.bounded',
					comment: [
						'- viewport means the edge of the visible window size.',
						'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
					]
				}, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."),
			],
			description: nls.localize({
				key: 'wordWrap',
				comment: [
					'- \'off\', \'on\', \'wordWrapColumn\' and \'bounded\' refer to values the setting can take and should not be localized.',
					'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
				]
			}, "Controls how lines should wrap.")
		}
	)),
	wordWrapBreakAfterCharacters: register(new EditorStringOption(
		EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters',
4327
		' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345
	)),
	wordWrapBreakBeforeCharacters: register(new EditorStringOption(
		EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters',
		'([{‘“〈《「『【〔([{「£¥$£¥++'
	)),
	wordWrapColumn: register(new EditorIntOption(
		EditorOption.wordWrapColumn, 'wordWrapColumn',
		80, 1, Constants.MAX_SAFE_SMALL_INTEGER,
		{
			markdownDescription: nls.localize({
				key: 'wordWrapColumn',
				comment: [
					'- `editor.wordWrap` refers to a different setting and should not be localized.',
					'- \'wordWrapColumn\' and \'bounded\' refer to values the different setting can take and should not be localized.'
				]
			}, "Controls the wrapping column of the editor when `#editor.wordWrap#` is `wordWrapColumn` or `bounded`.")
		}
	)),
4346 4347 4348
	wordWrapMinified: register(new EditorBooleanOption(
		EditorOption.wordWrapMinified, 'wordWrapMinified', true,
	)),
4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363
	wrappingIndent: register(new EditorEnumOption(
		EditorOption.wrappingIndent, 'wrappingIndent',
		WrappingIndent.Same, 'same',
		['none', 'same', 'indent', 'deepIndent'],
		_wrappingIndentFromString,
		{
			enumDescriptions: [
				nls.localize('wrappingIndent.none', "No indentation. Wrapped lines begin at column 1."),
				nls.localize('wrappingIndent.same', "Wrapped lines get the same indentation as the parent."),
				nls.localize('wrappingIndent.indent', "Wrapped lines get +1 indentation toward the parent."),
				nls.localize('wrappingIndent.deepIndent', "Wrapped lines get +2 indentation toward the parent."),
			],
			description: nls.localize('wrappingIndent', "Controls the indentation of wrapped lines."),
		}
	)),
4364 4365 4366 4367
	wrappingStrategy: register(new EditorStringEnumOption(
		EditorOption.wrappingStrategy, 'wrappingStrategy',
		'simple' as 'simple' | 'advanced',
		['simple', 'advanced'] as const,
4368 4369
		{
			enumDescriptions: [
4370 4371
				nls.localize('wrappingStrategy.simple', "Assumes that all characters are of the same width. This is a fast algorithm that works correctly for monospace fonts and certain scripts (like Latin characters) where glyphs are of equal width."),
				nls.localize('wrappingStrategy.advanced', "Delegates wrapping points computation to the browser. This is a slow algorithm, that might cause freezes for large files, but it works correctly in all cases.")
4372
			],
4373
			description: nls.localize('wrappingStrategy', "Controls the algorithm that computes wrapping points.")
4374 4375
		}
	)),
A
Alex Dima 已提交
4376

A
Alex Dima 已提交
4377
	// Leave these at the end (because they have dependencies!)
4378 4379
	editorClassName: register(new EditorClassName()),
	pixelRatio: register(new EditorPixelRatio()),
A
Alex Dima 已提交
4380
	tabFocusMode: register(new EditorTabFocusMode()),
4381
	layoutInfo: register(new EditorLayoutInfoComputer()),
4382
	wrappingInfo: register(new EditorWrappingInfoComputer())
4383
};
A
Alex Dima 已提交
4384

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