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

6 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 EditorAutoClosingEditStrategy = '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
	/**
	 * 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.
M
Matt Bierner 已提交
78
	 * Otherwise, if it is a truthy, line numbers will be rendered normally (equivalent of using an identity function).
79
	 * 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
	 * Should the editor be read only. See also `domReadOnly`.
143 144 145
	 * Defaults to false.
	 */
	readOnly?: boolean;
146 147 148 149 150
	/**
	 * Should the textarea used for input use the DOM `readonly` attribute.
	 * Defaults to false.
	 */
	domReadOnly?: boolean;
P
Rename  
Pine Wu 已提交
151
	/**
152
	 * Enable linked editing.
P
Rename  
Pine Wu 已提交
153 154
	 * Defaults to false.
	 */
155 156 157 158
	linkedEditing?: boolean;
	/**
	 * deprecated, use linkedEditing instead
	 */
P
Rename  
Pine Wu 已提交
159
	renameOnType?: boolean;
160 161 162 163 164
	/**
	 * Should the editor render validation decorations.
	 * Defaults to editable.
	 */
	renderValidationDecorations?: 'editable' | 'on' | 'off';
165 166 167 168 169 170 171 172
	/**
	 * Control the behavior and rendering of the scrollbars.
	 */
	scrollbar?: IEditorScrollbarOptions;
	/**
	 * Control the behavior and rendering of the minimap.
	 */
	minimap?: IEditorMinimapOptions;
173 174 175 176
	/**
	 * Control the behavior of the find widget.
	 */
	find?: IEditorFindOptions;
177 178 179 180 181 182 183
	/**
	 * Display overflow widgets as `fixed`.
	 * Defaults to `false`.
	 */
	fixedOverflowWidgets?: boolean;
	/**
	 * The number of vertical lanes the overview ruler should render.
184
	 * Defaults to 3.
185 186 187 188 189 190 191 192 193 194 195
	 */
	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 已提交
196
	cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
197 198 199 200 201 202 203 204 205 206
	/**
	 * 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';
207 208 209 210 211
	/**
	 * Enable smooth caret animation.
	 * Defaults to false.
	 */
	cursorSmoothCaretAnimation?: boolean;
212 213 214 215
	/**
	 * Control the cursor style, either 'block' or 'line'.
	 * Defaults to 'line'.
	 */
A
Alex Dima 已提交
216
	cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
217 218 219
	/**
	 * Control the width of the cursor when cursorStyle is set to 'line'
	 */
220
	cursorWidth?: number;
221 222 223 224
	/**
	 * Enable font ligatures.
	 * Defaults to false.
	 */
225
	fontLigatures?: boolean | string;
226
	/**
227 228
	 * 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.
229 230
	 * Defaults to false.
	 */
231
	disableLayerHinting?: boolean;
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
	/**
	 * 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;
247 248 249 250 251
	/**
	 * Enable that scrolling can go beyond the last column by a number of columns.
	 * Defaults to 5.
	 */
	scrollBeyondLastColumn?: number;
252 253
	/**
	 * Enable that the editor animates scrolling to a position.
254
	 * Defaults to false.
255 256
	 */
	smoothScrolling?: boolean;
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
	/**
	 * 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';
272 273 274 275 276 277 278 279
	/**
	 * Override the `wordWrap` setting.
	 */
	wordWrapOverride1?: 'off' | 'on' | 'inherit';
	/**
	 * Override the `wordWrapOverride1` setting.
	 */
	wordWrapOverride2?: 'off' | 'on' | 'inherit';
280 281 282 283 284 285 286 287 288 289
	/**
	 * 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;
	/**
290
	 * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
291 292
	 * Defaults to 'same' in vscode and to 'none' in monaco-editor.
	 */
A
Alex Dima 已提交
293
	wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
294
	/**
295 296
	 * Controls the wrapping strategy to use.
	 * Defaults to 'simple'.
297
	 */
298
	wrappingStrategy?: 'simple' | 'advanced';
299 300
	/**
	 * Configure word wrapping characters. A break will be introduced before these characters.
301
	 * Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
302 303 304 305
	 */
	wordWrapBreakBeforeCharacters?: string;
	/**
	 * Configure word wrapping characters. A break will be introduced after these characters.
306
	 * Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
307 308 309 310 311 312 313 314 315
	 */
	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 已提交
316
	 * Configure the editor's hover.
317
	 */
A
Alex Dima 已提交
318
	hover?: IEditorHoverOptions;
319 320 321 322 323
	/**
	 * Enable detecting links and making them clickable.
	 * Defaults to true.
	 */
	links?: boolean;
324
	/**
325
	 * Enable inline color decorators and color picker rendering.
326
	 */
R
rebornix 已提交
327
	colorDecorators?: boolean;
A
Alex Dima 已提交
328 329 330 331
	/**
	 * Control the behaviour of comments in the editor.
	 */
	comments?: IEditorCommentsOptions;
332 333 334 335 336 337 338 339 340 341
	/**
	 * 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 已提交
342
	/**
343 344
	 * FastScrolling mulitplier speed when pressing `Alt`
	 * Defaults to 5.
T
Tiago Ribeiro 已提交
345 346
	 */
	fastScrollSensitivity?: number;
347 348 349 350
	/**
	 * Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad.
	 * Defaults to true.
	 */
351
	scrollPredominantAxis?: boolean;
352 353 354 355 356
	/**
	 * Enable that the selection with the mouse and keys is doing column selection.
	 * Defaults to false.
	 */
	columnSelection?: boolean;
357 358 359 360
	/**
	 * The modifier to be used to add multiple cursors with the mouse.
	 * Defaults to 'alt'
	 */
361
	multiCursorModifier?: 'ctrlCmd' | 'alt';
362
	/**
A
Alex Dima 已提交
363
	 * Merge overlapping selections.
364 365
	 * Defaults to true
	 */
A
Alex Dima 已提交
366
	multiCursorMergeOverlapping?: boolean;
367 368 369 370 371
	/**
	 * Configure the behaviour when pasting a text with the line count equal to the cursor count.
	 * Defaults to 'spread'.
	 */
	multiCursorPaste?: 'spread' | 'full';
372 373 374 375 376
	/**
	 * Configure the editor's accessibility support.
	 * Defaults to 'auto'. It is best to leave this to 'auto'.
	 */
	accessibilitySupport?: 'auto' | 'off' | 'on';
I
isidor 已提交
377 378 379
	/**
	 * Controls the number of lines in the editor that can be read out by a screen reader
	 */
I
isidor 已提交
380
	accessibilityPageSize?: number;
381 382 383 384
	/**
	 * Suggest options.
	 */
	suggest?: ISuggestOptions;
385
	inlineSuggest?: IInlineSuggestOptions;
386
	/**
A
Alex Dima 已提交
387
	 * Smart select options.
388 389
	 */
	smartSelect?: ISmartSelectOptions;
390 391 392 393
	/**
	 *
	 */
	gotoLocation?: IGotoLocationOptions;
394 395 396 397
	/**
	 * Enable quick suggestions (shadow suggestions)
	 * Defaults to true.
	 */
A
Alex Dima 已提交
398
	quickSuggestions?: boolean | IQuickSuggestionsOptions;
399 400
	/**
	 * Quick suggestions show delay (in ms)
A
Alex Dima 已提交
401
	 * Defaults to 10 (ms)
402 403
	 */
	quickSuggestionsDelay?: number;
B
Bailey 已提交
404
	/**
B
Bailey 已提交
405
	 * Controls the spacing around the editor.
B
Bailey 已提交
406
	 */
B
Bailey 已提交
407
	padding?: IEditorPaddingOptions;
408
	/**
409
	 * Parameter hint options.
410
	 */
411
	parameterHints?: IEditorParameterHintOptions;
412
	/**
413
	 * Options for auto closing brackets.
414
	 * Defaults to language defined behavior.
415
	 */
J
Jackson Kearl 已提交
416
	autoClosingBrackets?: EditorAutoClosingStrategy;
417
	/**
418
	 * Options for auto closing quotes.
419
	 * Defaults to language defined behavior.
J
Jackson Kearl 已提交
420 421
	 */
	autoClosingQuotes?: EditorAutoClosingStrategy;
422 423 424 425
	/**
	 * Options for pressing backspace near quotes or bracket pairs.
	 */
	autoClosingDelete?: EditorAutoClosingEditStrategy;
426 427 428
	/**
	 * Options for typing over closing quotes or brackets.
	 */
429
	autoClosingOvertype?: EditorAutoClosingEditStrategy;
J
Jackson Kearl 已提交
430
	/**
431 432
	 * Options for auto surrounding.
	 * Defaults to always allowing auto surrounding.
433
	 */
434
	autoSurround?: EditorAutoSurroundStrategy;
435
	/**
R
rebornix 已提交
436 437
	 * Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.
	 * Defaults to advanced.
438
	 */
A
wip  
Alexandru Dima 已提交
439
	autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
440
	/**
441 442
	 * Emulate selection behaviour of tab characters when using spaces for indentation.
	 * This means selection will stick to tab stops.
443
	 */
444
	stickyTabStops?: boolean;
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
	/**
	 * 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.
467
	 * Defaults to 'on'.
468
	 */
A
Alex Dima 已提交
469
	acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
470 471 472 473 474 475 476 477 478 479 480 481 482
	/**
	 * 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;
483
	/**
484
	 * Syntax highlighting is copied.
485
	 */
486
	copyWithSyntaxHighlighting?: boolean;
487 488 489
	/**
	 * The history mode for suggestions.
	 */
M
Martin Aeschlimann 已提交
490
	suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
491 492 493 494 495 496 497 498 499 500
	/**
	 * 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;
501 502 503
	/**
	 * Enable tab completion.
	 */
A
Alex Dima 已提交
504
	tabCompletion?: 'on' | 'off' | 'onlySnippets';
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
	/**
	 * 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;
520 521 522 523 524 525 526 527
	/**
	 * Code lens font family. Defaults to editor font family.
	 */
	codeLensFontFamily?: string;
	/**
	 * Code lens font size. Default to 90% of the editor font size
	 */
	codeLensFontSize?: number;
528 529 530 531
	/**
	 * Control the behavior and rendering of the code action lightbulb.
	 */
	lightbulb?: IEditorLightbulbOptions;
532 533 534 535
	/**
	 * Timeout for running code actions on save.
	 */
	codeActionsOnSaveTimeout?: number;
536
	/**
537
	 * Enable code folding.
A
Alex Dima 已提交
538
	 * Defaults to true.
539 540
	 */
	folding?: boolean;
541 542 543 544 545
	/**
	 * 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';
546 547 548 549 550
	/**
	 * Enable highlight for folded regions.
	 * Defaults to true.
	 */
	foldingHighlight?: boolean;
W
Wenlu Wang 已提交
551 552 553 554 555
	/**
	 * Auto fold imports folding regions.
	 * Defaults to true.
	 */
	foldingImportsByDefault?: boolean;
556
	/**
557 558
	 * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
	 * Defaults to 'mouseover'.
559
	 */
560
	showFoldingControls?: 'always' | 'mouseover';
561 562 563 564
	/**
	 * Controls whether clicking on the empty content after a folded line will unfold the line.
	 * Defaults to false.
	 */
565
	unfoldOnClickAfterEndOfLine?: boolean;
566 567
	/**
	 * Enable highlighting of matching brackets.
568
	 * Defaults to 'always'.
569
	 */
570
	matchBrackets?: 'never' | 'near' | 'always';
571 572
	/**
	 * Enable rendering of whitespace.
573
	 * Defaults to 'selection'.
574
	 */
575
	renderWhitespace?: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
576 577 578 579 580 581 582 583 584 585
	/**
	 * Enable rendering of control characters.
	 * Defaults to false.
	 */
	renderControlCharacters?: boolean;
	/**
	 * Enable rendering of current line highlight.
	 * Defaults to all.
	 */
	renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
586 587 588 589 590
	/**
	 * Control if the current line highlight should be rendered only the editor is focused.
	 * Defaults to false.
	 */
	renderLineHighlightOnlyWhenFocus?: boolean;
591 592 593 594 595 596 597 598 599 600 601
	/**
	 * Inserting and deleting whitespace follows tab stops.
	 */
	useTabStops?: boolean;
	/**
	 * The font family
	 */
	fontFamily?: string;
	/**
	 * The font weight
	 */
602
	fontWeight?: string;
603 604 605 606 607 608 609 610
	/**
	 * The font size
	 */
	fontSize?: number;
	/**
	 * The line height
	 */
	lineHeight?: number;
611 612 613 614
	/**
	 * The letter spacing
	 */
	letterSpacing?: number;
615 616 617 618
	/**
	 * Controls fading out of unused variables.
	 */
	showUnused?: boolean;
619 620 621 622
	/**
	 * Controls whether to focus the inline editor in the peek widget by default.
	 * Defaults to false.
	 */
623
	peekWidgetDefaultFocus?: 'tree' | 'editor';
624
	/**
625
	 * Controls whether the definition link opens element in the peek widget.
626 627
	 * Defaults to false.
	 */
628
	definitionLinkOpensInPeek?: boolean;
629
	/**
630
	 * Controls strikethrough deprecated variables.
631
	 */
632
	showDeprecated?: boolean;
K
kingwl 已提交
633
	/**
K
kingwl 已提交
634
	 * Control the behavior and rendering of the inline hints.
K
kingwl 已提交
635
	 */
636
	inlayHints?: IEditorInlayHintsOptions;
637 638 639 640
	/**
	 * Control if the editor should use shadow DOM.
	 */
	useShadowDOM?: boolean;
H
Henning Dieterichs 已提交
641 642 643 644
	/**
	 * Controls the behavior of editor guides.
	*/
	guides?: IGuidesOptions;
645 646
}

647 648 649 650 651 652
/**
 * @internal
 * The width of the minimap gutter, in pixels.
 */
export const MINIMAP_GUTTER_WIDTH = 8;

653
export interface IDiffEditorBaseOptions {
654 655 656 657 658 659 660 661 662 663
	/**
	 * 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;
664 665 666 667
	/**
	 * Timeout in milliseconds after which diff computation is cancelled.
	 * Defaults to 5000.
	 */
668
	maxComputationTime?: number;
669 670 671 672 673
	/**
	 * Maximum supported file size in MB.
	 * Defaults to 50.
	 */
	maxFileSize?: number;
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
	/**
	 * 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;
689
	/**
690
	 * Should the diff editor enable code lens?
691 692
	 * Defaults to false.
	 */
693
	diffCodeLens?: boolean;
R
rebornix 已提交
694 695 696 697 698
	/**
	 * Is the diff editor should render overview ruler
	 * Defaults to true
	 */
	renderOverviewRuler?: boolean;
699 700
	/**
	 * Control the wrapping of the diff editor.
701
	 */
702
	diffWordWrap?: 'off' | 'on' | 'inherit';
703 704
}

705 706 707 708 709 710 711 712 713 714 715
/**
 * Configuration options for the diff editor.
 */
export interface IDiffEditorOptions extends IEditorOptions, IDiffEditorBaseOptions {
}

/**
 * @internal
 */
export type ValidDiffEditorBaseOptions = Readonly<Required<IDiffEditorBaseOptions>>;

A
Alex Dima 已提交
716
//#endregion
717 718

/**
719
 * An event describing that the configuration of the editor has changed.
720
 */
721 722
export class ConfigurationChangedEvent {
	private readonly _values: boolean[];
723 724 725
	/**
	 * @internal
	 */
726 727
	constructor(values: boolean[]) {
		this._values = values;
728
	}
729 730
	public hasChanged(id: EditorOption): boolean {
		return this._values[id];
731 732 733 734
	}
}

/**
735
 * @internal
736
 */
737 738
export class ValidatedEditorOptions {
	private readonly _values: any[] = [];
A
renames  
Alex Dima 已提交
739
	public _read<T>(option: EditorOption): T {
740 741
		return this._values[option];
	}
A
Alex Dima 已提交
742 743 744
	public get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
		return this._values[id];
	}
A
renames  
Alex Dima 已提交
745
	public _write<T>(option: EditorOption, value: T): void {
746 747
		this._values[option] = value;
	}
748
}
749

750
/**
751
 * All computed editor options.
752
 */
A
Alex Dima 已提交
753
export interface IComputedEditorOptions {
A
renames  
Alex Dima 已提交
754
	get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
755
}
756

A
Alex Dima 已提交
757 758
//#region IEditorOption

759
/**
A
Alex Dima 已提交
760
 * @internal
761
 */
A
Alex Dima 已提交
762
export interface IEnvironmentalOptions {
763
	readonly memory: ComputeOptionsMemory | null;
A
Alex Dima 已提交
764 765 766 767 768
	readonly outerWidth: number;
	readonly outerHeight: number;
	readonly fontInfo: FontInfo;
	readonly extraEditorClassName: string;
	readonly isDominatedByLongLines: boolean;
769
	readonly viewLineCount: number;
A
Alex Dima 已提交
770 771 772 773 774 775 776
	readonly lineNumbersDigitCount: number;
	readonly emptySelectionClipboard: boolean;
	readonly pixelRatio: number;
	readonly tabFocusMode: boolean;
	readonly accessibilitySupport: AccessibilitySupport;
}

777 778 779
/**
 * @internal
 */
780 781
export class ComputeOptionsMemory {

A
Alex Dima 已提交
782 783 784
	public stableMinimapLayoutInput: IMinimapLayoutInput | null;
	public stableFitMaxMinimapScale: number;
	public stableFitRemainingWidth: number;
785 786

	constructor() {
A
Alex Dima 已提交
787 788 789
		this.stableMinimapLayoutInput = null;
		this.stableFitMaxMinimapScale = 0;
		this.stableFitRemainingWidth = 0;
790
	}
791 792
}

A
Alex Dima 已提交
793 794 795
export interface IEditorOption<K1 extends EditorOption, V> {
	readonly id: K1;
	readonly name: string;
796
	defaultValue: V;
797
	/**
798
	 * @internal
799
	 */
800
	readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; } | undefined;
801
	/**
A
Alex Dima 已提交
802
	 * @internal
803
	 */
A
Alex Dima 已提交
804
	validate(input: any): V;
805
	/**
A
Alex Dima 已提交
806
	 * @internal
807
	 */
A
Alex Dima 已提交
808 809 810
	compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
}

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

814 815 816
/**
 * @internal
 */
817
abstract class BaseEditorOption<K1 extends EditorOption, V> implements IEditorOption<K1, V> {
A
Alex Dima 已提交
818 819

	public readonly id: K1;
820
	public readonly name: string;
A
Alex Dima 已提交
821
	public readonly defaultValue: V;
822
	public readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; } | undefined;
A
Alex Dima 已提交
823

824
	constructor(id: K1, name: string, defaultValue: V, schema?: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema; }) {
A
Alex Dima 已提交
825 826 827
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
828
		this.schema = schema;
A
Alex Dima 已提交
829 830 831 832 833 834 835
	}

	public abstract validate(input: any): V;

	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
	}
836 837 838 839 840
}

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

843
	public readonly id: K1;
A
Alex Dima 已提交
844 845 846
	public readonly name: '_never_';
	public readonly defaultValue: V;
	public readonly deps: EditorOption[] | null;
847
	public readonly schema: IConfigurationPropertySchema | undefined = undefined;
A
Alex Dima 已提交
848 849 850 851 852 853

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

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

A
Alex Dima 已提交
860
	public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
861 862
}

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

A
Alex Dima 已提交
865 866 867
	public readonly id: K1;
	public readonly name: PossibleKeyName<V>;
	public readonly defaultValue: V;
868
	public readonly schema: IConfigurationPropertySchema | undefined;
A
Alex Dima 已提交
869

870
	constructor(id: K1, name: PossibleKeyName<V>, defaultValue: V, schema?: IConfigurationPropertySchema) {
871 872 873
		this.id = id;
		this.name = name;
		this.defaultValue = defaultValue;
874
		this.schema = schema;
A
Alex Dima 已提交
875
	}
876

A
Alex Dima 已提交
877 878 879
	public validate(input: any): V {
		if (typeof input === 'undefined') {
			return this.defaultValue;
A
Alex Dima 已提交
880
		}
A
Alex Dima 已提交
881 882
		return input as any;
	}
883

A
Alex Dima 已提交
884 885
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
		return value;
886
	}
887 888
}

889 890 891 892 893 894
/**
 * @internal
 */
export function boolean(value: any, defaultValue: boolean): boolean {
	if (typeof value === 'undefined') {
		return defaultValue;
A
Alex Dima 已提交
895
	}
896 897 898 899 900 901 902 903
	if (value === 'false') {
		// treat the string 'false' as false
		return false;
	}
	return Boolean(value);
}

class EditorBooleanOption<K1 extends EditorOption> extends SimpleEditorOption<K1, boolean> {
904

905
	constructor(id: K1, name: PossibleKeyName<boolean>, defaultValue: boolean, schema: IConfigurationPropertySchema | undefined = undefined) {
906 907 908 909
		if (typeof schema !== 'undefined') {
			schema.type = 'boolean';
			schema.default = defaultValue;
		}
910
		super(id, name, defaultValue, schema);
911
	}
912

913
	public override validate(input: any): boolean {
914
		return boolean(input, this.defaultValue);
915
	}
916 917
}

918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
/**
 * @internal
 */
export function clampedInt<T>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
	if (typeof value === 'undefined') {
		return defaultValue;
	}
	let r = parseInt(value, 10);
	if (isNaN(r)) {
		return defaultValue;
	}
	r = Math.max(minimum, r);
	r = Math.min(maximum, r);
	return r | 0;
}

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

A
Alex Dima 已提交
936
	public static clampedInt<T>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
937
		return clampedInt(value, defaultValue, minimum, maximum);
A
Alex Dima 已提交
938
	}
A
Alex Dima 已提交
939

A
Alex Dima 已提交
940 941
	public readonly minimum: number;
	public readonly maximum: number;
942

943 944 945 946 947 948 949 950
	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 已提交
951 952
		this.minimum = minimum;
		this.maximum = maximum;
953 954
	}

955
	public override validate(input: any): number {
A
Alex Dima 已提交
956
		return EditorIntOption.clampedInt(input, this.defaultValue, this.minimum, this.maximum);
957
	}
A
Alex Dima 已提交
958
}
959

A
Alex Dima 已提交
960
class EditorFloatOption<K1 extends EditorOption> extends SimpleEditorOption<K1, number> {
A
Alex Dima 已提交
961 962 963 964 965 966 967 968 969

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

A
Alex Dima 已提交
972 973 974 975 976 977 978 979 980
	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 已提交
981
	}
982

A
Alex Dima 已提交
983
	public readonly validationFn: (value: number) => number;
984 985 986 987 988 989 990

	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 已提交
991
		this.validationFn = validationFn;
A
Alex Dima 已提交
992 993
	}

994
	public override validate(input: any): number {
A
Alex Dima 已提交
995
		return this.validationFn(EditorFloatOption.float(input, this.defaultValue));
A
Alex Dima 已提交
996
	}
997
}
A
Alex Dima 已提交
998

A
Alex Dima 已提交
999
class EditorStringOption<K1 extends EditorOption> extends SimpleEditorOption<K1, string> {
A
Alex Dima 已提交
1000 1001 1002 1003 1004 1005

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

1008 1009 1010 1011 1012 1013
	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 已提交
1014 1015
	}

1016
	public override validate(input: any): string {
A
Alex Dima 已提交
1017
		return EditorStringOption.string(input, this.defaultValue);
1018
	}
A
Alex Dima 已提交
1019
}
1020

1021 1022 1023 1024 1025 1026
/**
 * @internal
 */
export function stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: ReadonlyArray<T>): T {
	if (typeof value !== 'string') {
		return defaultValue;
1027
	}
1028 1029
	if (allowedValues.indexOf(value) === -1) {
		return defaultValue;
1030
	}
1031 1032 1033 1034
	return value;
}

class EditorStringEnumOption<K1 extends EditorOption, V extends string> extends SimpleEditorOption<K1, V> {
1035

1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
	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 已提交
1046 1047
	}

1048
	public override validate(input: any): V {
1049
		return stringSet<V>(input, this.defaultValue, this._allowedValues);
A
Alex Dima 已提交
1050 1051 1052
	}
}

1053 1054 1055 1056 1057 1058 1059 1060 1061
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;
1062
			schema.default = defaultStringValue;
1063
		}
1064 1065 1066
		super(id, name, defaultValue, schema);
		this._allowedValues = allowedValues;
		this._convert = convert;
1067 1068
	}

A
Alex Dima 已提交
1069 1070
	public validate(input: any): V {
		if (typeof input !== 'string') {
A
Alex Dima 已提交
1071 1072
			return this.defaultValue;
		}
1073
		if (this._allowedValues.indexOf(<T>input) === -1) {
A
Alex Dima 已提交
1074 1075
			return this.defaultValue;
		}
1076
		return this._convert(<any>input);
1077
	}
A
Alex Dima 已提交
1078
}
1079

A
Alex Dima 已提交
1080
//#endregion
A
Alex Dima 已提交
1081

A
wip  
Alexandru Dima 已提交
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095
//#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 已提交
1096 1097
//#region accessibilitySupport

1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
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 已提交
1108
					nls.localize('accessibilitySupport.on', "The editor will be permanently optimized for usage with a Screen Reader. Word wrapping will be disabled."),
1109 1110 1111
					nls.localize('accessibilitySupport.off', "The editor will never be optimized for usage with a Screen Reader."),
				],
				default: 'auto',
A
Alex Dima 已提交
1112
				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.")
1113
			}
A
Alex Dima 已提交
1114 1115 1116
		);
	}

A
Alex Dima 已提交
1117 1118 1119 1120 1121
	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 已提交
1122
		}
A
Alex Dima 已提交
1123
		return this.defaultValue;
A
Alex Dima 已提交
1124
	}
1125

1126
	public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: AccessibilitySupport): AccessibilitySupport {
A
Alex Dima 已提交
1127
		if (value === AccessibilitySupport.Unknown) {
A
Alex Dima 已提交
1128 1129
			// The editor reads the `accessibilitySupport` from the environment
			return env.accessibilitySupport;
A
Alex Dima 已提交
1130
		}
A
Alex Dima 已提交
1131
		return value;
1132 1133 1134
	}
}

A
Alex Dima 已提交
1135 1136
//#endregion

A
Alex Dima 已提交
1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
//#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;
1148
	/**
1149 1150
	 * Ignore empty lines when inserting line comments.
	 * Defaults to true.
1151
	 */
1152
	ignoreEmptyLines?: boolean;
A
Alex Dima 已提交
1153 1154
}

1155 1156 1157
/**
 * @internal
 */
A
Alex Dima 已提交
1158 1159 1160 1161 1162 1163 1164
export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;

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

	constructor() {
		const defaults: EditorCommentsOptions = {
			insertSpace: true,
1165
			ignoreEmptyLines: true,
A
Alex Dima 已提交
1166 1167 1168 1169 1170 1171 1172 1173 1174
		};
		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.")
				},
1175
				'editor.comments.ignoreEmptyLines': {
1176
					type: 'boolean',
1177 1178
					default: defaults.ignoreEmptyLines,
					description: nls.localize('comments.ignoreEmptyLines', 'Controls if empty lines should be ignored with toggle, add or remove actions for line comments.')
1179
				},
A
Alex Dima 已提交
1180 1181 1182 1183 1184
			}
		);
	}

	public validate(_input: any): EditorCommentsOptions {
A
Alex Dima 已提交
1185
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1186 1187 1188 1189
			return this.defaultValue;
		}
		const input = _input as IEditorCommentsOptions;
		return {
1190 1191
			insertSpace: boolean(input.insertSpace, this.defaultValue.insertSpace),
			ignoreEmptyLines: boolean(input.ignoreEmptyLines, this.defaultValue.ignoreEmptyLines),
A
Alex Dima 已提交
1192 1193 1194 1195 1196 1197
		};
	}
}

//#endregion

1198
//#region cursorBlinking
A
Alex Dima 已提交
1199

A
Alex Dima 已提交
1200
/**
A
Alex Dima 已提交
1201
 * The kind of animation in which the editor's cursor should be rendered.
A
Alex Dima 已提交
1202
 */
A
Alex Dima 已提交
1203
export const enum TextEditorCursorBlinkingStyle {
A
Alex Dima 已提交
1204
	/**
A
Alex Dima 已提交
1205
	 * Hidden
A
Alex Dima 已提交
1206
	 */
A
Alex Dima 已提交
1207
	Hidden = 0,
A
Alex Dima 已提交
1208
	/**
A
Alex Dima 已提交
1209
	 * Blinking
A
Alex Dima 已提交
1210
	 */
A
Alex Dima 已提交
1211
	Blink = 1,
A
Alex Dima 已提交
1212
	/**
A
Alex Dima 已提交
1213
	 * Blinking with smooth fading
A
Alex Dima 已提交
1214
	 */
A
Alex Dima 已提交
1215
	Smooth = 2,
A
Alex Dima 已提交
1216
	/**
A
Alex Dima 已提交
1217
	 * Blinking with prolonged filled state and smooth fading
A
Alex Dima 已提交
1218
	 */
A
Alex Dima 已提交
1219
	Phase = 3,
1220
	/**
A
Alex Dima 已提交
1221
	 * Expand collapse animation on the y axis
1222
	 */
A
Alex Dima 已提交
1223
	Expand = 4,
1224
	/**
A
Alex Dima 已提交
1225
	 * No-Blinking
1226
	 */
A
Alex Dima 已提交
1227 1228
	Solid = 5
}
1229

A
Alex Dima 已提交
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
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

1301
//#region editorClassName
A
Alex Dima 已提交
1302

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

1305
	constructor() {
1306
		super(EditorOption.editorClassName, [EditorOption.mouseStyle, EditorOption.extraEditorClassName]);
1307
	}
A
Alex Dima 已提交
1308

A
Alex Dima 已提交
1309
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string {
1310
		const classNames = ['monaco-editor'];
A
Alex Dima 已提交
1311
		if (options.get(EditorOption.extraEditorClassName)) {
1312
			classNames.push(options.get(EditorOption.extraEditorClassName));
A
Alex Dima 已提交
1313 1314
		}
		if (env.extraEditorClassName) {
1315
			classNames.push(env.extraEditorClassName);
A
Alex Dima 已提交
1316 1317
		}
		if (options.get(EditorOption.mouseStyle) === 'default') {
1318
			classNames.push('mouse-default');
A
Alex Dima 已提交
1319
		} else if (options.get(EditorOption.mouseStyle) === 'copy') {
1320
			classNames.push('mouse-copy');
A
Alex Dima 已提交
1321
		}
1322

1323
		if (options.get(EditorOption.showUnused)) {
1324
			classNames.push('showUnused');
1325
		}
1326 1327

		if (options.get(EditorOption.showDeprecated)) {
1328
			classNames.push('showDeprecated');
1329
		}
1330 1331

		return classNames.join(' ');
A
Alex Dima 已提交
1332 1333 1334 1335 1336
	}
}

//#endregion

A
Alex Dima 已提交
1337
//#region emptySelectionClipboard
1338

1339 1340 1341 1342 1343 1344 1345 1346 1347
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.") }
		);
	}

1348
	public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
A
Alex Dima 已提交
1349
		return value && env.emptySelectionClipboard;
1350 1351 1352 1353 1354
	}
}

//#endregion

A
Alex Dima 已提交
1355
//#region find
A
Alex Dima 已提交
1356

1357 1358 1359 1360
/**
 * Configuration options for editor find widget
 */
export interface IEditorFindOptions {
T
Ted Goldman 已提交
1361 1362 1363
	/**
	* Controls whether the cursor should move to find matches while typing.
	*/
R
rebornix 已提交
1364
	cursorMoveOnType?: boolean;
1365 1366 1367
	/**
	 * Controls if we seed search string in the Find Widget with editor selection.
	 */
1368
	seedSearchStringFromSelection?: 'never' | 'always' | 'selection';
1369
	/**
P
Peng Lyu 已提交
1370
	 * Controls if Find in Selection flag is turned on in the editor.
1371
	 */
P
Peng Lyu 已提交
1372
	autoFindInSelection?: 'never' | 'always' | 'multiline';
1373 1374 1375 1376 1377 1378 1379 1380 1381
	/*
	 * 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;
1382 1383 1384 1385
	/**
	 * Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found
	 */
	loop?: boolean;
1386 1387
}

1388 1389 1390
/**
 * @internal
 */
A
Alex Dima 已提交
1391
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
A
Alex Dima 已提交
1392

1393 1394 1395 1396
class EditorFind extends BaseEditorOption<EditorOption.find, EditorFindOptions> {

	constructor() {
		const defaults: EditorFindOptions = {
R
rebornix 已提交
1397
			cursorMoveOnType: true,
1398
			seedSearchStringFromSelection: 'always',
P
Peng Lyu 已提交
1399
			autoFindInSelection: 'never',
1400
			globalFindClipboard: false,
1401 1402
			addExtraSpaceOnTop: true,
			loop: true
1403 1404 1405 1406
		};
		super(
			EditorOption.find, 'find', defaults,
			{
R
rebornix 已提交
1407
				'editor.find.cursorMoveOnType': {
T
Ted Goldman 已提交
1408
					type: 'boolean',
R
rebornix 已提交
1409 1410
					default: defaults.cursorMoveOnType,
					description: nls.localize('find.cursorMoveOnType', "Controls whether the cursor should jump to find matches while typing.")
T
Ted Goldman 已提交
1411
				},
1412
				'editor.find.seedSearchStringFromSelection': {
1413 1414
					type: 'string',
					enum: ['never', 'always', 'selection'],
1415
					default: defaults.seedSearchStringFromSelection,
1416 1417 1418 1419 1420
					enumDescriptions: [
						nls.localize('editor.find.seedSearchStringFromSelection.never', 'Never seed search string from the editor selection.'),
						nls.localize('editor.find.seedSearchStringFromSelection.always', 'Always seed search string from the editor selection, including word at cursor position.'),
						nls.localize('editor.find.seedSearchStringFromSelection.selection', 'Only seed search string from the editor selection.')
					],
1421 1422 1423
					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 已提交
1424 1425
					type: 'string',
					enum: ['never', 'always', 'multiline'],
1426
					default: defaults.autoFindInSelection,
P
Peng Lyu 已提交
1427
					enumDescriptions: [
1428 1429 1430
						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.')
P
Peng Lyu 已提交
1431
					],
1432
					description: nls.localize('find.autoFindInSelection', "Controls the condition for turning on Find in Selection automatically.")
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
				},
				'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.")
1444 1445 1446 1447 1448 1449 1450
				},
				'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.")
				},

1451 1452 1453 1454
			}
		);
	}

A
Alex Dima 已提交
1455
	public validate(_input: any): EditorFindOptions {
A
Alex Dima 已提交
1456
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1457 1458 1459 1460
			return this.defaultValue;
		}
		const input = _input as IEditorFindOptions;
		return {
1461
			cursorMoveOnType: boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
1462 1463 1464
			seedSearchStringFromSelection: typeof _input.seedSearchStringFromSelection === 'boolean'
				? (_input.seedSearchStringFromSelection ? 'always' : 'never')
				: stringSet<'never' | 'always' | 'selection'>(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection, ['never', 'always', 'selection']),
P
Peng Lyu 已提交
1465 1466
			autoFindInSelection: typeof _input.autoFindInSelection === 'boolean'
				? (_input.autoFindInSelection ? 'always' : 'never')
1467
				: stringSet<'never' | 'always' | 'multiline'>(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ['never', 'always', 'multiline']),
1468 1469 1470
			globalFindClipboard: boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
			addExtraSpaceOnTop: boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop),
			loop: boolean(input.loop, this.defaultValue.loop),
A
Alex Dima 已提交
1471
		};
A
Alex Dima 已提交
1472 1473 1474 1475 1476
	}
}

//#endregion

1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
//#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',
J
Jade 已提交
1494
						description: nls.localize('fontLigatures', "Enables/Disables font ligatures ('calt' and 'liga' font features). Change this to a string for fine-grained control of the 'font-feature-settings' CSS property."),
1495 1496 1497
					},
					{
						type: 'string',
J
Jade 已提交
1498
						description: nls.localize('fontFeatureSettings', "Explicit 'font-feature-settings' CSS property. A boolean can be passed instead if one only needs to turn on/off ligatures.")
1499 1500
					}
				],
J
Jade 已提交
1501
				description: nls.localize('fontLigaturesGeneral', "Configures font ligatures or font features. Can be either a boolean to enable/disable ligatures or a string for the value of the CSS 'font-feature-settings' property."),
1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528
				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 已提交
1529
//#region fontInfo
A
Alex Dima 已提交
1530

1531 1532 1533 1534 1535 1536
class EditorFontInfo extends ComputedEditorOption<EditorOption.fontInfo, FontInfo> {

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

A
Alex Dima 已提交
1537 1538
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo {
		return env.fontInfo;
A
Alex Dima 已提交
1539 1540 1541 1542 1543
	}
}

//#endregion

A
Alex Dima 已提交
1544 1545
//#region fontSize

1546 1547 1548 1549 1550 1551 1552
class EditorFontSize extends SimpleEditorOption<EditorOption.fontSize, number> {

	constructor() {
		super(
			EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize,
			{
				type: 'number',
1553 1554
				minimum: 6,
				maximum: 100,
1555 1556 1557 1558 1559 1560
				default: EDITOR_FONT_DEFAULTS.fontSize,
				description: nls.localize('fontSize', "Controls the font size in pixels.")
			}
		);
	}

1561
	public override validate(input: any): number {
A
Alex Dima 已提交
1562
		let r = EditorFloatOption.float(input, this.defaultValue);
A
Alex Dima 已提交
1563 1564 1565
		if (r === 0) {
			return EDITOR_FONT_DEFAULTS.fontSize;
		}
1566
		return EditorFloatOption.clamp(r, 6, 100);
A
Alex Dima 已提交
1567
	}
1568
	public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
A
Alex Dima 已提交
1569 1570 1571
		// The final fontSize respects the editor zoom level.
		// So take the result from env.fontInfo
		return env.fontInfo.fontSize;
A
Alex Dima 已提交
1572 1573 1574 1575 1576
	}
}

//#endregion

1577 1578 1579
//#region fontWeight

class EditorFontWeight extends BaseEditorOption<EditorOption.fontWeight, string> {
1580
	private static SUGGESTION_VALUES = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
	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,
1592 1593
						maximum: EditorFontWeight.MAXIMUM_VALUE,
						errorMessage: nls.localize('fontWeightErrorMessage', "Only \"normal\" and \"bold\" keywords or numbers between 1 and 1000 are allowed.")
1594 1595
					},
					{
1596 1597
						type: 'string',
						pattern: '^(normal|bold|1000|[1-9][0-9]{0,2})$'
1598 1599
					},
					{
1600
						enum: EditorFontWeight.SUGGESTION_VALUES
1601 1602 1603
					}
				],
				default: EDITOR_FONT_DEFAULTS.fontWeight,
1604
				description: nls.localize('fontWeight', "Controls the font weight. Accepts \"normal\" and \"bold\" keywords or numbers between 1 and 1000.")
1605 1606 1607 1608 1609
			}
		);
	}

	public validate(input: any): string {
1610 1611
		if (input === 'normal' || input === 'bold') {
			return input;
1612
		}
A
Alex Dima 已提交
1613
		return String(EditorIntOption.clampedInt(input, EDITOR_FONT_DEFAULTS.fontWeight, EditorFontWeight.MINIMUM_VALUE, EditorFontWeight.MAXIMUM_VALUE));
1614 1615 1616 1617 1618
	}
}

//#endregion

A
Alex Dima 已提交
1619
//#region gotoLocation
A
Alex Dima 已提交
1620

1621 1622
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';

1623 1624 1625 1626
/**
 * Configuration options for go to location
 */
export interface IGotoLocationOptions {
1627

1628
	multiple?: GoToLocationValues;
1629

1630 1631 1632
	multipleDefinitions?: GoToLocationValues;
	multipleTypeDefinitions?: GoToLocationValues;
	multipleDeclarations?: GoToLocationValues;
R
rzj17 已提交
1633
	multipleImplementations?: GoToLocationValues;
1634
	multipleReferences?: GoToLocationValues;
1635 1636 1637 1638 1639 1640

	alternativeDefinitionCommand?: string;
	alternativeTypeDefinitionCommand?: string;
	alternativeDeclarationCommand?: string;
	alternativeImplementationCommand?: string;
	alternativeReferenceCommand?: string;
1641 1642
}

1643 1644 1645
/**
 * @internal
 */
A
Alex Dima 已提交
1646
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
A
Alex Dima 已提交
1647

1648 1649 1650
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, GoToLocationOptions> {

	constructor() {
1651 1652 1653 1654 1655
		const defaults: GoToLocationOptions = {
			multiple: 'peek',
			multipleDefinitions: 'peek',
			multipleTypeDefinitions: 'peek',
			multipleDeclarations: 'peek',
R
rzj17 已提交
1656
			multipleImplementations: 'peek',
1657
			multipleReferences: 'peek',
1658 1659 1660 1661 1662
			alternativeDefinitionCommand: 'editor.action.goToReferences',
			alternativeTypeDefinitionCommand: 'editor.action.goToReferences',
			alternativeDeclarationCommand: 'editor.action.goToReferences',
			alternativeImplementationCommand: '',
			alternativeReferenceCommand: '',
1663
		};
M
Matt Bierner 已提交
1664
		const jsonSubset: IJSONSchema = {
1665 1666 1667 1668 1669 1670 1671 1672 1673
			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')
			]
		};
1674
		const alternativeCommandOptions = ['', 'editor.action.referenceSearch.trigger', 'editor.action.goToReferences', 'editor.action.peekImplementation', 'editor.action.goToImplementation', 'editor.action.peekTypeDefinition', 'editor.action.goToTypeDefinition', 'editor.action.peekDeclaration', 'editor.action.revealDeclaration', 'editor.action.peekDefinition', 'editor.action.revealDefinitionAside', 'editor.action.revealDefinition'];
1675 1676 1677 1678
		super(
			EditorOption.gotoLocation, 'gotoLocation', defaults,
			{
				'editor.gotoLocation.multiple': {
R
rzj17 已提交
1679
					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."),
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692
				},
				'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 已提交
1693 1694
				'editor.gotoLocation.multipleImplementations': {
					description: nls.localize('editor.editor.gotoLocation.multipleImplemenattions', "Controls the behavior the 'Go to Implementations'-command when multiple target locations exist."),
1695 1696 1697 1698 1699
					...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,
1700
				},
1701
				'editor.gotoLocation.alternativeDefinitionCommand': {
1702
					type: 'string',
1703
					default: defaults.alternativeDefinitionCommand,
1704
					enum: alternativeCommandOptions,
1705 1706 1707 1708 1709
					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,
1710
					enum: alternativeCommandOptions,
1711 1712 1713 1714 1715
					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,
1716
					enum: alternativeCommandOptions,
1717 1718 1719 1720 1721
					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,
1722
					enum: alternativeCommandOptions,
1723 1724 1725 1726 1727
					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,
1728
					enum: alternativeCommandOptions,
1729
					description: nls.localize('alternativeReferenceCommand', "Alternative command id that is being executed when the result of 'Go to Reference' is the current location.")
1730 1731 1732 1733 1734
				},
			}
		);
	}

A
Alex Dima 已提交
1735
	public validate(_input: any): GoToLocationOptions {
A
Alex Dima 已提交
1736
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1737 1738
			return this.defaultValue;
		}
A
Alex Dima 已提交
1739
		const input = _input as IGotoLocationOptions;
A
Alex Dima 已提交
1740
		return {
1741 1742 1743 1744 1745 1746
			multiple: stringSet<GoToLocationValues>(input.multiple, this.defaultValue.multiple!, ['peek', 'gotoAndPeek', 'goto']),
			multipleDefinitions: input.multipleDefinitions ?? stringSet<GoToLocationValues>(input.multipleDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleTypeDefinitions: input.multipleTypeDefinitions ?? stringSet<GoToLocationValues>(input.multipleTypeDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleDeclarations: input.multipleDeclarations ?? stringSet<GoToLocationValues>(input.multipleDeclarations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleImplementations: input.multipleImplementations ?? stringSet<GoToLocationValues>(input.multipleImplementations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
			multipleReferences: input.multipleReferences ?? stringSet<GoToLocationValues>(input.multipleReferences, 'peek', ['peek', 'gotoAndPeek', 'goto']),
1747 1748 1749 1750 1751
			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 已提交
1752 1753 1754 1755 1756 1757
		};
	}
}

//#endregion

A
Alex Dima 已提交
1758
//#region hover
A
Alex Dima 已提交
1759

1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778
/**
 * 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;
T
Tim Hutt 已提交
1779 1780 1781 1782 1783
	/**
	 * Should the hover be shown below the line if possible?
	 * Defaults to false.
	 */
	below?: boolean;
1784 1785
}

1786 1787 1788
/**
 * @internal
 */
A
Alex Dima 已提交
1789
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
A
Alex Dima 已提交
1790

1791 1792 1793 1794 1795 1796
class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOptions> {

	constructor() {
		const defaults: EditorHoverOptions = {
			enabled: true,
			delay: 300,
T
Tim Hutt 已提交
1797 1798
			sticky: true,
			below: false,
1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817
		};
		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.")
				},
T
Tim Hutt 已提交
1818 1819 1820 1821 1822
				'editor.hover.below': {
					type: 'boolean',
					default: defaults.below,
					description: nls.localize('hover.below', "Show hovers below the line instead of above, if there's space.")
				},
1823 1824 1825 1826
			}
		);
	}

A
Alex Dima 已提交
1827
	public validate(_input: any): EditorHoverOptions {
A
Alex Dima 已提交
1828
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
1829 1830
			return this.defaultValue;
		}
A
Alex Dima 已提交
1831
		const input = _input as IEditorHoverOptions;
A
Alex Dima 已提交
1832
		return {
1833
			enabled: boolean(input.enabled, this.defaultValue.enabled),
A
Alex Dima 已提交
1834
			delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
T
Tim Hutt 已提交
1835 1836
			sticky: boolean(input.sticky, this.defaultValue.sticky),
			below: boolean(input.below, this.defaultValue.below),
A
Alex Dima 已提交
1837 1838 1839 1840 1841 1842
		};
	}
}

//#endregion

A
Alex Dima 已提交
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
//#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 已提交
1867 1868
export const enum RenderMinimap {
	None = 0,
1869 1870
	Text = 1,
	Blocks = 2,
A
Alex Dima 已提交
1871 1872
}

A
Alex Dima 已提交
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890
/**
 * 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;
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922
	/**
	 * 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;

1923
	/**
A
Alex Dima 已提交
1924
	 * Layout information for the minimap
1925
	 */
A
Alex Dima 已提交
1926
	readonly minimap: EditorMinimapLayoutInfo;
1927 1928 1929 1930 1931 1932

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

1933 1934 1935 1936
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;

1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951
	/**
	 * 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 已提交
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968
/**
 * 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;
}

1969
/**
A
Alex Dima 已提交
1970
 * @internal
1971
 */
A
Alex Dima 已提交
1972
export interface EditorLayoutInfoComputerEnv {
1973
	readonly memory: ComputeOptionsMemory | null;
1974 1975
	readonly outerWidth: number;
	readonly outerHeight: number;
1976
	readonly isDominatedByLongLines: boolean;
1977 1978 1979 1980 1981 1982
	readonly lineHeight: number;
	readonly viewLineCount: number;
	readonly lineNumbersDigitCount: number;
	readonly typicalHalfwidthCharacterWidth: number;
	readonly maxDigitWidth: number;
	readonly pixelRatio: number;
1983
}
1984

1985 1986 1987 1988 1989 1990
/**
 * @internal
 */
export interface IEditorLayoutComputerInput {
	readonly outerWidth: number;
	readonly outerHeight: number;
1991
	readonly isDominatedByLongLines: boolean;
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
	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 已提交
2011 2012 2013 2014
/**
 * @internal
 */
export interface IMinimapLayoutInput {
A
Alex Dima 已提交
2015
	readonly outerWidth: number;
A
Alex Dima 已提交
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025
	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;
2026
}
2027 2028 2029 2030

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

2033 2034 2035
	constructor() {
		super(
			EditorOption.layoutInfo,
2036 2037 2038
			[
				EditorOption.glyphMargin, EditorOption.lineDecorationsWidth, EditorOption.folding,
				EditorOption.minimap, EditorOption.scrollbar, EditorOption.lineNumbers,
2039
				EditorOption.lineNumbersMinChars, EditorOption.scrollBeyondLastLine,
2040
				EditorOption.wordWrap, EditorOption.wordWrapColumn, EditorOption.wordWrapOverride1, EditorOption.wordWrapOverride2,
2041 2042
				EditorOption.accessibilitySupport
			]
2043
		);
2044
	}
2045

A
Alex Dima 已提交
2046
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorLayoutInfo): EditorLayoutInfo {
A
Alex Dima 已提交
2047
		return EditorLayoutInfoComputer.computeLayout(options, {
2048
			memory: env.memory,
A
Alex Dima 已提交
2049 2050
			outerWidth: env.outerWidth,
			outerHeight: env.outerHeight,
2051
			isDominatedByLongLines: env.isDominatedByLongLines,
A
Alex Dima 已提交
2052
			lineHeight: env.fontInfo.lineHeight,
2053
			viewLineCount: env.viewLineCount,
A
Alex Dima 已提交
2054 2055 2056 2057 2058
			lineNumbersDigitCount: env.lineNumbersDigitCount,
			typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
			maxDigitWidth: env.fontInfo.maxDigitWidth,
			pixelRatio: env.pixelRatio
		});
2059 2060
	}

A
Alex Dima 已提交
2061
	public static computeContainedMinimapLineCount(input: {
2062
		viewLineCount: number;
A
Alex Dima 已提交
2063 2064 2065 2066
		scrollBeyondLastLine: boolean;
		height: number;
		lineHeight: number;
		pixelRatio: number;
2067 2068 2069
	}): { typicalViewportLineCount: number; extraLinesBeyondLastLine: number; desiredRatio: number; minimapLineCount: number; } {
		const typicalViewportLineCount = input.height / input.lineHeight;
		const extraLinesBeyondLastLine = input.scrollBeyondLastLine ? (typicalViewportLineCount - 1) : 0;
2070 2071
		const desiredRatio = (input.viewLineCount + extraLinesBeyondLastLine) / (input.pixelRatio * input.height);
		const minimapLineCount = Math.floor(input.viewLineCount / desiredRatio);
2072
		return { typicalViewportLineCount, extraLinesBeyondLastLine, desiredRatio, minimapLineCount };
A
Alex Dima 已提交
2073 2074
	}

A
Alex Dima 已提交
2075 2076
	private static _computeMinimapLayout(input: IMinimapLayoutInput, memory: ComputeOptionsMemory): EditorMinimapLayoutInfo {
		const outerWidth = input.outerWidth;
A
Alex Dima 已提交
2077 2078 2079
		const outerHeight = input.outerHeight;
		const pixelRatio = input.pixelRatio;

A
Alex Dima 已提交
2080 2081
		if (!input.minimap.enabled) {
			return {
A
Alex Dima 已提交
2082 2083
				renderMinimap: RenderMinimap.None,
				minimapLeft: 0,
A
Alex Dima 已提交
2084 2085 2086 2087 2088 2089
				minimapWidth: 0,
				minimapHeightIsEditorHeight: false,
				minimapIsSampling: false,
				minimapScale: 1,
				minimapLineHeight: 1,
				minimapCanvasInnerWidth: 0,
A
Alex Dima 已提交
2090
				minimapCanvasInnerHeight: Math.floor(pixelRatio * outerHeight),
A
Alex Dima 已提交
2091
				minimapCanvasOuterWidth: 0,
A
Alex Dima 已提交
2092
				minimapCanvasOuterHeight: outerHeight,
A
Alex Dima 已提交
2093 2094 2095
			};
		}

A
Alex Dima 已提交
2096 2097 2098 2099
		// Can use memory if only the `viewLineCount` and `remainingWidth` have changed
		const stableMinimapLayoutInput = memory.stableMinimapLayoutInput;
		const couldUseMemory = (
			stableMinimapLayoutInput
A
Alex Dima 已提交
2100
			// && input.outerWidth === lastMinimapLayoutInput.outerWidth !!! INTENTIONAL OMITTED
A
Alex Dima 已提交
2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118
			&& 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
		);

2119 2120 2121 2122 2123 2124 2125
		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 已提交
2126
		const minimapSide = input.minimap.side;
A
Alex Dima 已提交
2127 2128 2129 2130
		const verticalScrollbarWidth = input.verticalScrollbarWidth;
		const viewLineCount = input.viewLineCount;
		const remainingWidth = input.remainingWidth;
		const isViewportWrapping = input.isViewportWrapping;
2131

2132
		const baseCharHeight = minimapRenderCharacters ? 2 : 3;
2133 2134
		let minimapCanvasInnerHeight = Math.floor(pixelRatio * outerHeight);
		const minimapCanvasOuterHeight = minimapCanvasInnerHeight / pixelRatio;
A
Alex Dima 已提交
2135
		let minimapHeightIsEditorHeight = false;
2136
		let minimapIsSampling = false;
2137
		let minimapLineHeight = baseCharHeight * minimapScale;
A
Alex Dima 已提交
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159
		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 已提交
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174
				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);
A
Alex Dima 已提交
2175
					}
A
Alex Dima 已提交
2176 2177 2178
				}

				if (minimapSize === 'fill' || fitBecomesFill) {
A
Alex Dima 已提交
2179
					minimapHeightIsEditorHeight = true;
A
Alex Dima 已提交
2180
					const configuredMinimapScale = minimapScale;
A
Alex Dima 已提交
2181
					minimapLineHeight = Math.min(lineHeight * pixelRatio, Math.max(1, Math.floor(1 / desiredRatio)));
2182 2183 2184 2185 2186 2187 2188 2189
					if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
						// There is a loop when using `fill` 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.
						maxMinimapScale = memory.stableFitMaxMinimapScale;
					}
A
Alex Dima 已提交
2190 2191 2192
					minimapScale = Math.min(maxMinimapScale, Math.max(1, Math.floor(minimapLineHeight / baseCharHeight)));
					if (minimapScale > configuredMinimapScale) {
						minimapWidthMultiplier = Math.min(2, minimapScale / configuredMinimapScale);
2193
					}
A
Alex Dima 已提交
2194 2195
					minimapCharWidth = minimapScale / pixelRatio / minimapWidthMultiplier;
					minimapCanvasInnerHeight = Math.ceil((Math.max(typicalViewportLineCount, viewLineCount + extraLinesBeyondLastLine)) * minimapLineHeight);
2196 2197 2198 2199
					if (isViewportWrapping) {
						// remember for next time
						memory.stableMinimapLayoutInput = input;
						memory.stableFitRemainingWidth = remainingWidth;
A
Alex Dima 已提交
2200
						memory.stableFitMaxMinimapScale = minimapScale;
2201 2202 2203
					} else {
						memory.stableMinimapLayoutInput = null;
						memory.stableFitRemainingWidth = 0;
A
Alex Dima 已提交
2204
					}
2205 2206
				}
			}
A
Alex Dima 已提交
2207
		}
2208

A
Alex Dima 已提交
2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221
		// 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 已提交
2222 2223
		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 已提交
2224

A
Alex Dima 已提交
2225 2226
		let minimapCanvasInnerWidth = Math.floor(pixelRatio * minimapWidth);
		const minimapCanvasOuterWidth = minimapCanvasInnerWidth / pixelRatio;
A
Alex Dima 已提交
2227 2228
		minimapCanvasInnerWidth = Math.floor(minimapCanvasInnerWidth * minimapWidthMultiplier);

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

A
Alex Dima 已提交
2232
		return {
A
Alex Dima 已提交
2233 2234
			renderMinimap,
			minimapLeft,
A
Alex Dima 已提交
2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246
			minimapWidth,
			minimapHeightIsEditorHeight,
			minimapIsSampling,
			minimapScale,
			minimapLineHeight,
			minimapCanvasInnerWidth,
			minimapCanvasInnerHeight,
			minimapCanvasOuterWidth,
			minimapCanvasOuterHeight,
		};
	}

A
Alex Dima 已提交
2247 2248 2249 2250 2251 2252 2253 2254
	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 已提交
2255 2256
		const viewLineCount = env.viewLineCount;

2257 2258 2259 2260
		const wordWrapOverride2 = options.get(EditorOption.wordWrapOverride2);
		const wordWrapOverride1 = (wordWrapOverride2 === 'inherit' ? options.get(EditorOption.wordWrapOverride1) : wordWrapOverride2);
		const wordWrap = (wordWrapOverride1 === 'inherit' ? options.get(EditorOption.wordWrap) : wordWrapOverride1);

A
Alex Dima 已提交
2261 2262 2263
		const wordWrapColumn = options.get(EditorOption.wordWrapColumn);
		const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
		const isDominatedByLongLines = env.isDominatedByLongLines;
A
Alex Dima 已提交
2264 2265 2266

		const showGlyphMargin = options.get(EditorOption.glyphMargin);
		const showLineNumbers = (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off);
A
Alex Dima 已提交
2267
		const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars);
2268
		const scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine);
A
renames  
Alex Dima 已提交
2269
		const minimap = options.get(EditorOption.minimap);
A
Alex Dima 已提交
2270

A
renames  
Alex Dima 已提交
2271
		const scrollbar = options.get(EditorOption.scrollbar);
A
Alex Dima 已提交
2272
		const verticalScrollbarWidth = scrollbar.verticalScrollbarSize;
A
Alex Dima 已提交
2273
		const verticalScrollbarHasArrows = scrollbar.verticalHasArrows;
A
Alex Dima 已提交
2274 2275
		const scrollbarArrowSize = scrollbar.arrowSize;
		const horizontalScrollbarHeight = scrollbar.horizontalScrollbarSize;
A
Alex Dima 已提交
2276 2277 2278

		const rawLineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth);
		const folding = options.get(EditorOption.folding);
A
Alex Dima 已提交
2279 2280 2281 2282

		let lineDecorationsWidth: number;
		if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) {
			const multiple = parseFloat(rawLineDecorationsWidth.substr(0, rawLineDecorationsWidth.length - 2));
A
Alex Dima 已提交
2283
			lineDecorationsWidth = EditorIntOption.clampedInt(multiple * typicalHalfwidthCharacterWidth, 0, 0, 1000);
A
Alex Dima 已提交
2284
		} else {
A
Alex Dima 已提交
2285
			lineDecorationsWidth = EditorIntOption.clampedInt(rawLineDecorationsWidth, 0, 0, 1000);
A
Alex Dima 已提交
2286 2287 2288
		}
		if (folding) {
			lineDecorationsWidth += 16;
2289 2290
		}

A
Alex Dima 已提交
2291 2292 2293 2294 2295
		let lineNumbersWidth = 0;
		if (showLineNumbers) {
			const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars);
			lineNumbersWidth = Math.round(digitCount * maxDigitWidth);
		}
2296

A
Alex Dima 已提交
2297 2298 2299 2300
		let glyphMarginWidth = 0;
		if (showGlyphMargin) {
			glyphMarginWidth = lineHeight;
		}
2301

A
Alex Dima 已提交
2302
		let glyphMarginLeft = 0;
2303
		let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
A
Alex Dima 已提交
2304 2305 2306
		let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
		let contentLeft = decorationsLeft + lineDecorationsWidth;

2307
		const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;
A
Alex Dima 已提交
2308

A
Alex Dima 已提交
2309 2310 2311
		let isWordWrapMinified = false;
		let isViewportWrapping = false;
		let wrappingColumn = -1;
2312

A
Alex Dima 已提交
2313
		if (accessibilitySupport !== AccessibilitySupport.Enabled) {
C
ChaseKnowlden 已提交
2314
			// See https://github.com/microsoft/vscode/issues/27766
A
Alex Dima 已提交
2315 2316 2317
			// 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.
2318
			if (wordWrapOverride1 === 'inherit' && isDominatedByLongLines) {
A
Alex Dima 已提交
2319 2320 2321 2322 2323 2324 2325
				// 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 已提交
2326
			}
A
Alex Dima 已提交
2327
		}
2328

A
Alex Dima 已提交
2329 2330
		const minimapLayout = EditorLayoutInfoComputer._computeMinimapLayout({
			outerWidth: outerWidth,
A
Alex Dima 已提交
2331 2332 2333 2334 2335 2336 2337 2338 2339 2340
			outerHeight: outerHeight,
			lineHeight: lineHeight,
			typicalHalfwidthCharacterWidth: typicalHalfwidthCharacterWidth,
			pixelRatio: pixelRatio,
			scrollBeyondLastLine: scrollBeyondLastLine,
			minimap: minimap,
			verticalScrollbarWidth: verticalScrollbarWidth,
			viewLineCount: viewLineCount,
			remainingWidth: remainingWidth,
			isViewportWrapping: isViewportWrapping,
A
Alex Dima 已提交
2341
		}, env.memory || new ComputeOptionsMemory());
A
Alex Dima 已提交
2342

A
Alex Dima 已提交
2343 2344 2345 2346 2347 2348
		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;
2349
		}
A
Alex Dima 已提交
2350
		const contentWidth = remainingWidth - minimapLayout.minimapWidth;
2351

A
Alex Dima 已提交
2352 2353 2354 2355 2356
		// (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);

2357 2358 2359 2360 2361
		if (isViewportWrapping) {
			// compute the actual wrappingColumn
			wrappingColumn = Math.max(1, viewportColumn);
			if (wordWrap === 'bounded') {
				wrappingColumn = Math.min(wrappingColumn, wordWrapColumn);
2362 2363 2364
			}
		}

A
Alex Dima 已提交
2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380
		return {
			width: outerWidth,
			height: outerHeight,

			glyphMarginLeft: glyphMarginLeft,
			glyphMarginWidth: glyphMarginWidth,

			lineNumbersLeft: lineNumbersLeft,
			lineNumbersWidth: lineNumbersWidth,

			decorationsLeft: decorationsLeft,
			decorationsWidth: lineDecorationsWidth,

			contentLeft: contentLeft,
			contentWidth: contentWidth,

A
Alex Dima 已提交
2381
			minimap: minimapLayout,
A
Alex Dima 已提交
2382 2383 2384

			viewportColumn: viewportColumn,

2385 2386 2387
			isWordWrapMinified: isWordWrapMinified,
			isViewportWrapping: isViewportWrapping,
			wrappingColumn: wrappingColumn,
2388

A
Alex Dima 已提交
2389 2390 2391 2392 2393 2394 2395 2396 2397 2398
			verticalScrollbarWidth: verticalScrollbarWidth,
			horizontalScrollbarHeight: horizontalScrollbarHeight,

			overviewRuler: {
				top: verticalArrowSize,
				width: verticalScrollbarWidth,
				height: (outerHeight - 2 * verticalArrowSize),
				right: 0
			}
		};
2399 2400 2401
	}
}

A
Alex Dima 已提交
2402 2403
//#endregion

A
Alex Dima 已提交
2404 2405
//#region lightbulb

2406 2407 2408 2409 2410 2411 2412 2413 2414
/**
 * Configuration options for editor lightbulb
 */
export interface IEditorLightbulbOptions {
	/**
	 * Enable the lightbulb code action.
	 * Defaults to true.
	 */
	enabled?: boolean;
2415 2416
}

2417 2418 2419
/**
 * @internal
 */
A
Alex Dima 已提交
2420
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
A
Alex Dima 已提交
2421

2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435
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.")
				},
			}
		);
2436
	}
2437

A
Alex Dima 已提交
2438
	public validate(_input: any): EditorLightbulbOptions {
A
Alex Dima 已提交
2439
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2440 2441 2442 2443
			return this.defaultValue;
		}
		const input = _input as IEditorLightbulbOptions;
		return {
2444
			enabled: boolean(input.enabled, this.defaultValue.enabled)
A
Alex Dima 已提交
2445
		};
2446 2447 2448
	}
}

A
Alex Dima 已提交
2449 2450
//#endregion

2451
//#region inlayHints
K
kingwl 已提交
2452 2453

/**
2454
 * Configuration options for editor inlayHints
K
kingwl 已提交
2455
 */
2456
export interface IEditorInlayHintsOptions {
K
kingwl 已提交
2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475
	/**
	 * Enable the inline hints.
	 * Defaults to true.
	 */
	enabled?: boolean;

	/**
	 * Font size of inline hints.
	 * Default to 90% of the editor font size.
	 */
	fontSize?: number;

	/**
	 * Font family of inline hints.
	 * Defaults to editor font family.
	 */
	fontFamily?: string;
}

2476 2477 2478
/**
 * @internal
 */
2479
export type EditorInlayHintsOptions = Readonly<Required<IEditorInlayHintsOptions>>;
K
kingwl 已提交
2480

2481
class EditorInlayHints extends BaseEditorOption<EditorOption.inlayHints, EditorInlayHintsOptions> {
K
kingwl 已提交
2482 2483

	constructor() {
2484
		const defaults: EditorInlayHintsOptions = { enabled: true, fontSize: 0, fontFamily: '' };
K
kingwl 已提交
2485
		super(
2486
			EditorOption.inlayHints, 'inlayHints', defaults,
K
kingwl 已提交
2487
			{
2488
				'editor.inlayHints.enabled': {
K
kingwl 已提交
2489 2490
					type: 'boolean',
					default: defaults.enabled,
2491
					description: nls.localize('inlayHints.enable', "Enables the inlay hints in the editor.")
K
kingwl 已提交
2492
				},
2493
				'editor.inlayHints.fontSize': {
K
kingwl 已提交
2494 2495
					type: 'number',
					default: defaults.fontSize,
2496
					markdownDescription: nls.localize('inlayHints.fontSize', "Controls font size of inlay hints in the editor. A default of 90% of `#editor.fontSize#` is used when the configured value is less than `5` or greater than the editor font size.")
K
kingwl 已提交
2497
				},
2498
				'editor.inlayHints.fontFamily': {
K
kingwl 已提交
2499 2500
					type: 'string',
					default: defaults.fontFamily,
2501
					markdownDescription: nls.localize('inlayHints.fontFamily', "Controls font family of inlay hints in the editor. When set to empty, the `#editor.fontFamily#` is used.")
K
kingwl 已提交
2502 2503 2504 2505 2506
				},
			}
		);
	}

2507
	public validate(_input: any): EditorInlayHintsOptions {
K
kingwl 已提交
2508 2509 2510
		if (!_input || typeof _input !== 'object') {
			return this.defaultValue;
		}
2511
		const input = _input as IEditorInlayHintsOptions;
K
kingwl 已提交
2512 2513 2514 2515 2516 2517 2518 2519 2520 2521
		return {
			enabled: boolean(input.enabled, this.defaultValue.enabled),
			fontSize: EditorIntOption.clampedInt(input.fontSize, this.defaultValue.fontSize, 0, 100),
			fontFamily: EditorStringOption.string(input.fontFamily, this.defaultValue.fontFamily)
		};
	}
}

//#endregion

A
Alex Dima 已提交
2522 2523
//#region lineHeight

2524
class EditorLineHeight extends EditorFloatOption<EditorOption.lineHeight> {
2525 2526 2527 2528

	constructor() {
		super(
			EditorOption.lineHeight, 'lineHeight',
2529 2530
			EDITOR_FONT_DEFAULTS.lineHeight,
			x => EditorFloatOption.clamp(x, 0, 150),
2531
			{ markdownDescription: nls.localize('lineHeight', "Controls the line height. \n - Use 0 to automatically compute the line height from the font size.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values.") }
2532
		);
2533
	}
2534

2535
	public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
A
Alex Dima 已提交
2536 2537 2538 2539
		// 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;
2540 2541 2542
	}
}

A
Alex Dima 已提交
2543 2544 2545 2546
//#endregion

//#region minimap

2547
/**
2548
 * Configuration options for editor minimap
2549
 */
2550
export interface IEditorMinimapOptions {
2551
	/**
2552 2553
	 * Enable the rendering of the minimap.
	 * Defaults to true.
2554
	 */
2555 2556 2557 2558 2559 2560
	enabled?: boolean;
	/**
	 * Control the side of the minimap in editor.
	 * Defaults to 'right'.
	 */
	side?: 'right' | 'left';
A
Alex Dima 已提交
2561 2562 2563 2564
	/**
	 * Control the minimap rendering mode.
	 * Defaults to 'actual'.
	 */
2565
	size?: 'proportional' | 'fill' | 'fit';
2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580
	/**
	 * 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;
2581 2582 2583 2584
	/**
	 * Relative size of the font in the minimap. Defaults to 1.
	 */
	scale?: number;
2585
}
A
Alex Dima 已提交
2586

2587 2588 2589
/**
 * @internal
 */
A
Alex Dima 已提交
2590
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
A
Alex Dima 已提交
2591

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

2594 2595 2596
	constructor() {
		const defaults: EditorMinimapOptions = {
			enabled: true,
2597
			size: 'proportional',
2598 2599 2600 2601
			side: 'right',
			showSlider: 'mouseover',
			renderCharacters: true,
			maxColumn: 120,
2602
			scale: 1,
2603 2604 2605 2606 2607 2608 2609 2610 2611
		};
		super(
			EditorOption.minimap, 'minimap', defaults,
			{
				'editor.minimap.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('minimap.enabled', "Controls whether the minimap is shown.")
				},
2612
				'editor.minimap.size': {
A
Alex Dima 已提交
2613
					type: 'string',
2614
					enum: ['proportional', 'fill', 'fit'],
A
Alex Dima 已提交
2615
					enumDescriptions: [
2616 2617 2618
						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 已提交
2619
					],
2620 2621
					default: defaults.size,
					description: nls.localize('minimap.size', "Controls the size of the minimap.")
A
Alex Dima 已提交
2622
				},
2623 2624 2625 2626 2627 2628 2629 2630 2631 2632
				'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,
2633
					description: nls.localize('minimap.showSlider', "Controls when the minimap slider is shown.")
2634
				},
2635 2636 2637 2638 2639
				'editor.minimap.scale': {
					type: 'number',
					default: defaults.scale,
					minimum: 1,
					maximum: 3,
2640 2641
					enum: [1, 2, 3],
					description: nls.localize('minimap.scale', "Scale of content drawn in the minimap: 1, 2 or 3.")
2642 2643 2644 2645 2646 2647 2648 2649 2650 2651
				},
				'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 已提交
2652
				}
2653
			}
2654 2655
		);
	}
J
Jackson Kearl 已提交
2656

A
Alex Dima 已提交
2657
	public validate(_input: any): EditorMinimapOptions {
A
Alex Dima 已提交
2658
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2659 2660 2661
			return this.defaultValue;
		}
		const input = _input as IEditorMinimapOptions;
A
Alex Dima 已提交
2662
		return {
2663
			enabled: boolean(input.enabled, this.defaultValue.enabled),
2664 2665 2666
			size: stringSet<'proportional' | 'fill' | 'fit'>(input.size, this.defaultValue.size, ['proportional', 'fill', 'fit']),
			side: stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']),
			showSlider: stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
2667
			renderCharacters: boolean(input.renderCharacters, this.defaultValue.renderCharacters),
2668
			scale: EditorIntOption.clampedInt(input.scale, 1, 1, 3),
A
Alex Dima 已提交
2669
			maxColumn: EditorIntOption.clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000),
A
Alex Dima 已提交
2670 2671
		};
	}
A
Alex Dima 已提交
2672
}
A
Alex Dima 已提交
2673

A
Alex Dima 已提交
2674
//#endregion
A
Alex Dima 已提交
2675

A
Alex Dima 已提交
2676
//#region multiCursorModifier
A
Alex Dima 已提交
2677

A
Alex Dima 已提交
2678 2679 2680 2681 2682
function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): 'altKey' | 'metaKey' | 'ctrlKey' {
	if (multiCursorModifier === 'ctrlCmd') {
		return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
	}
	return 'altKey';
A
Alex Dima 已提交
2683
}
A
Alex Dima 已提交
2684

A
Alex Dima 已提交
2685
//#endregion
A
Alex Dima 已提交
2686

B
Bailey 已提交
2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702
//#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;
}

2703 2704 2705 2706
/**
 * @internal
 */
export type InternalEditorPaddingOptions = Readonly<Required<IEditorPaddingOptions>>;
B
Bailey 已提交
2707 2708 2709 2710 2711 2712 2713 2714 2715 2716

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 已提交
2717 2718
					minimum: 0,
					maximum: 1000,
B
Bailey 已提交
2719 2720 2721 2722 2723
					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 已提交
2724 2725
					minimum: 0,
					maximum: 1000,
B
Bailey 已提交
2726 2727 2728 2729 2730 2731 2732
					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 已提交
2733
		if (!_input || typeof _input !== 'object') {
B
Bailey 已提交
2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745
			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 已提交
2746
//#region parameterHints
A
Alex Dima 已提交
2747

2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763
/**
 * 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;
}

2764 2765 2766
/**
 * @internal
 */
A
Alex Dima 已提交
2767 2768
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;

2769 2770 2771 2772 2773 2774
class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, InternalParameterHintOptions> {

	constructor() {
		const defaults: InternalParameterHintOptions = {
			enabled: true,
			cycle: false
A
Alex Dima 已提交
2775
		};
2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790
		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 已提交
2791 2792
	}

A
Alex Dima 已提交
2793
	public validate(_input: any): InternalParameterHintOptions {
A
Alex Dima 已提交
2794
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
2795
			return this.defaultValue;
A
Alex Dima 已提交
2796
		}
A
Alex Dima 已提交
2797
		const input = _input as IEditorParameterHintOptions;
A
Alex Dima 已提交
2798
		return {
2799 2800
			enabled: boolean(input.enabled, this.defaultValue.enabled),
			cycle: boolean(input.cycle, this.defaultValue.cycle)
A
Alex Dima 已提交
2801 2802
		};
	}
A
Alex Dima 已提交
2803
}
A
Alex Dima 已提交
2804

A
Alex Dima 已提交
2805
//#endregion
2806

A
Alex Dima 已提交
2807
//#region pixelRatio
2808

2809
class EditorPixelRatio extends ComputedEditorOption<EditorOption.pixelRatio, number> {
2810

2811 2812
	constructor() {
		super(EditorOption.pixelRatio);
2813 2814
	}

A
Alex Dima 已提交
2815 2816
	public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number {
		return env.pixelRatio;
A
Alex Dima 已提交
2817
	}
A
Alex Dima 已提交
2818
}
A
Alex Dima 已提交
2819

A
Alex Dima 已提交
2820 2821 2822 2823
//#endregion

//#region quickSuggestions

2824 2825 2826 2827
/**
 * Configuration options for quick suggestions
 */
export interface IQuickSuggestionsOptions {
A
Alex Dima 已提交
2828 2829 2830
	other?: boolean;
	comments?: boolean;
	strings?: boolean;
2831 2832
}

2833 2834 2835
/**
 * @internal
 */
A
Alex Dima 已提交
2836 2837
export type ValidQuickSuggestionsOptions = boolean | Readonly<Required<IQuickSuggestionsOptions>>;

2838 2839
class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, ValidQuickSuggestionsOptions> {

2840
	public override readonly defaultValue: Readonly<Required<IQuickSuggestionsOptions>>;
2841 2842 2843 2844 2845 2846

	constructor() {
		const defaults: ValidQuickSuggestionsOptions = {
			other: true,
			comments: false,
			strings: false
2847
		};
2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879
		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.")
			}
		);
2880
		this.defaultValue = defaults;
2881 2882
	}

A
Alex Dima 已提交
2883 2884 2885 2886
	public validate(_input: any): ValidQuickSuggestionsOptions {
		if (typeof _input === 'boolean') {
			return _input;
		}
A
Alex Dima 已提交
2887
		if (_input && typeof _input === 'object') {
A
Alex Dima 已提交
2888
			const input = _input as IQuickSuggestionsOptions;
2889
			const opts = {
2890 2891 2892
				other: boolean(input.other, this.defaultValue.other),
				comments: boolean(input.comments, this.defaultValue.comments),
				strings: boolean(input.strings, this.defaultValue.strings),
A
Alex Dima 已提交
2893
			};
2894 2895 2896 2897 2898 2899 2900
			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;
			}
2901
		}
A
Alex Dima 已提交
2902
		return this.defaultValue;
2903
	}
A
Alex Dima 已提交
2904
}
2905

A
Alex Dima 已提交
2906
//#endregion
2907

A
Alex Dima 已提交
2908 2909 2910
//#region renderLineNumbers

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

A
Alex Dima 已提交
2912 2913 2914 2915 2916 2917 2918
export const enum RenderLineNumbersType {
	Off = 0,
	On = 1,
	Relative = 2,
	Interval = 3,
	Custom = 4
}
2919

A
Alex Dima 已提交
2920 2921 2922 2923
export interface InternalEditorRenderLineNumbersOptions {
	readonly renderType: RenderLineNumbersType;
	readonly renderFn: ((lineNumber: number) => string) | null;
}
2924

2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940
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.")
2941
			}
2942 2943
		);
	}
2944

A
Alex Dima 已提交
2945 2946 2947 2948 2949
	public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions {
		let renderType: RenderLineNumbersType = this.defaultValue.renderType;
		let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn;

		if (typeof lineNumbers !== 'undefined') {
2950
			if (typeof lineNumbers === 'function') {
A
Alex Dima 已提交
2951 2952
				renderType = RenderLineNumbersType.Custom;
				renderFn = lineNumbers;
2953
			} else if (lineNumbers === 'interval') {
A
Alex Dima 已提交
2954
				renderType = RenderLineNumbersType.Interval;
2955
			} else if (lineNumbers === 'relative') {
A
Alex Dima 已提交
2956
				renderType = RenderLineNumbersType.Relative;
2957
			} else if (lineNumbers === 'on') {
A
Alex Dima 已提交
2958
				renderType = RenderLineNumbersType.On;
2959
			} else {
A
Alex Dima 已提交
2960
				renderType = RenderLineNumbersType.Off;
2961 2962 2963
			}
		}

A
Alex Dima 已提交
2964 2965 2966 2967 2968 2969
		return {
			renderType,
			renderFn
		};
	}
}
2970

A
Alex Dima 已提交
2971 2972
//#endregion

2973 2974 2975 2976 2977
//#region renderValidationDecorations

/**
 * @internal
 */
2978
export function filterValidationDecorations(options: IComputedEditorOptions): boolean {
2979 2980
	const renderValidationDecorations = options.get(EditorOption.renderValidationDecorations);
	if (renderValidationDecorations === 'editable') {
2981
		return options.get(EditorOption.readOnly);
2982
	}
2983
	return renderValidationDecorations === 'on' ? false : true;
2984 2985 2986 2987
}

//#endregion

A
Alex Dima 已提交
2988 2989
//#region rulers

2990 2991 2992
export interface IRulerOption {
	readonly column: number;
	readonly color: string | null;
2993 2994
}

2995
class EditorRulers extends BaseEditorOption<EditorOption.rulers, IRulerOption[]> {
2996 2997

	constructor() {
2998
		const defaults: IRulerOption[] = [];
2999
		const columnSchema: IJSONSchema = { type: 'number', description: nls.localize('rulers.size', "Number of monospace characters at which this editor ruler will render.") };
3000 3001 3002 3003 3004
		super(
			EditorOption.rulers, 'rulers', defaults,
			{
				type: 'array',
				items: {
3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017
					anyOf: [
						columnSchema,
						{
							type: [
								'object'
							],
							properties: {
								column: columnSchema,
								color: {
									type: 'string',
									description: nls.localize('rulers.color', "Color of this editor ruler."),
									format: 'color-hex'
								}
3018 3019
							}
						}
3020
					]
3021 3022 3023
				},
				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.")
3024
			}
3025 3026
		);
	}
3027

3028
	public validate(input: any): IRulerOption[] {
A
Alex Dima 已提交
3029
		if (Array.isArray(input)) {
3030
			let rulers: IRulerOption[] = [];
3031 3032 3033 3034 3035 3036
			for (let _element of input) {
				if (typeof _element === 'number') {
					rulers.push({
						column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
						color: null
					});
A
Alex Dima 已提交
3037
				} else if (_element && typeof _element === 'object') {
3038 3039 3040 3041 3042
					const element = _element as IRulerOption;
					rulers.push({
						column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
						color: element.color
					});
3043
				}
3044
			}
3045
			rulers.sort((a, b) => a.column - b.column);
A
Alex Dima 已提交
3046
			return rulers;
3047
		}
A
Alex Dima 已提交
3048 3049 3050
		return this.defaultValue;
	}
}
3051

A
Alex Dima 已提交
3052
//#endregion
T
Tiago Ribeiro 已提交
3053

A
Alex Dima 已提交
3054
//#region scrollbar
3055

3056 3057 3058 3059 3060 3061 3062
/**
 * Configuration options for editor scrollbars
 */
export interface IEditorScrollbarOptions {
	/**
	 * The size of arrows (if displayed).
	 * Defaults to 11.
3063
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078
	 */
	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.
3079
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3080 3081 3082 3083 3084
	 */
	useShadows?: boolean;
	/**
	 * Render arrows at the top and bottom of the vertical scrollbar.
	 * Defaults to false.
3085
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3086 3087 3088 3089 3090
	 */
	verticalHasArrows?: boolean;
	/**
	 * Render arrows at the left and right of the horizontal scrollbar.
	 * Defaults to false.
3091
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3092 3093 3094 3095 3096 3097 3098
	 */
	horizontalHasArrows?: boolean;
	/**
	 * Listen to mouse wheel events and react to them by scrolling.
	 * Defaults to true.
	 */
	handleMouseWheel?: boolean;
3099 3100 3101
	/**
	 * Always consume mouse wheel events (always call preventDefault() and stopPropagation() on the browser events).
	 * Defaults to true.
3102
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3103 3104
	 */
	alwaysConsumeMouseWheel?: boolean;
3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117
	/**
	 * 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`.
3118
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3119 3120 3121 3122 3123
	 */
	verticalSliderSize?: number;
	/**
	 * Height in pixels for the horizontal slider.
	 * Defaults to `horizontalScrollbarSize`.
3124
	 * **NOTE**: This option cannot be updated using `updateOptions()`
3125 3126
	 */
	horizontalSliderSize?: number;
3127 3128 3129 3130
	/**
	 * Scroll gutter clicks move by page vs jump to position.
	 * Defaults to false.
	 */
A
Alex Dima 已提交
3131
	scrollByPage?: boolean;
3132 3133
}

A
Alex Dima 已提交
3134 3135 3136 3137 3138 3139 3140 3141
export interface InternalEditorScrollbarOptions {
	readonly arrowSize: number;
	readonly vertical: ScrollbarVisibility;
	readonly horizontal: ScrollbarVisibility;
	readonly useShadows: boolean;
	readonly verticalHasArrows: boolean;
	readonly horizontalHasArrows: boolean;
	readonly handleMouseWheel: boolean;
3142
	readonly alwaysConsumeMouseWheel: boolean;
A
Alex Dima 已提交
3143 3144 3145 3146
	readonly horizontalScrollbarSize: number;
	readonly horizontalSliderSize: number;
	readonly verticalScrollbarSize: number;
	readonly verticalSliderSize: number;
A
Alex Dima 已提交
3147
	readonly scrollByPage: boolean;
A
Alex Dima 已提交
3148 3149
}

A
Alex Dima 已提交
3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160
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;
	}
}

3161 3162 3163
class EditorScrollbar extends BaseEditorOption<EditorOption.scrollbar, InternalEditorScrollbarOptions> {

	constructor() {
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178
		const defaults: InternalEditorScrollbarOptions = {
			vertical: ScrollbarVisibility.Auto,
			horizontal: ScrollbarVisibility.Auto,
			arrowSize: 11,
			useShadows: true,
			verticalHasArrows: false,
			horizontalHasArrows: false,
			horizontalScrollbarSize: 12,
			horizontalSliderSize: 12,
			verticalScrollbarSize: 14,
			verticalSliderSize: 14,
			handleMouseWheel: true,
			alwaysConsumeMouseWheel: true,
			scrollByPage: false
		};
3179
		super(
3180
			EditorOption.scrollbar, 'scrollbar', defaults,
3181
			{
3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218
				'editor.scrollbar.vertical': {
					type: 'string',
					enum: ['auto', 'visible', 'hidden'],
					enumDescriptions: [
						nls.localize('scrollbar.vertical.auto', "The vertical scrollbar will be visible only when necessary."),
						nls.localize('scrollbar.vertical.visible', "The vertical scrollbar will always be visible."),
						nls.localize('scrollbar.vertical.fit', "The vertical scrollbar will always be hidden."),
					],
					default: 'auto',
					description: nls.localize('scrollbar.vertical', "Controls the visibility of the vertical scrollbar.")
				},
				'editor.scrollbar.horizontal': {
					type: 'string',
					enum: ['auto', 'visible', 'hidden'],
					enumDescriptions: [
						nls.localize('scrollbar.horizontal.auto', "The horizontal scrollbar will be visible only when necessary."),
						nls.localize('scrollbar.horizontal.visible', "The horizontal scrollbar will always be visible."),
						nls.localize('scrollbar.horizontal.fit', "The horizontal scrollbar will always be hidden."),
					],
					default: 'auto',
					description: nls.localize('scrollbar.horizontal', "Controls the visibility of the horizontal scrollbar.")
				},
				'editor.scrollbar.verticalScrollbarSize': {
					type: 'number',
					default: defaults.verticalScrollbarSize,
					description: nls.localize('scrollbar.verticalScrollbarSize', "The width of the vertical scrollbar.")
				},
				'editor.scrollbar.horizontalScrollbarSize': {
					type: 'number',
					default: defaults.horizontalScrollbarSize,
					description: nls.localize('scrollbar.horizontalScrollbarSize', "The height of the horizontal scrollbar.")
				},
				'editor.scrollbar.scrollByPage': {
					type: 'boolean',
					default: defaults.scrollByPage,
					description: nls.localize('scrollbar.scrollByPage', "Controls whether clicks scroll by page or jump to click position.")
				}
3219 3220 3221 3222
			}
		);
	}

A
Alex Dima 已提交
3223
	public validate(_input: any): InternalEditorScrollbarOptions {
A
Alex Dima 已提交
3224
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
3225 3226 3227
			return this.defaultValue;
		}
		const input = _input as IEditorScrollbarOptions;
A
Alex Dima 已提交
3228 3229
		const horizontalScrollbarSize = EditorIntOption.clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000);
		const verticalScrollbarSize = EditorIntOption.clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000);
3230
		return {
A
Alex Dima 已提交
3231
			arrowSize: EditorIntOption.clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000),
A
Alex Dima 已提交
3232 3233
			vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical),
			horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal),
3234 3235 3236 3237 3238
			useShadows: boolean(input.useShadows, this.defaultValue.useShadows),
			verticalHasArrows: boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows),
			horizontalHasArrows: boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows),
			handleMouseWheel: boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel),
			alwaysConsumeMouseWheel: boolean(input.alwaysConsumeMouseWheel, this.defaultValue.alwaysConsumeMouseWheel),
A
Alex Dima 已提交
3239
			horizontalScrollbarSize: horizontalScrollbarSize,
A
Alex Dima 已提交
3240
			horizontalSliderSize: EditorIntOption.clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),
A
Alex Dima 已提交
3241
			verticalScrollbarSize: verticalScrollbarSize,
A
Alex Dima 已提交
3242
			verticalSliderSize: EditorIntOption.clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000),
3243
			scrollByPage: boolean(input.scrollByPage, this.defaultValue.scrollByPage),
A
Alex Dima 已提交
3244 3245
		};
	}
A
Alex Dima 已提交
3246
}
A
Alex Dima 已提交
3247

A
Alex Dima 已提交
3248 3249
//#endregion

3250 3251 3252 3253 3254 3255 3256
//#region inlineSuggest

export interface IInlineSuggestOptions {
	/**
	 * Enable or disable the rendering of automatic inline completions.
	*/
	enabled?: boolean;
3257 3258 3259 3260

	/**
	 * Configures the mode.
	 * Use `prefix` to only show ghost text if the text to replace is a prefix of the suggestion text.
3261 3262
	 * Use `subword` to only show ghost text if the replace text is a subword of the suggestion text.
	 * Use `subwordSmart` to only show ghost text if the replace text is a subword of the suggestion text, but the subword must start after the cursor position.
3263 3264
	 * Defaults to `prefix`.
	*/
3265
	mode?: 'prefix' | 'subword' | 'subwordSmart';
3266 3267
}

3268 3269 3270
/**
 * @internal
 */
3271 3272 3273 3274 3275 3276 3277 3278
export type InternalInlineSuggestOptions = Readonly<Required<IInlineSuggestOptions>>;

/**
 * Configuration options for inline suggestions
 */
class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, InternalInlineSuggestOptions> {
	constructor() {
		const defaults: InternalInlineSuggestOptions = {
3279
			enabled: true,
3280
			mode: 'subwordSmart'
3281 3282 3283 3284 3285 3286 3287 3288 3289
		};

		super(
			EditorOption.inlineSuggest, 'inlineSuggest', defaults,
			{
				'editor.inlineSuggest.enabled': {
					type: 'boolean',
					default: defaults.enabled,
					description: nls.localize('inlineSuggest.enabled', "Controls whether to automatically show inline suggestions in the editor.")
3290
				}
3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301
			}
		);
	}

	public validate(_input: any): InternalInlineSuggestOptions {
		if (!_input || typeof _input !== 'object') {
			return this.defaultValue;
		}
		const input = _input as IInlineSuggestOptions;
		return {
			enabled: boolean(input.enabled, this.defaultValue.enabled),
3302
			mode: stringSet(input.mode, this.defaultValue.mode, ['prefix', 'subword', 'subwordSmart']),
3303 3304 3305 3306 3307 3308
		};
	}
}

//#endregion

3309 3310 3311 3312 3313 3314 3315 3316 3317
//#region bracketPairColorization

export interface IBracketPairColorizationOptions {
	/**
	 * Enable or disable bracket pair colorization.
	*/
	enabled?: boolean;
}

3318 3319 3320
/**
 * @internal
 */
3321 3322 3323 3324 3325 3326 3327 3328
export type InternalBracketPairColorizationOptions = Readonly<Required<IBracketPairColorizationOptions>>;

/**
 * Configuration options for inline suggestions
 */
class BracketPairColorization extends BaseEditorOption<EditorOption.bracketPairColorization, InternalBracketPairColorizationOptions> {
	constructor() {
		const defaults: InternalBracketPairColorizationOptions = {
3329
			enabled: EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions.enabled
3330 3331 3332 3333 3334 3335 3336 3337
		};

		super(
			EditorOption.bracketPairColorization, 'bracketPairColorization', defaults,
			{
				'editor.bracketPairColorization.enabled': {
					type: 'boolean',
					default: defaults.enabled,
3338
					description: nls.localize('bracketPairColorization.enabled', "Controls whether bracket pair colorization is enabled or not. Use 'workbench.colorCustomizations' to override the bracket highlight colors.")
3339
				}
3340 3341 3342 3343 3344 3345 3346 3347 3348 3349
			}
		);
	}

	public validate(_input: any): InternalBracketPairColorizationOptions {
		if (!_input || typeof _input !== 'object') {
			return this.defaultValue;
		}
		const input = _input as IBracketPairColorizationOptions;
		return {
3350
			enabled: boolean(input.enabled, this.defaultValue.enabled)
3351 3352 3353 3354 3355 3356
		};
	}
}

//#endregion

H
Henning Dieterichs 已提交
3357
//#region guides
H
Henning Dieterichs 已提交
3358

H
Henning Dieterichs 已提交
3359
export interface IGuidesOptions {
H
Henning Dieterichs 已提交
3360
	/**
H
Henning Dieterichs 已提交
3361
	 * Enable rendering of bracket pair guides.
3362
	 * Defaults to false.
H
Henning Dieterichs 已提交
3363
	*/
3364
	bracketPairs?: boolean | 'active';
3365 3366 3367 3368 3369

	/**
	 * Enable rendering of vertical bracket pair guides.
	 * Defaults to 'active'.
	 */
3370
	bracketPairsHorizontal?: boolean | 'active';
3371 3372 3373 3374 3375 3376

	/**
	 * Enable highlighting of the active bracket pair.
	 * Defaults to true.
	*/
	highlightActiveBracketPair?: boolean;
H
Henning Dieterichs 已提交
3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388

	/**
	 * Enable rendering of indent guides.
	 * Defaults to true.
	 */
	indentation?: boolean;

	/**
	 * Enable highlighting of the active indent guide.
	 * Defaults to true.
	 */
	highlightActiveIndentation?: boolean;
H
Henning Dieterichs 已提交
3389 3390
}

3391 3392 3393
/**
 * @internal
 */
H
Henning Dieterichs 已提交
3394
export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>;
H
Henning Dieterichs 已提交
3395 3396 3397 3398

/**
 * Configuration options for inline suggestions
 */
H
Henning Dieterichs 已提交
3399
class GuideOptions extends BaseEditorOption<EditorOption.guides, InternalGuidesOptions> {
H
Henning Dieterichs 已提交
3400
	constructor() {
H
Henning Dieterichs 已提交
3401
		const defaults: InternalGuidesOptions = {
3402
			bracketPairs: false,
3403 3404 3405
			bracketPairsHorizontal: 'active',
			highlightActiveBracketPair: true,

H
Henning Dieterichs 已提交
3406 3407
			indentation: true,
			highlightActiveIndentation: true
H
Henning Dieterichs 已提交
3408 3409 3410
		};

		super(
H
Henning Dieterichs 已提交
3411
			EditorOption.guides, 'guides', defaults,
H
Henning Dieterichs 已提交
3412
			{
H
Henning Dieterichs 已提交
3413
				'editor.guides.bracketPairs': {
3414 3415
					type: ['boolean', 'string'],
					enum: [true, 'active', false],
3416 3417 3418 3419 3420
					enumDescriptions: [
						nls.localize('editor.guides.bracketPairs.true', "Enables bracket pair guides."),
						nls.localize('editor.guides.bracketPairs.active', "Enables bracket pair guides only for the active bracket pair."),
						nls.localize('editor.guides.bracketPairs.false', "Disables bracket pair guides."),
					],
H
Henning Dieterichs 已提交
3421 3422
					default: defaults.bracketPairs,
					description: nls.localize('editor.guides.bracketPairs', "Controls whether bracket pair guides are enabled or not.")
H
Henning Dieterichs 已提交
3423
				},
3424
				'editor.guides.bracketPairsHorizontal': {
3425 3426
					type: ['boolean', 'string'],
					enum: [true, 'active', false],
3427 3428 3429 3430 3431
					enumDescriptions: [
						nls.localize('editor.guides.bracketPairsHorizontal.true', "Enables horizontal guides as addition to vertical bracket pair guides."),
						nls.localize('editor.guides.bracketPairsHorizontal.active', "Enables horizontal guides only for the active bracket pair."),
						nls.localize('editor.guides.bracketPairsHorizontal.false', "Disables horizontal bracket pair guides."),
					],
3432 3433 3434 3435 3436 3437 3438 3439
					default: defaults.bracketPairsHorizontal,
					description: nls.localize('editor.guides.bracketPairsHorizontal', "Controls whether horizontal bracket pair guides are enabled or not.")
				},
				'editor.guides.highlightActiveBracketPair': {
					type: 'boolean',
					default: defaults.highlightActiveBracketPair,
					description: nls.localize('editor.guides.highlightActiveBracketPair', "Controls whether bracket pair guides are enabled or not.")
				},
H
Henning Dieterichs 已提交
3440 3441 3442 3443 3444 3445 3446 3447 3448
				'editor.guides.indentation': {
					type: 'boolean',
					default: defaults.indentation,
					description: nls.localize('editor.guides.indentation', "Controls whether the editor should render indent guides.")
				},
				'editor.guides.highlightActiveIndentation': {
					type: 'boolean',
					default: defaults.highlightActiveIndentation,
					description: nls.localize('editor.guides.highlightActiveIndentation', "Controls whether the editor should highlight the active indent guide.")
H
Henning Dieterichs 已提交
3449 3450 3451 3452 3453
				}
			}
		);
	}

H
Henning Dieterichs 已提交
3454
	public validate(_input: any): InternalGuidesOptions {
H
Henning Dieterichs 已提交
3455 3456 3457
		if (!_input || typeof _input !== 'object') {
			return this.defaultValue;
		}
H
Henning Dieterichs 已提交
3458
		const input = _input as IGuidesOptions;
H
Henning Dieterichs 已提交
3459
		return {
3460 3461
			bracketPairs: primitiveSet(input.bracketPairs, this.defaultValue.bracketPairs, [true, false, 'active']),
			bracketPairsHorizontal: primitiveSet(input.bracketPairsHorizontal, this.defaultValue.bracketPairsHorizontal, [true, false, 'active']),
3462 3463
			highlightActiveBracketPair: boolean(input.highlightActiveBracketPair, this.defaultValue.highlightActiveBracketPair),

H
Henning Dieterichs 已提交
3464 3465
			indentation: boolean(input.indentation, this.defaultValue.indentation),
			highlightActiveIndentation: boolean(input.highlightActiveIndentation, this.defaultValue.highlightActiveIndentation),
H
Henning Dieterichs 已提交
3466 3467 3468 3469
		};
	}
}

3470 3471 3472 3473 3474 3475 3476 3477
function primitiveSet<T extends string | boolean>(value: unknown, defaultValue: T, allowedValues: T[]): T {
	const idx = allowedValues.indexOf(value as any);
	if (idx === -1) {
		return defaultValue;
	}
	return allowedValues[idx];
}

H
Henning Dieterichs 已提交
3478 3479
//#endregion

A
Alex Dima 已提交
3480 3481
//#region suggest

3482 3483 3484 3485
/**
 * Configuration options for editor suggest widget
 */
export interface ISuggestOptions {
3486 3487 3488
	/**
	 * Overwrite word ends on accept. Default to false.
	 */
3489
	insertMode?: 'insert' | 'replace';
3490 3491 3492 3493 3494 3495 3496 3497 3498
	/**
	 * Enable graceful matching. Defaults to true.
	 */
	filterGraceful?: boolean;
	/**
	 * Prevent quick suggestions when a snippet is active. Defaults to true.
	 */
	snippetsPreventQuickSuggestions?: boolean;
	/**
N
Noah Bliss 已提交
3499
	 * Favors words that appear close to the cursor.
3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510
	 */
	localityBonus?: boolean;
	/**
	 * Enable using global storage for remembering suggestions.
	 */
	shareSuggestSelections?: boolean;
	/**
	 * Enable or disable icons in suggestions. Defaults to true.
	 */
	showIcons?: boolean;
	/**
3511
	 * Enable or disable the suggest status bar.
3512
	 */
3513
	showStatusBar?: boolean;
3514
	/**
3515
	 * Enable or disable the rendering of the suggestion preview.
3516
	 */
3517
	preview?: boolean;
3518
	/**
3519
	 * Configures the mode of the preview.
3520
	*/
3521
	previewMode?: 'prefix' | 'subword' | 'subwordSmart';
3522 3523 3524
	/**
	 * Show details inline with the label. Defaults to true.
	 */
3525
	showInlineDetails?: boolean;
3526
	/**
3527
	 * Show method-suggestions.
3528
	 */
3529 3530 3531 3532 3533 3534 3535
	showMethods?: boolean;
	/**
	 * Show function-suggestions.
	 */
	showFunctions?: boolean;
	/**
	 * Show constructor-suggestions.
3536
	 */
3537
	showConstructors?: boolean;
3538 3539 3540 3541
	/**
	 * Show deprecated-suggestions.
	 */
	showDeprecated?: boolean;
3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625
	/**
	 * 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;
3626 3627 3628 3629 3630 3631 3632 3633
	/**
	 * Show issue-suggestions.
	 */
	showIssues?: boolean;
	/**
	 * Show user-suggestions.
	 */
	showUsers?: boolean;
3634 3635 3636 3637
	/**
	 * Show snippet-suggestions.
	 */
	showSnippets?: boolean;
3638 3639
}

3640 3641 3642
/**
 * @internal
 */
A
Alex Dima 已提交
3643
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
A
Alex Dima 已提交
3644

A
Alex Dima 已提交
3645
class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSuggestOptions> {
3646 3647 3648

	constructor() {
		const defaults: InternalSuggestOptions = {
3649
			insertMode: 'insert',
3650 3651 3652 3653 3654
			filterGraceful: true,
			snippetsPreventQuickSuggestions: true,
			localityBonus: false,
			shareSuggestSelections: false,
			showIcons: true,
3655
			showStatusBar: false,
3656
			preview: false,
3657
			previewMode: 'subwordSmart',
3658
			showInlineDetails: true,
3659 3660 3661
			showMethods: true,
			showFunctions: true,
			showConstructors: true,
3662
			showDeprecated: true,
3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684
			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,
3685 3686
			showUsers: true,
			showIssues: true,
3687 3688 3689 3690
		};
		super(
			EditorOption.suggest, 'suggest', defaults,
			{
3691 3692 3693 3694 3695 3696 3697 3698 3699
				'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.")
3700
				},
3701 3702 3703 3704 3705 3706 3707 3708
				'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,
N
Noah Bliss 已提交
3709
					description: nls.localize('suggest.localityBonus', "Controls whether sorting favors words that appear close to the cursor.")
3710 3711 3712 3713 3714 3715 3716 3717 3718
				},
				'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 已提交
3719
					description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
3720 3721 3722 3723 3724 3725
				},
				'editor.suggest.showIcons': {
					type: 'boolean',
					default: defaults.showIcons,
					description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
				},
3726 3727 3728 3729 3730
				'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.")
				},
3731
				'editor.suggest.preview': {
3732
					type: 'boolean',
3733 3734
					default: defaults.preview,
					description: nls.localize('suggest.preview', "Controls whether to preview the suggestion outcome in the editor.")
3735
				},
3736
				'editor.suggest.showInlineDetails': {
3737
					type: 'boolean',
3738
					default: defaults.showInlineDetails,
3739
					description: nls.localize('suggest.showInlineDetails', "Controls whether suggest details show inline with the label or only in the details widget")
3740
				},
3741 3742
				'editor.suggest.maxVisibleSuggestions': {
					type: 'number',
3743
					deprecationMessage: nls.localize('suggest.maxVisibleSuggestions.dep', "This setting is deprecated. The suggest widget can now be resized."),
3744 3745 3746
				},
				'editor.suggest.filteredTypes': {
					type: 'object',
3747
					deprecationMessage: nls.localize('deprecated', "This setting is deprecated, please use separate settings like 'editor.suggest.showKeywords' or 'editor.suggest.showSnippets' instead.")
J
Johannes Rieken 已提交
3748
				},
3749
				'editor.suggest.showMethods': {
3750 3751
					type: 'boolean',
					default: true,
3752
					markdownDescription: nls.localize('editor.suggest.showMethods', "When enabled IntelliSense shows `method`-suggestions.")
3753
				},
3754
				'editor.suggest.showFunctions': {
3755 3756
					type: 'boolean',
					default: true,
3757
					markdownDescription: nls.localize('editor.suggest.showFunctions', "When enabled IntelliSense shows `function`-suggestions.")
3758
				},
3759
				'editor.suggest.showConstructors': {
3760 3761
					type: 'boolean',
					default: true,
3762
					markdownDescription: nls.localize('editor.suggest.showConstructors', "When enabled IntelliSense shows `constructor`-suggestions.")
3763
				},
3764 3765 3766 3767 3768
				'editor.suggest.showDeprecated': {
					type: 'boolean',
					default: true,
					markdownDescription: nls.localize('editor.suggest.showDeprecated', "When enabled IntelliSense shows `deprecated`-suggestions.")
				},
3769
				'editor.suggest.showFields': {
3770 3771
					type: 'boolean',
					default: true,
3772
					markdownDescription: nls.localize('editor.suggest.showFields', "When enabled IntelliSense shows `field`-suggestions.")
3773
				},
3774
				'editor.suggest.showVariables': {
3775 3776
					type: 'boolean',
					default: true,
3777
					markdownDescription: nls.localize('editor.suggest.showVariables', "When enabled IntelliSense shows `variable`-suggestions.")
3778
				},
3779
				'editor.suggest.showClasses': {
3780 3781
					type: 'boolean',
					default: true,
3782
					markdownDescription: nls.localize('editor.suggest.showClasss', "When enabled IntelliSense shows `class`-suggestions.")
3783
				},
3784
				'editor.suggest.showStructs': {
3785 3786
					type: 'boolean',
					default: true,
3787
					markdownDescription: nls.localize('editor.suggest.showStructs', "When enabled IntelliSense shows `struct`-suggestions.")
3788
				},
3789
				'editor.suggest.showInterfaces': {
3790 3791
					type: 'boolean',
					default: true,
3792
					markdownDescription: nls.localize('editor.suggest.showInterfaces', "When enabled IntelliSense shows `interface`-suggestions.")
3793
				},
3794
				'editor.suggest.showModules': {
3795 3796
					type: 'boolean',
					default: true,
3797
					markdownDescription: nls.localize('editor.suggest.showModules', "When enabled IntelliSense shows `module`-suggestions.")
3798
				},
3799
				'editor.suggest.showProperties': {
3800 3801
					type: 'boolean',
					default: true,
3802
					markdownDescription: nls.localize('editor.suggest.showPropertys', "When enabled IntelliSense shows `property`-suggestions.")
3803
				},
3804
				'editor.suggest.showEvents': {
3805 3806
					type: 'boolean',
					default: true,
3807
					markdownDescription: nls.localize('editor.suggest.showEvents', "When enabled IntelliSense shows `event`-suggestions.")
3808
				},
3809
				'editor.suggest.showOperators': {
3810 3811
					type: 'boolean',
					default: true,
3812
					markdownDescription: nls.localize('editor.suggest.showOperators', "When enabled IntelliSense shows `operator`-suggestions.")
3813
				},
3814
				'editor.suggest.showUnits': {
3815 3816
					type: 'boolean',
					default: true,
3817
					markdownDescription: nls.localize('editor.suggest.showUnits', "When enabled IntelliSense shows `unit`-suggestions.")
3818
				},
3819
				'editor.suggest.showValues': {
3820 3821
					type: 'boolean',
					default: true,
3822
					markdownDescription: nls.localize('editor.suggest.showValues', "When enabled IntelliSense shows `value`-suggestions.")
3823
				},
3824
				'editor.suggest.showConstants': {
3825 3826
					type: 'boolean',
					default: true,
3827
					markdownDescription: nls.localize('editor.suggest.showConstants', "When enabled IntelliSense shows `constant`-suggestions.")
3828
				},
3829
				'editor.suggest.showEnums': {
3830 3831
					type: 'boolean',
					default: true,
3832
					markdownDescription: nls.localize('editor.suggest.showEnums', "When enabled IntelliSense shows `enum`-suggestions.")
3833
				},
3834
				'editor.suggest.showEnumMembers': {
3835 3836
					type: 'boolean',
					default: true,
3837
					markdownDescription: nls.localize('editor.suggest.showEnumMembers', "When enabled IntelliSense shows `enumMember`-suggestions.")
3838
				},
3839
				'editor.suggest.showKeywords': {
3840 3841
					type: 'boolean',
					default: true,
3842
					markdownDescription: nls.localize('editor.suggest.showKeywords', "When enabled IntelliSense shows `keyword`-suggestions.")
3843
				},
3844
				'editor.suggest.showWords': {
3845 3846
					type: 'boolean',
					default: true,
3847
					markdownDescription: nls.localize('editor.suggest.showTexts', "When enabled IntelliSense shows `text`-suggestions.")
3848
				},
3849
				'editor.suggest.showColors': {
3850 3851
					type: 'boolean',
					default: true,
3852
					markdownDescription: nls.localize('editor.suggest.showColors', "When enabled IntelliSense shows `color`-suggestions.")
3853
				},
3854
				'editor.suggest.showFiles': {
3855 3856
					type: 'boolean',
					default: true,
3857
					markdownDescription: nls.localize('editor.suggest.showFiles', "When enabled IntelliSense shows `file`-suggestions.")
3858
				},
3859
				'editor.suggest.showReferences': {
3860 3861
					type: 'boolean',
					default: true,
3862
					markdownDescription: nls.localize('editor.suggest.showReferences', "When enabled IntelliSense shows `reference`-suggestions.")
3863
				},
3864
				'editor.suggest.showCustomcolors': {
3865 3866
					type: 'boolean',
					default: true,
3867
					markdownDescription: nls.localize('editor.suggest.showCustomcolors', "When enabled IntelliSense shows `customcolor`-suggestions.")
3868
				},
3869
				'editor.suggest.showFolders': {
3870 3871
					type: 'boolean',
					default: true,
3872
					markdownDescription: nls.localize('editor.suggest.showFolders', "When enabled IntelliSense shows `folder`-suggestions.")
3873
				},
3874
				'editor.suggest.showTypeParameters': {
3875 3876
					type: 'boolean',
					default: true,
3877
					markdownDescription: nls.localize('editor.suggest.showTypeParameters', "When enabled IntelliSense shows `typeParameter`-suggestions.")
3878
				},
3879
				'editor.suggest.showSnippets': {
3880 3881
					type: 'boolean',
					default: true,
3882
					markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
3883
				},
3884 3885 3886 3887 3888 3889 3890 3891 3892
				'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.")
3893
				}
3894 3895 3896 3897
			}
		);
	}

A
Alex Dima 已提交
3898
	public validate(_input: any): InternalSuggestOptions {
A
Alex Dima 已提交
3899
		if (!_input || typeof _input !== 'object') {
A
Alex Dima 已提交
3900
			return this.defaultValue;
A
Alex Dima 已提交
3901
		}
A
Alex Dima 已提交
3902
		const input = _input as ISuggestOptions;
A
Alex Dima 已提交
3903
		return {
3904
			insertMode: stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
3905 3906 3907 3908 3909 3910
			filterGraceful: boolean(input.filterGraceful, this.defaultValue.filterGraceful),
			snippetsPreventQuickSuggestions: boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
			localityBonus: boolean(input.localityBonus, this.defaultValue.localityBonus),
			shareSuggestSelections: boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
			showIcons: boolean(input.showIcons, this.defaultValue.showIcons),
			showStatusBar: boolean(input.showStatusBar, this.defaultValue.showStatusBar),
3911
			preview: boolean(input.preview, this.defaultValue.preview),
3912
			previewMode: stringSet(input.previewMode, this.defaultValue.previewMode, ['prefix', 'subword', 'subwordSmart']),
3913 3914 3915 3916
			showInlineDetails: boolean(input.showInlineDetails, this.defaultValue.showInlineDetails),
			showMethods: boolean(input.showMethods, this.defaultValue.showMethods),
			showFunctions: boolean(input.showFunctions, this.defaultValue.showFunctions),
			showConstructors: boolean(input.showConstructors, this.defaultValue.showConstructors),
3917
			showDeprecated: boolean(input.showDeprecated, this.defaultValue.showDeprecated),
3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941
			showFields: boolean(input.showFields, this.defaultValue.showFields),
			showVariables: boolean(input.showVariables, this.defaultValue.showVariables),
			showClasses: boolean(input.showClasses, this.defaultValue.showClasses),
			showStructs: boolean(input.showStructs, this.defaultValue.showStructs),
			showInterfaces: boolean(input.showInterfaces, this.defaultValue.showInterfaces),
			showModules: boolean(input.showModules, this.defaultValue.showModules),
			showProperties: boolean(input.showProperties, this.defaultValue.showProperties),
			showEvents: boolean(input.showEvents, this.defaultValue.showEvents),
			showOperators: boolean(input.showOperators, this.defaultValue.showOperators),
			showUnits: boolean(input.showUnits, this.defaultValue.showUnits),
			showValues: boolean(input.showValues, this.defaultValue.showValues),
			showConstants: boolean(input.showConstants, this.defaultValue.showConstants),
			showEnums: boolean(input.showEnums, this.defaultValue.showEnums),
			showEnumMembers: boolean(input.showEnumMembers, this.defaultValue.showEnumMembers),
			showKeywords: boolean(input.showKeywords, this.defaultValue.showKeywords),
			showWords: boolean(input.showWords, this.defaultValue.showWords),
			showColors: boolean(input.showColors, this.defaultValue.showColors),
			showFiles: boolean(input.showFiles, this.defaultValue.showFiles),
			showReferences: boolean(input.showReferences, this.defaultValue.showReferences),
			showFolders: boolean(input.showFolders, this.defaultValue.showFolders),
			showTypeParameters: boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
			showSnippets: boolean(input.showSnippets, this.defaultValue.showSnippets),
			showUsers: boolean(input.showUsers, this.defaultValue.showUsers),
			showIssues: boolean(input.showIssues, this.defaultValue.showIssues),
3942 3943 3944 3945
		};
	}
}

A
Alex Dima 已提交
3946 3947
//#endregion

3948 3949 3950 3951 3952 3953
//#region smart select

export interface ISmartSelectOptions {
	selectLeadingAndTrailingWhitespace?: boolean
}

3954 3955 3956
/**
 * @internal
 */
3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972
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 已提交
3973
			}
3974 3975 3976 3977 3978 3979 3980 3981
		);
	}

	public validate(input: any): Readonly<Required<ISmartSelectOptions>> {
		if (!input || typeof input !== 'object') {
			return this.defaultValue;
		}
		return {
3982
			selectLeadingAndTrailingWhitespace: boolean((input as ISmartSelectOptions).selectLeadingAndTrailingWhitespace, this.defaultValue.selectLeadingAndTrailingWhitespace)
3983 3984 3985 3986
		};
	}
}

A
Alex Dima 已提交
3987 3988 3989 3990
//#endregion

//#region tabFocusMode

A
Alex Dima 已提交
3991 3992 3993 3994 3995 3996
class EditorTabFocusMode extends ComputedEditorOption<EditorOption.tabFocusMode, boolean> {

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

A
Alex Dima 已提交
3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034
	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;
4035
	}
A
Alex Dima 已提交
4036
}
4037

A
Alex Dima 已提交
4038
//#endregion
4039

A
Alex Dima 已提交
4040
//#region wrappingInfo
4041

A
Alex Dima 已提交
4042 4043 4044 4045 4046 4047
export interface EditorWrappingInfo {
	readonly isDominatedByLongLines: boolean;
	readonly isWordWrapMinified: boolean;
	readonly isViewportWrapping: boolean;
	readonly wrappingColumn: number;
}
4048

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

A
Alex Dima 已提交
4051
	constructor() {
4052
		super(EditorOption.wrappingInfo, [EditorOption.layoutInfo]);
A
Alex Dima 已提交
4053 4054
	}

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

A
Alex Dima 已提交
4058
		return {
4059
			isDominatedByLongLines: env.isDominatedByLongLines,
4060 4061 4062
			isWordWrapMinified: layoutInfo.isWordWrapMinified,
			isViewportWrapping: layoutInfo.isViewportWrapping,
			wrappingColumn: layoutInfo.wrappingColumn,
A
Alex Dima 已提交
4063
		};
4064 4065 4066
	}
}

A
Alex Dima 已提交
4067
//#endregion
4068 4069 4070

const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
4071
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';
4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084

/**
 * @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,
4085
	letterSpacing: 0,
4086 4087 4088 4089 4090 4091 4092
};

/**
 * @internal
 */
export const EDITOR_MODEL_DEFAULTS = {
	tabSize: 4,
D
David Lechner 已提交
4093
	indentSize: 4,
4094 4095
	insertSpaces: true,
	detectIndentation: true,
4096
	trimAutoWhitespace: true,
4097
	largeFileOptimizations: true,
4098
	bracketPairColorizationOptions: { enabled: false }
4099 4100 4101 4102 4103
};

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

4106
function register<K1 extends EditorOption, V>(option: IEditorOption<K1, V>): IEditorOption<K1, V> {
A
Alex Dima 已提交
4107 4108 4109 4110
	editorOptionsRegistry[option.id] = option;
	return option;
}

A
renames  
Alex Dima 已提交
4111
export const enum EditorOption {
A
Alex Dima 已提交
4112 4113
	acceptSuggestionOnCommitCharacter,
	acceptSuggestionOnEnter,
A
Alex Dima 已提交
4114
	accessibilitySupport,
I
isidor 已提交
4115
	accessibilityPageSize,
4116
	ariaLabel,
A
Alex Dima 已提交
4117
	autoClosingBrackets,
4118
	autoClosingDelete,
A
Alex Dima 已提交
4119 4120 4121 4122 4123
	autoClosingOvertype,
	autoClosingQuotes,
	autoIndent,
	automaticLayout,
	autoSurround,
4124
	bracketPairColorization,
H
Henning Dieterichs 已提交
4125
	guides,
A
Alex Dima 已提交
4126
	codeLens,
4127 4128
	codeLensFontFamily,
	codeLensFontSize,
A
Alex Dima 已提交
4129
	colorDecorators,
4130
	columnSelection,
A
Alex Dima 已提交
4131
	comments,
A
Alex Dima 已提交
4132
	contextmenu,
A
Alex Dima 已提交
4133 4134 4135 4136 4137
	copyWithSyntaxHighlighting,
	cursorBlinking,
	cursorSmoothCaretAnimation,
	cursorStyle,
	cursorSurroundingLines,
4138
	cursorSurroundingLinesStyle,
A
Alex Dima 已提交
4139 4140
	cursorWidth,
	disableLayerHinting,
4141
	disableMonospaceOptimizations,
4142
	domReadOnly,
A
Alex Dima 已提交
4143 4144 4145
	dragAndDrop,
	emptySelectionClipboard,
	extraEditorClassName,
A
Alex Dima 已提交
4146
	fastScrollSensitivity,
A
Alex Dima 已提交
4147
	find,
A
Alex Dima 已提交
4148
	fixedOverflowWidgets,
A
Alex Dima 已提交
4149
	folding,
A
Alex Dima 已提交
4150
	foldingStrategy,
4151
	foldingHighlight,
W
Wenlu Wang 已提交
4152
	foldingImportsByDefault,
4153
	unfoldOnClickAfterEndOfLine,
4154 4155
	fontFamily,
	fontInfo,
A
Alex Dima 已提交
4156
	fontLigatures,
4157 4158
	fontSize,
	fontWeight,
A
Alex Dima 已提交
4159 4160
	formatOnPaste,
	formatOnType,
A
Alex Dima 已提交
4161
	glyphMargin,
A
Alex Dima 已提交
4162
	gotoLocation,
A
Alex Dima 已提交
4163
	hideCursorInOverviewRuler,
A
Alex Dima 已提交
4164
	hover,
A
Alex Dima 已提交
4165
	inDiffEditor,
4166
	inlineSuggest,
4167
	letterSpacing,
A
Alex Dima 已提交
4168
	lightbulb,
A
Alex Dima 已提交
4169
	lineDecorationsWidth,
A
Alex Dima 已提交
4170
	lineHeight,
A
Alex Dima 已提交
4171
	lineNumbers,
A
Alex Dima 已提交
4172
	lineNumbersMinChars,
4173
	linkedEditing,
A
Alex Dima 已提交
4174 4175
	links,
	matchBrackets,
A
Alex Dima 已提交
4176
	minimap,
A
Alex Dima 已提交
4177
	mouseStyle,
A
Alex Dima 已提交
4178
	mouseWheelScrollSensitivity,
A
Alex Dima 已提交
4179 4180 4181
	mouseWheelZoom,
	multiCursorMergeOverlapping,
	multiCursorModifier,
4182
	multiCursorPaste,
A
Alex Dima 已提交
4183
	occurrencesHighlight,
A
Alex Dima 已提交
4184 4185
	overviewRulerBorder,
	overviewRulerLanes,
B
Bailey 已提交
4186
	padding,
A
Alex Dima 已提交
4187
	parameterHints,
4188
	peekWidgetDefaultFocus,
4189
	definitionLinkOpensInPeek,
A
Alex Dima 已提交
4190
	quickSuggestions,
A
Alex Dima 已提交
4191
	quickSuggestionsDelay,
4192
	readOnly,
P
Rename  
Pine Wu 已提交
4193
	renameOnType,
A
Alex Dima 已提交
4194
	renderControlCharacters,
A
Alex Dima 已提交
4195
	renderFinalNewline,
A
Alex Dima 已提交
4196
	renderLineHighlight,
4197
	renderLineHighlightOnlyWhenFocus,
4198
	renderValidationDecorations,
A
Alex Dima 已提交
4199 4200 4201 4202
	renderWhitespace,
	revealHorizontalRightPadding,
	roundedSelection,
	rulers,
A
Alex Dima 已提交
4203
	scrollbar,
A
Alex Dima 已提交
4204 4205
	scrollBeyondLastColumn,
	scrollBeyondLastLine,
4206
	scrollPredominantAxis,
A
Alex Dima 已提交
4207
	selectionClipboard,
A
Alex Dima 已提交
4208
	selectionHighlight,
A
Alex Dima 已提交
4209
	selectOnLineNumbers,
A
Alex Dima 已提交
4210
	showFoldingControls,
A
Alex Dima 已提交
4211
	showUnused,
A
Alex Dima 已提交
4212
	snippetSuggestions,
4213
	smartSelect,
A
Alex Dima 已提交
4214
	smoothScrolling,
4215
	stickyTabStops,
A
Alex Dima 已提交
4216
	stopRenderingLineAfter,
A
Alex Dima 已提交
4217
	suggest,
A
Alex Dima 已提交
4218 4219
	suggestFontSize,
	suggestLineHeight,
A
Alex Dima 已提交
4220
	suggestOnTriggerCharacters,
A
Alex Dima 已提交
4221 4222
	suggestSelection,
	tabCompletion,
4223
	tabIndex,
4224
	unusualLineTerminators,
4225
	useShadowDOM,
A
Alex Dima 已提交
4226 4227
	useTabStops,
	wordSeparators,
A
Alex Dima 已提交
4228 4229 4230 4231
	wordWrap,
	wordWrapBreakAfterCharacters,
	wordWrapBreakBeforeCharacters,
	wordWrapColumn,
4232 4233
	wordWrapOverride1,
	wordWrapOverride2,
A
Alex Dima 已提交
4234
	wrappingIndent,
4235
	wrappingStrategy,
4236
	showDeprecated,
4237
	inlayHints,
A
Alex Dima 已提交
4238
	// Leave these at the end (because they have dependencies!)
A
Alex Dima 已提交
4239
	editorClassName,
A
Alex Dima 已提交
4240
	pixelRatio,
A
Alex Dima 已提交
4241
	tabFocusMode,
A
Alex Dima 已提交
4242 4243
	layoutInfo,
	wrappingInfo,
4244 4245
}

A
renames  
Alex Dima 已提交
4246
export const EditorOptions = {
4247 4248 4249 4250
	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.") }
	)),
4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264
	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 已提交
4265
	accessibilityPageSize: register(new EditorIntOption(EditorOption.accessibilityPageSize, 'accessibilityPageSize', 10, 1, Constants.MAX_SAFE_SMALL_INTEGER,
4266
		{
4267
			description: nls.localize('accessibilityPageSize', "Controls the number of lines in the editor that can be read out by a screen reader at once. When we detect a screen reader we automatically set the default to be 500. Warning: this has a performance implication for numbers larger than the default.")
4268
		})),
4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285
	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.")
		}
	)),
4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298
	autoClosingDelete: register(new EditorStringEnumOption(
		EditorOption.autoClosingDelete, 'autoClosingDelete',
		'auto' as 'always' | 'auto' | 'never',
		['always', 'auto', 'never'] as const,
		{
			enumDescriptions: [
				'',
				nls.localize('editor.autoClosingDelete.auto', "Remove adjacent closing quotes or brackets only if they were automatically inserted."),
				'',
			],
			description: nls.localize('autoClosingDelete', "Controls whether the editor should remove adjacent closing quotes or brackets when deleting.")
		}
	)),
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
	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 已提交
4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340
	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.")
		}
4341 4342 4343 4344
	)),
	automaticLayout: register(new EditorBooleanOption(
		EditorOption.automaticLayout, 'automaticLayout', false,
	)),
4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355
	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."),
				''
			],
4356
			description: nls.localize('autoSurround', "Controls whether the editor should automatically surround selections when typing quotes or brackets.")
4357 4358
		}
	)),
4359
	bracketPairColorization: register(new BracketPairColorization()),
H
Henning Dieterichs 已提交
4360
	bracketPairGuides: register(new GuideOptions()),
4361 4362
	stickyTabStops: register(new EditorBooleanOption(
		EditorOption.stickyTabStops, 'stickyTabStops', false,
4363
		{ description: nls.localize('stickyTabStops', "Emulate selection behavior of tab characters when using spaces for indentation. Selection will stick to tab stops.") }
4364
	)),
4365 4366 4367 4368
	codeLens: register(new EditorBooleanOption(
		EditorOption.codeLens, 'codeLens', true,
		{ description: nls.localize('codeLens', "Controls whether the editor shows CodeLens.") }
	)),
4369 4370
	codeLensFontFamily: register(new EditorStringOption(
		EditorOption.codeLensFontFamily, 'codeLensFontFamily', '',
4371
		{ description: nls.localize('codeLensFontFamily', "Controls the font family for CodeLens.") }
4372 4373 4374 4375 4376 4377
	)),
	codeLensFontSize: register(new EditorIntOption(EditorOption.codeLensFontSize, 'codeLensFontSize', 0, 0, 100, {
		type: 'number',
		default: 0,
		minimum: 0,
		maximum: 100,
4378
		markdownDescription: nls.localize('codeLensFontSize', "Controls the font size in pixels for CodeLens. When set to `0`, the 90% of `#editor.fontSize#` is used.")
4379
	})),
4380 4381 4382 4383
	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.") }
	)),
4384 4385 4386 4387
	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 已提交
4388
	comments: register(new EditorComments()),
4389 4390 4391 4392 4393 4394 4395
	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.") }
	)),
4396 4397 4398 4399 4400 4401 4402
	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.") }
	)),
4403 4404 4405 4406
	cursorSmoothCaretAnimation: register(new EditorBooleanOption(
		EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation', false,
		{ description: nls.localize('cursorSmoothCaretAnimation', "Controls whether the smooth caret animation should be enabled.") }
	)),
4407 4408 4409 4410 4411 4412 4413 4414 4415 4416
	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,
4417
		{ 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.") }
4418
	)),
4419 4420 4421 4422 4423 4424
	cursorSurroundingLinesStyle: register(new EditorStringEnumOption(
		EditorOption.cursorSurroundingLinesStyle, 'cursorSurroundingLinesStyle',
		'default' as 'default' | 'all',
		['default', 'all'] as const,
		{
			enumDescriptions: [
G
Greg Van Liew 已提交
4425
				nls.localize('cursorSurroundingLinesStyle.default', "`cursorSurroundingLines` is enforced only when triggered via the keyboard or API."),
4426 4427
				nls.localize('cursorSurroundingLinesStyle.all', "`cursorSurroundingLines` is enforced always.")
			],
G
Greg Van Liew 已提交
4428
			description: nls.localize('cursorSurroundingLinesStyle', "Controls when `cursorSurroundingLines` should be enforced.")
4429 4430
		}
	)),
4431 4432 4433 4434 4435
	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`.") }
	)),
4436 4437 4438
	disableLayerHinting: register(new EditorBooleanOption(
		EditorOption.disableLayerHinting, 'disableLayerHinting', false,
	)),
4439 4440 4441
	disableMonospaceOptimizations: register(new EditorBooleanOption(
		EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false
	)),
4442 4443 4444
	domReadOnly: register(new EditorBooleanOption(
		EditorOption.domReadOnly, 'domReadOnly', false,
	)),
4445 4446 4447 4448
	dragAndDrop: register(new EditorBooleanOption(
		EditorOption.dragAndDrop, 'dragAndDrop', true,
		{ description: nls.localize('dragAndDrop', "Controls whether the editor should allow moving selections via drag and drop.") }
	)),
4449 4450 4451 4452 4453 4454 4455 4456 4457 4458
	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()),
4459 4460 4461 4462 4463 4464 4465
	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.") }
	)),
4466 4467 4468 4469
	foldingStrategy: register(new EditorStringEnumOption(
		EditorOption.foldingStrategy, 'foldingStrategy',
		'auto' as 'auto' | 'indentation',
		['auto', 'indentation'] as const,
4470 4471 4472 4473 4474 4475 4476
		{
			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.")
		}
4477
	)),
4478 4479 4480
	foldingHighlight: register(new EditorBooleanOption(
		EditorOption.foldingHighlight, 'foldingHighlight', true,
		{ description: nls.localize('foldingHighlight', "Controls whether the editor should highlight folded ranges.") }
4481
	)),
W
Wenlu Wang 已提交
4482 4483
	foldingImportsByDefault: register(new EditorBooleanOption(
		EditorOption.foldingImportsByDefault, 'foldingImportsByDefault', false,
I
isidor 已提交
4484
		{ description: nls.localize('foldingImportsByDefault', "Controls whether the editor automatically collapses import ranges.") }
W
Wenlu Wang 已提交
4485
	)),
4486 4487 4488
	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.") }
4489
	)),
4490 4491 4492 4493 4494
	fontFamily: register(new EditorStringOption(
		EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
		{ description: nls.localize('fontFamily', "Controls the font family.") }
	)),
	fontInfo: register(new EditorFontInfo()),
4495
	fontLigatures2: register(new EditorFontLigatures()),
4496
	fontSize: register(new EditorFontSize()),
4497
	fontWeight: register(new EditorFontWeight()),
4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509
	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.") }
	)),
4510
	gotoLocation: register(new EditorGoToLocation()),
4511 4512 4513 4514
	hideCursorInOverviewRuler: register(new EditorBooleanOption(
		EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false,
		{ description: nls.localize('hideCursorInOverviewRuler', "Controls whether the cursor should be hidden in the overview ruler.") }
	)),
4515
	hover: register(new EditorHover()),
4516
	inDiffEditor: register(new EditorBooleanOption(
4517
		EditorOption.inDiffEditor, 'inDiffEditor', false
4518
	)),
4519 4520 4521 4522 4523 4524
	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()),
4525
	lineDecorationsWidth: register(new SimpleEditorOption(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10 as number | string)),
4526 4527 4528 4529
	lineHeight: register(new EditorLineHeight()),
	lineNumbers: register(new EditorRenderLineNumbersOption()),
	lineNumbersMinChars: register(new EditorIntOption(
		EditorOption.lineNumbersMinChars, 'lineNumbersMinChars',
4530
		5, 1, 300
4531
	)),
4532 4533 4534 4535
	linkedEditing: register(new EditorBooleanOption(
		EditorOption.linkedEditing, 'linkedEditing', false,
		{ description: nls.localize('linkedEditing', "Controls whether the editor has linked editing enabled. Depending on the language, related symbols, e.g. HTML tags, are updated while editing.") }
	)),
4536 4537 4538 4539
	links: register(new EditorBooleanOption(
		EditorOption.links, 'links', true,
		{ description: nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }
	)),
4540 4541 4542 4543 4544
	matchBrackets: register(new EditorStringEnumOption(
		EditorOption.matchBrackets, 'matchBrackets',
		'always' as 'never' | 'near' | 'always',
		['always', 'near', 'never'] as const,
		{ description: nls.localize('matchBrackets', "Highlight matching brackets.") }
4545
	)),
4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556
	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.") }
	)),
4557 4558 4559 4560 4561 4562 4563 4564
	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.") }
	)),
4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580
	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.'
				]
J
Jake Vossen 已提交
4581
			}, "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).")
4582 4583
		}
	)),
4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595
	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.")
		}
	)),
4596 4597 4598 4599 4600 4601 4602 4603
	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.") }
	)),
4604 4605
	overviewRulerLanes: register(new EditorIntOption(
		EditorOption.overviewRulerLanes, 'overviewRulerLanes',
4606
		3, 0, 3
4607
	)),
B
Bailey 已提交
4608
	padding: register(new EditorPadding()),
4609
	parameterHints: register(new EditorParameterHints()),
4610 4611 4612 4613 4614 4615
	peekWidgetDefaultFocus: register(new EditorStringEnumOption(
		EditorOption.peekWidgetDefaultFocus, 'peekWidgetDefaultFocus',
		'tree' as 'tree' | 'editor',
		['tree', 'editor'] as const,
		{
			enumDescriptions: [
4616
				nls.localize('peekWidgetDefaultFocus.tree', "Focus the tree when opening peek"),
4617 4618 4619 4620
				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.")
		}
4621
	)),
4622 4623
	definitionLinkOpensInPeek: register(new EditorBooleanOption(
		EditorOption.definitionLinkOpensInPeek, 'definitionLinkOpensInPeek', false,
4624
		{ description: nls.localize('definitionLinkOpensInPeek', "Controls whether the Go to Definition mouse gesture always opens the peek widget.") }
4625
	)),
4626 4627 4628 4629 4630 4631
	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.") }
	)),
4632 4633 4634
	readOnly: register(new EditorBooleanOption(
		EditorOption.readOnly, 'readOnly', false,
	)),
P
Rename  
Pine Wu 已提交
4635 4636
	renameOnType: register(new EditorBooleanOption(
		EditorOption.renameOnType, 'renameOnType', false,
4637
		{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type."), markdownDeprecationMessage: nls.localize('renameOnTypeDeprecate', "Deprecated, use `editor.linkedEditing` instead.") }
P
Rename  
Pine Wu 已提交
4638
	)),
4639 4640 4641 4642 4643 4644 4645 4646
	renderControlCharacters: register(new EditorBooleanOption(
		EditorOption.renderControlCharacters, 'renderControlCharacters', false,
		{ description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters.") }
	)),
	renderFinalNewline: register(new EditorBooleanOption(
		EditorOption.renderFinalNewline, 'renderFinalNewline', true,
		{ description: nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }
	)),
4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660
	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.")
		}
	)),
4661 4662
	renderLineHighlightOnlyWhenFocus: register(new EditorBooleanOption(
		EditorOption.renderLineHighlightOnlyWhenFocus, 'renderLineHighlightOnlyWhenFocus', false,
4663
		{ description: nls.localize('renderLineHighlightOnlyWhenFocus', "Controls if the editor should render the current line highlight only when the editor is focused.") }
4664
	)),
4665 4666 4667 4668 4669
	renderValidationDecorations: register(new EditorStringEnumOption(
		EditorOption.renderValidationDecorations, 'renderValidationDecorations',
		'editable' as 'editable' | 'on' | 'off',
		['editable', 'on', 'off'] as const
	)),
4670 4671
	renderWhitespace: register(new EditorStringEnumOption(
		EditorOption.renderWhitespace, 'renderWhitespace',
4672 4673
		'selection' as 'selection' | 'none' | 'boundary' | 'trailing' | 'all',
		['none', 'boundary', 'selection', 'trailing', 'all'] as const,
4674 4675 4676 4677 4678
		{
			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."),
4679
				nls.localize('renderWhitespace.trailing', "Render only trailing whitespace characters."),
4680 4681 4682 4683 4684 4685 4686 4687 4688
				''
			],
			description: nls.localize('renderWhitespace', "Controls how the editor should render whitespace characters.")
		}
	)),
	revealHorizontalRightPadding: register(new EditorIntOption(
		EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding',
		30, 0, 1000,
	)),
4689 4690 4691 4692
	roundedSelection: register(new EditorBooleanOption(
		EditorOption.roundedSelection, 'roundedSelection', true,
		{ description: nls.localize('roundedSelection', "Controls whether selections should have rounded corners.") }
	)),
4693 4694 4695 4696 4697 4698 4699
	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.") }
	)),
4700 4701 4702 4703
	scrollBeyondLastLine: register(new EditorBooleanOption(
		EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true,
		{ description: nls.localize('scrollBeyondLastLine', "Controls whether the editor will scroll beyond the last line.") }
	)),
4704 4705 4706
	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.") }
4707
	)),
4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721
	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,
	)),
4722 4723 4724 4725
	showFoldingControls: register(new EditorStringEnumOption(
		EditorOption.showFoldingControls, 'showFoldingControls',
		'mouseover' as 'always' | 'mouseover',
		['always', 'mouseover'] as const,
4726 4727 4728 4729 4730 4731 4732
		{
			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.")
		}
4733
	)),
4734 4735 4736 4737
	showUnused: register(new EditorBooleanOption(
		EditorOption.showUnused, 'showUnused', true,
		{ description: nls.localize('showUnused', "Controls fading out of unused code.") }
	)),
4738 4739 4740 4741
	showDeprecated: register(new EditorBooleanOption(
		EditorOption.showDeprecated, 'showDeprecated', true,
		{ description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") }
	)),
4742
	inlayHints: register(new EditorInlayHints()),
4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756
	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.")
		}
	)),
4757
	smartSelect: register(new SmartSelect()),
4758 4759 4760 4761
	smoothScrolling: register(new EditorBooleanOption(
		EditorOption.smoothScrolling, 'smoothScrolling', false,
		{ description: nls.localize('smoothScrolling', "Controls whether the editor will scroll using an animation.") }
	)),
4762 4763 4764 4765 4766
	stopRenderingLineAfter: register(new EditorIntOption(
		EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter',
		10000, -1, Constants.MAX_SAFE_SMALL_INTEGER,
	)),
	suggest: register(new EditorSuggest()),
4767
	inlineSuggest: register(new InlineEditorSuggest()),
4768 4769 4770 4771 4772 4773 4774 4775
	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,
4776
		{ markdownDescription: nls.localize('suggestLineHeight', "Line height for the suggest widget. When set to `0`, the value of `#editor.lineHeight#` is used. The minimum value is 8.") }
4777
	)),
4778 4779 4780 4781
	suggestOnTriggerCharacters: register(new EditorBooleanOption(
		EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true,
		{ description: nls.localize('suggestOnTriggerCharacters', "Controls whether suggestions should automatically show up when typing trigger characters.") }
	)),
4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807
	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.")
		}
	)),
4808 4809 4810 4811
	tabIndex: register(new EditorIntOption(
		EditorOption.tabIndex, 'tabIndex',
		0, -1, Constants.MAX_SAFE_SMALL_INTEGER
	)),
4812 4813
	unusualLineTerminators: register(new EditorStringEnumOption(
		EditorOption.unusualLineTerminators, 'unusualLineTerminators',
4814 4815
		'prompt' as 'auto' | 'off' | 'prompt',
		['auto', 'off', 'prompt'] as const,
4816 4817
		{
			enumDescriptions: [
4818
				nls.localize('unusualLineTerminators.auto', "Unusual line terminators are automatically removed."),
4819 4820 4821 4822 4823 4824
				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.")
		}
	)),
4825 4826 4827
	useShadowDOM: register(new EditorBooleanOption(
		EditorOption.useShadowDOM, 'useShadowDOM', true
	)),
4828 4829 4830 4831
	useTabStops: register(new EditorBooleanOption(
		EditorOption.useTabStops, 'useTabStops', true,
		{ description: nls.localize('useTabStops', "Inserting and deleting whitespace follows tab stops.") }
	)),
4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868
	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',
4869
		' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887
	)),
	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`.")
		}
	)),
4888 4889 4890 4891 4892 4893 4894 4895 4896
	wordWrapOverride1: register(new EditorStringEnumOption(
		EditorOption.wordWrapOverride1, 'wordWrapOverride1',
		'inherit' as 'off' | 'on' | 'inherit',
		['off', 'on', 'inherit'] as const
	)),
	wordWrapOverride2: register(new EditorStringEnumOption(
		EditorOption.wordWrapOverride2, 'wordWrapOverride2',
		'inherit' as 'off' | 'on' | 'inherit',
		['off', 'on', 'inherit'] as const
4897
	)),
4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912
	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."),
		}
	)),
4913 4914 4915 4916
	wrappingStrategy: register(new EditorStringEnumOption(
		EditorOption.wrappingStrategy, 'wrappingStrategy',
		'simple' as 'simple' | 'advanced',
		['simple', 'advanced'] as const,
4917 4918
		{
			enumDescriptions: [
4919 4920
				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.")
4921
			],
4922
			description: nls.localize('wrappingStrategy', "Controls the algorithm that computes wrapping points.")
4923 4924
		}
	)),
A
Alex Dima 已提交
4925

A
Alex Dima 已提交
4926
	// Leave these at the end (because they have dependencies!)
4927 4928
	editorClassName: register(new EditorClassName()),
	pixelRatio: register(new EditorPixelRatio()),
A
Alex Dima 已提交
4929
	tabFocusMode: register(new EditorTabFocusMode()),
4930
	layoutInfo: register(new EditorLayoutInfoComputer()),
4931
	wrappingInfo: register(new EditorWrappingInfoComputer())
4932
};
A
Alex Dima 已提交
4933

A
Alex Dima 已提交
4934 4935 4936
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;
4937
export type FindComputedEditorOptionValueById<T extends EditorOption> = NonNullable<ComputedEditorOptionValue<EditorOptionsType[FindEditorOptionsKeyById<T>]>>;