Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/config/editorOptions.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as arrays from '../../../base/common/arrays.js';
7
import { IMarkdownString } from '../../../base/common/htmlContent.js';
8
import { IJSONSchema } from '../../../base/common/jsonSchema.js';
9
import * as objects from '../../../base/common/objects.js';
10
import * as platform from '../../../base/common/platform.js';
11
import { ScrollbarVisibility } from '../../../base/common/scrollable.js';
12
import { Constants } from '../../../base/common/uint.js';
13
import { FontInfo } from './fontInfo.js';
14
import { EDITOR_MODEL_DEFAULTS } from '../core/misc/textModelDefaults.js';
15
import { USUAL_WORD_SEPARATORS } from '../core/wordHelper.js';
16
import * as nls from '../../../nls.js';
17
import { AccessibilitySupport } from '../../../platform/accessibility/common/accessibility.js';
18
import { IConfigurationPropertySchema } from '../../../platform/configuration/common/configurationRegistry.js';
19
20
//#region typed options
21
22
/**
23
* Configuration options for auto closing quotes and brackets
24
*/
25
export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';
26
27
/**
28
* Configuration options for auto wrapping quotes and brackets
29
*/
30
export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never';
31
32
/**
33
* Configuration options for typing over closing quotes or brackets
34
*/
35
export type EditorAutoClosingEditStrategy = 'always' | 'auto' | 'never';
36
37
/**
38
* Configuration options for auto indentation in the editor
39
*/
40
export const enum EditorAutoIndentStrategy {
41
None = 0,
42
Keep = 1,
43
Brackets = 2,
44
Advanced = 3,
45
Full = 4
46
}
47
48
/**
49
* Configuration options for the editor.
50
*/
51
export interface IEditorOptions {
52
/**
53
* This editor is used inside a diff editor.
54
*/
55
inDiffEditor?: boolean;
56
/**
57
* This editor is allowed to use variable line heights.
58
*/
59
allowVariableLineHeights?: boolean;
60
/**
61
* This editor is allowed to use variable font-sizes and font-families
62
*/
63
allowVariableFonts?: boolean;
64
/**
65
* This editor is allowed to use variable font-sizes and font-families in accessibility mode
66
*/
67
allowVariableFontsInAccessibilityMode?: boolean;
68
/**
69
* The aria label for the editor's textarea (when it is focused).
70
*/
71
ariaLabel?: string;
72
73
/**
74
* Whether the aria-required attribute should be set on the editors textarea.
75
*/
76
ariaRequired?: boolean;
77
/**
78
* Control whether a screen reader announces inline suggestion content immediately.
79
*/
80
screenReaderAnnounceInlineSuggestion?: boolean;
81
/**
82
* The `tabindex` property of the editor's textarea
83
*/
84
tabIndex?: number;
85
/**
86
* Render vertical lines at the specified columns.
87
* Defaults to empty array.
88
*/
89
rulers?: (number | IRulerOption)[];
90
/**
91
* Locales used for segmenting lines into words when doing word related navigations or operations.
92
*
93
* Specify the BCP 47 language tag of the word you wish to recognize (e.g., ja, zh-CN, zh-Hant-TW, etc.).
94
* Defaults to empty array
95
*/
96
wordSegmenterLocales?: string | string[];
97
/**
98
* A string containing the word separators used when doing word navigation.
99
* Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
100
*/
101
wordSeparators?: string;
102
/**
103
* Enable Linux primary clipboard.
104
* Defaults to true.
105
*/
106
selectionClipboard?: boolean;
107
/**
108
* Control the rendering of line numbers.
109
* If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
110
* Otherwise, if it is a truthy, line numbers will be rendered normally (equivalent of using an identity function).
111
* Otherwise, line numbers will not be rendered.
112
* Defaults to `on`.
113
*/
114
lineNumbers?: LineNumbersType;
115
/**
116
* Controls the minimal number of visible leading and trailing lines surrounding the cursor.
117
* Defaults to 0.
118
*/
119
cursorSurroundingLines?: number;
120
/**
121
* Controls when `cursorSurroundingLines` should be enforced
122
* Defaults to `default`, `cursorSurroundingLines` is not enforced when cursor position is changed
123
* by mouse.
124
*/
125
cursorSurroundingLinesStyle?: 'default' | 'all';
126
/**
127
* Render last line number when the file ends with a newline.
128
* Defaults to 'on' for Windows and macOS and 'dimmed' for Linux.
129
*/
130
renderFinalNewline?: 'on' | 'off' | 'dimmed';
131
/**
132
* Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
133
* Defaults to 'prompt'.
134
*/
135
unusualLineTerminators?: 'auto' | 'off' | 'prompt';
136
/**
137
* Should the corresponding line be selected when clicking on the line number?
138
* Defaults to true.
139
*/
140
selectOnLineNumbers?: boolean;
141
/**
142
* Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits.
143
* Defaults to 5.
144
*/
145
lineNumbersMinChars?: number;
146
/**
147
* Enable the rendering of the glyph margin.
148
* Defaults to true in vscode and to false in monaco-editor.
149
*/
150
glyphMargin?: boolean;
151
/**
152
* The width reserved for line decorations (in px).
153
* Line decorations are placed between line numbers and the editor content.
154
* You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch.
155
* Defaults to 10.
156
*/
157
lineDecorationsWidth?: number | string;
158
/**
159
* When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle.
160
* This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport.
161
* Defaults to 30 (px).
162
*/
163
revealHorizontalRightPadding?: number;
164
/**
165
* Render the editor selection with rounded borders.
166
* Defaults to true.
167
*/
168
roundedSelection?: boolean;
169
/**
170
* Class name to be added to the editor.
171
*/
172
extraEditorClassName?: string;
173
/**
174
* Should the editor be read only. See also `domReadOnly`.
175
* Defaults to false.
176
*/
177
readOnly?: boolean;
178
/**
179
* The message to display when the editor is readonly.
180
*/
181
readOnlyMessage?: IMarkdownString;
182
/**
183
* Should the textarea used for input use the DOM `readonly` attribute.
184
* Defaults to false.
185
*/
186
domReadOnly?: boolean;
187
/**
188
* Enable linked editing.
189
* Defaults to false.
190
*/
191
linkedEditing?: boolean;
192
/**
193
* deprecated, use linkedEditing instead
194
*/
195
renameOnType?: boolean;
196
/**
197
* Should the editor render validation decorations.
198
* Defaults to editable.
199
*/
200
renderValidationDecorations?: 'editable' | 'on' | 'off';
201
/**
202
* Control the behavior and rendering of the scrollbars.
203
*/
204
scrollbar?: IEditorScrollbarOptions;
205
/**
206
* Control the behavior of sticky scroll options
207
*/
208
stickyScroll?: IEditorStickyScrollOptions;
209
/**
210
* Control the behavior and rendering of the minimap.
211
*/
212
minimap?: IEditorMinimapOptions;
213
/**
214
* Control the behavior of the find widget.
215
*/
216
find?: IEditorFindOptions;
217
/**
218
* Display overflow widgets as `fixed`.
219
* Defaults to `false`.
220
*/
221
fixedOverflowWidgets?: boolean;
222
/**
223
* Allow content widgets and overflow widgets to overflow the editor viewport.
224
* Defaults to `true`.
225
*/
226
allowOverflow?: boolean;
227
/**
228
* The number of vertical lanes the overview ruler should render.
229
* Defaults to 3.
230
*/
231
overviewRulerLanes?: number;
232
/**
233
* Controls if a border should be drawn around the overview ruler.
234
* Defaults to `true`.
235
*/
236
overviewRulerBorder?: boolean;
237
/**
238
* Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
239
* Defaults to 'blink'.
240
*/
241
cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
242
/**
243
* Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
244
* Defaults to false.
245
*/
246
mouseWheelZoom?: boolean;
247
/**
248
* Control the mouse pointer style, either 'text' or 'default' or 'copy'
249
* Defaults to 'text'
250
*/
251
mouseStyle?: 'text' | 'default' | 'copy';
252
/**
253
* Enable smooth caret animation.
254
* Defaults to 'off'.
255
*/
256
cursorSmoothCaretAnimation?: 'off' | 'explicit' | 'on';
257
/**
258
* Control the cursor style in insert mode.
259
* Defaults to 'line'.
260
*/
261
cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
262
/**
263
* Control the cursor style in overtype mode.
264
* Defaults to 'block'.
265
*/
266
overtypeCursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
267
/**
268
* Controls whether paste in overtype mode should overwrite or insert.
269
*/
270
overtypeOnPaste?: boolean;
271
/**
272
* Control the width of the cursor when cursorStyle is set to 'line'
273
*/
274
cursorWidth?: number;
275
/**
276
* Control the height of the cursor when cursorStyle is set to 'line'
277
*/
278
cursorHeight?: number;
279
/**
280
* Enable font ligatures.
281
* Defaults to false.
282
*/
283
fontLigatures?: boolean | string;
284
/**
285
* Enable font variations.
286
* Defaults to false.
287
*/
288
fontVariations?: boolean | string;
289
/**
290
* Controls whether to use default color decorations or not using the default document color provider
291
*/
292
defaultColorDecorators?: 'auto' | 'always' | 'never';
293
/**
294
* Disable the use of `transform: translate3d(0px, 0px, 0px)` for the editor margin and lines layers.
295
* The usage of `transform: translate3d(0px, 0px, 0px)` acts as a hint for browsers to create an extra layer.
296
* Defaults to false.
297
*/
298
disableLayerHinting?: boolean;
299
/**
300
* Disable the optimizations for monospace fonts.
301
* Defaults to false.
302
*/
303
disableMonospaceOptimizations?: boolean;
304
/**
305
* Should the cursor be hidden in the overview ruler.
306
* Defaults to false.
307
*/
308
hideCursorInOverviewRuler?: boolean;
309
/**
310
* Enable that scrolling can go one screen size after the last line.
311
* Defaults to true.
312
*/
313
scrollBeyondLastLine?: boolean;
314
/**
315
* Scroll editor on middle click
316
*/
317
scrollOnMiddleClick?: boolean;
318
/**
319
* Enable that scrolling can go beyond the last column by a number of columns.
320
* Defaults to 5.
321
*/
322
scrollBeyondLastColumn?: number;
323
/**
324
* Enable that the editor animates scrolling to a position.
325
* Defaults to false.
326
*/
327
smoothScrolling?: boolean;
328
/**
329
* Enable that the editor will install a ResizeObserver to check if its container dom node size has changed.
330
* Defaults to false.
331
*/
332
automaticLayout?: boolean;
333
/**
334
* Control the wrapping of the editor.
335
* When `wordWrap` = "off", the lines will never wrap.
336
* When `wordWrap` = "on", the lines will wrap at the viewport width.
337
* When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
338
* When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
339
* Defaults to "off".
340
*/
341
wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
342
/**
343
* Override the `wordWrap` setting.
344
*/
345
wordWrapOverride1?: 'off' | 'on' | 'inherit';
346
/**
347
* Override the `wordWrapOverride1` setting.
348
*/
349
wordWrapOverride2?: 'off' | 'on' | 'inherit';
350
/**
351
* Control the wrapping of the editor.
352
* When `wordWrap` = "off", the lines will never wrap.
353
* When `wordWrap` = "on", the lines will wrap at the viewport width.
354
* When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
355
* When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
356
* Defaults to 80.
357
*/
358
wordWrapColumn?: number;
359
/**
360
* Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
361
* Defaults to 'same' in vscode and to 'none' in monaco-editor.
362
*/
363
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
364
/**
365
* Controls the wrapping strategy to use.
366
* Defaults to 'simple'.
367
*/
368
wrappingStrategy?: 'simple' | 'advanced';
369
/**
370
* Create a softwrap on every quoted "\n" literal.
371
* Defaults to false.
372
*/
373
wrapOnEscapedLineFeeds?: boolean;
374
/**
375
* Configure word wrapping characters. A break will be introduced before these characters.
376
*/
377
wordWrapBreakBeforeCharacters?: string;
378
/**
379
* Configure word wrapping characters. A break will be introduced after these characters.
380
*/
381
wordWrapBreakAfterCharacters?: string;
382
/**
383
* Sets whether line breaks appear wherever the text would otherwise overflow its content box.
384
* When wordBreak = 'normal', Use the default line break rule.
385
* When wordBreak = 'keepAll', Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as for normal.
386
*/
387
wordBreak?: 'normal' | 'keepAll';
388
/**
389
* Performance guard: Stop rendering a line after x characters.
390
* Defaults to 10000.
391
* Use -1 to never stop rendering
392
*/
393
stopRenderingLineAfter?: number;
394
/**
395
* Configure the editor's hover.
396
*/
397
hover?: IEditorHoverOptions;
398
/**
399
* Enable detecting links and making them clickable.
400
* Defaults to true.
401
*/
402
links?: boolean;
403
/**
404
* Enable inline color decorators and color picker rendering.
405
*/
406
colorDecorators?: boolean;
407
/**
408
* Controls what is the condition to spawn a color picker from a color dectorator
409
*/
410
colorDecoratorsActivatedOn?: 'clickAndHover' | 'click' | 'hover';
411
/**
412
* Controls the max number of color decorators that can be rendered in an editor at once.
413
*/
414
colorDecoratorsLimit?: number;
415
/**
416
* Control the behaviour of comments in the editor.
417
*/
418
comments?: IEditorCommentsOptions;
419
/**
420
* Enable custom contextmenu.
421
* Defaults to true.
422
*/
423
contextmenu?: boolean;
424
/**
425
* A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
426
* Defaults to 1.
427
*/
428
mouseWheelScrollSensitivity?: number;
429
/**
430
* FastScrolling mulitplier speed when pressing `Alt`
431
* Defaults to 5.
432
*/
433
fastScrollSensitivity?: number;
434
/**
435
* Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad.
436
* Defaults to true.
437
*/
438
scrollPredominantAxis?: boolean;
439
/**
440
* Make scrolling inertial - mostly useful with touchpad on linux.
441
*/
442
inertialScroll?: boolean;
443
/**
444
* Enable that the selection with the mouse and keys is doing column selection.
445
* Defaults to false.
446
*/
447
columnSelection?: boolean;
448
/**
449
* The modifier to be used to add multiple cursors with the mouse.
450
* Defaults to 'alt'
451
*/
452
multiCursorModifier?: 'ctrlCmd' | 'alt';
453
/**
454
* Merge overlapping selections.
455
* Defaults to true
456
*/
457
multiCursorMergeOverlapping?: boolean;
458
/**
459
* Configure the behaviour when pasting a text with the line count equal to the cursor count.
460
* Defaults to 'spread'.
461
*/
462
multiCursorPaste?: 'spread' | 'full';
463
/**
464
* Controls the max number of text cursors that can be in an active editor at once.
465
*/
466
multiCursorLimit?: number;
467
/**
468
* Configure the editor's accessibility support.
469
* Defaults to 'auto'. It is best to leave this to 'auto'.
470
*/
471
accessibilitySupport?: 'auto' | 'off' | 'on';
472
/**
473
* Controls the number of lines in the editor that can be read out by a screen reader
474
*/
475
accessibilityPageSize?: number;
476
/**
477
* Suggest options.
478
*/
479
suggest?: ISuggestOptions;
480
inlineSuggest?: IInlineSuggestOptions;
481
/**
482
* Smart select options.
483
*/
484
smartSelect?: ISmartSelectOptions;
485
/**
486
*
487
*/
488
gotoLocation?: IGotoLocationOptions;
489
/**
490
* Enable quick suggestions (shadow suggestions)
491
* Defaults to true.
492
*/
493
quickSuggestions?: boolean | IQuickSuggestionsOptions;
494
/**
495
* Quick suggestions show delay (in ms)
496
* Defaults to 10 (ms)
497
*/
498
quickSuggestionsDelay?: number;
499
/**
500
* Controls the spacing around the editor.
501
*/
502
padding?: IEditorPaddingOptions;
503
/**
504
* Parameter hint options.
505
*/
506
parameterHints?: IEditorParameterHintOptions;
507
/**
508
* Options for auto closing brackets.
509
* Defaults to language defined behavior.
510
*/
511
autoClosingBrackets?: EditorAutoClosingStrategy;
512
/**
513
* Options for auto closing comments.
514
* Defaults to language defined behavior.
515
*/
516
autoClosingComments?: EditorAutoClosingStrategy;
517
/**
518
* Options for auto closing quotes.
519
* Defaults to language defined behavior.
520
*/
521
autoClosingQuotes?: EditorAutoClosingStrategy;
522
/**
523
* Options for pressing backspace near quotes or bracket pairs.
524
*/
525
autoClosingDelete?: EditorAutoClosingEditStrategy;
526
/**
527
* Options for typing over closing quotes or brackets.
528
*/
529
autoClosingOvertype?: EditorAutoClosingEditStrategy;
530
/**
531
* Options for auto surrounding.
532
* Defaults to always allowing auto surrounding.
533
*/
534
autoSurround?: EditorAutoSurroundStrategy;
535
/**
536
* Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.
537
* Defaults to advanced.
538
*/
539
autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
540
/**
541
* Boolean which controls whether to autoindent on paste
542
*/
543
autoIndentOnPaste?: boolean;
544
/**
545
* Boolean which controls whether to autoindent on paste within a string when autoIndentOnPaste is enabled.
546
*/
547
autoIndentOnPasteWithinString?: boolean;
548
/**
549
* Emulate selection behaviour of tab characters when using spaces for indentation.
550
* This means selection will stick to tab stops.
551
*/
552
stickyTabStops?: boolean;
553
/**
554
* Enable format on type.
555
* Defaults to false.
556
*/
557
formatOnType?: boolean;
558
/**
559
* Enable format on paste.
560
* Defaults to false.
561
*/
562
formatOnPaste?: boolean;
563
/**
564
* Controls if the editor should allow to move selections via drag and drop.
565
* Defaults to false.
566
*/
567
dragAndDrop?: boolean;
568
/**
569
* Enable the suggestion box to pop-up on trigger characters.
570
* Defaults to true.
571
*/
572
suggestOnTriggerCharacters?: boolean;
573
/**
574
* Accept suggestions on ENTER.
575
* Defaults to 'on'.
576
*/
577
acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
578
/**
579
* Accept suggestions on provider defined characters.
580
* Defaults to true.
581
*/
582
acceptSuggestionOnCommitCharacter?: boolean;
583
/**
584
* Enable snippet suggestions. Default to 'true'.
585
*/
586
snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none';
587
/**
588
* Copying without a selection copies the current line.
589
*/
590
emptySelectionClipboard?: boolean;
591
/**
592
* Syntax highlighting is copied.
593
*/
594
copyWithSyntaxHighlighting?: boolean;
595
/**
596
* The history mode for suggestions.
597
*/
598
suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
599
/**
600
* The font size for the suggest widget.
601
* Defaults to the editor font size.
602
*/
603
suggestFontSize?: number;
604
/**
605
* The line height for the suggest widget.
606
* Defaults to the editor line height.
607
*/
608
suggestLineHeight?: number;
609
/**
610
* Enable tab completion.
611
*/
612
tabCompletion?: 'on' | 'off' | 'onlySnippets';
613
/**
614
* Enable selection highlight.
615
* Defaults to true.
616
*/
617
selectionHighlight?: boolean;
618
/**
619
* Enable selection highlight for multiline selections.
620
* Defaults to false.
621
*/
622
selectionHighlightMultiline?: boolean;
623
/**
624
* Maximum length (in characters) for selection highlights.
625
* Set to 0 to have an unlimited length.
626
*/
627
selectionHighlightMaxLength?: number;
628
/**
629
* Enable semantic occurrences highlight.
630
* Defaults to 'singleFile'.
631
* 'off' disables occurrence highlighting
632
* 'singleFile' triggers occurrence highlighting in the current document
633
* 'multiFile' triggers occurrence highlighting across valid open documents
634
*/
635
occurrencesHighlight?: 'off' | 'singleFile' | 'multiFile';
636
/**
637
* Controls delay for occurrences highlighting
638
* Defaults to 250.
639
* Minimum value is 0
640
* Maximum value is 2000
641
*/
642
occurrencesHighlightDelay?: number;
643
/**
644
* Show code lens
645
* Defaults to true.
646
*/
647
codeLens?: boolean;
648
/**
649
* Code lens font family. Defaults to editor font family.
650
*/
651
codeLensFontFamily?: string;
652
/**
653
* Code lens font size. Default to 90% of the editor font size
654
*/
655
codeLensFontSize?: number;
656
/**
657
* Control the behavior and rendering of the code action lightbulb.
658
*/
659
lightbulb?: IEditorLightbulbOptions;
660
/**
661
* Timeout for running code actions on save.
662
*/
663
codeActionsOnSaveTimeout?: number;
664
/**
665
* Enable code folding.
666
* Defaults to true.
667
*/
668
folding?: boolean;
669
/**
670
* Selects the folding strategy. 'auto' uses the strategies contributed for the current document, 'indentation' uses the indentation based folding strategy.
671
* Defaults to 'auto'.
672
*/
673
foldingStrategy?: 'auto' | 'indentation';
674
/**
675
* Enable highlight for folded regions.
676
* Defaults to true.
677
*/
678
foldingHighlight?: boolean;
679
/**
680
* Auto fold imports folding regions.
681
* Defaults to true.
682
*/
683
foldingImportsByDefault?: boolean;
684
/**
685
* Maximum number of foldable regions.
686
* Defaults to 5000.
687
*/
688
foldingMaximumRegions?: number;
689
/**
690
* Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
691
* Defaults to 'mouseover'.
692
*/
693
showFoldingControls?: 'always' | 'never' | 'mouseover';
694
/**
695
* Controls whether clicking on the empty content after a folded line will unfold the line.
696
* Defaults to false.
697
*/
698
unfoldOnClickAfterEndOfLine?: boolean;
699
/**
700
* Enable highlighting of matching brackets.
701
* Defaults to 'always'.
702
*/
703
matchBrackets?: 'never' | 'near' | 'always';
704
/**
705
* Enable experimental rendering using WebGPU.
706
* Defaults to 'off'.
707
*/
708
experimentalGpuAcceleration?: 'on' | 'off';
709
/**
710
* Enable experimental whitespace rendering.
711
* Defaults to 'svg'.
712
*/
713
experimentalWhitespaceRendering?: 'svg' | 'font' | 'off';
714
/**
715
* Enable rendering of whitespace.
716
* Defaults to 'selection'.
717
*/
718
renderWhitespace?: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
719
/**
720
* Enable rendering of control characters.
721
* Defaults to true.
722
*/
723
renderControlCharacters?: boolean;
724
/**
725
* Enable rendering of current line highlight.
726
* Defaults to all.
727
*/
728
renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
729
/**
730
* Control if the current line highlight should be rendered only the editor is focused.
731
* Defaults to false.
732
*/
733
renderLineHighlightOnlyWhenFocus?: boolean;
734
/**
735
* Inserting and deleting whitespace follows tab stops.
736
*/
737
useTabStops?: boolean;
738
/**
739
* Controls whether the editor should automatically remove indentation whitespace when joining lines with Delete.
740
* Defaults to false.
741
*/
742
trimWhitespaceOnDelete?: boolean;
743
/**
744
* The font family
745
*/
746
fontFamily?: string;
747
/**
748
* The font weight
749
*/
750
fontWeight?: string;
751
/**
752
* The font size
753
*/
754
fontSize?: number;
755
/**
756
* The line height
757
*/
758
lineHeight?: number;
759
/**
760
* The letter spacing
761
*/
762
letterSpacing?: number;
763
/**
764
* Controls fading out of unused variables.
765
*/
766
showUnused?: boolean;
767
/**
768
* Controls whether to focus the inline editor in the peek widget by default.
769
* Defaults to false.
770
*/
771
peekWidgetDefaultFocus?: 'tree' | 'editor';
772
773
/**
774
* Sets a placeholder for the editor.
775
* If set, the placeholder is shown if the editor is empty.
776
*/
777
placeholder?: string | undefined;
778
779
/**
780
* Controls whether the definition link opens element in the peek widget.
781
* Defaults to false.
782
*/
783
definitionLinkOpensInPeek?: boolean;
784
/**
785
* Controls strikethrough deprecated variables.
786
*/
787
showDeprecated?: boolean;
788
/**
789
* Controls whether suggestions allow matches in the middle of the word instead of only at the beginning
790
*/
791
matchOnWordStartOnly?: boolean;
792
/**
793
* Control the behavior and rendering of the inline hints.
794
*/
795
inlayHints?: IEditorInlayHintsOptions;
796
/**
797
* Control if the editor should use shadow DOM.
798
*/
799
useShadowDOM?: boolean;
800
/**
801
* Controls the behavior of editor guides.
802
*/
803
guides?: IGuidesOptions;
804
805
/**
806
* Controls the behavior of the unicode highlight feature
807
* (by default, ambiguous and invisible characters are highlighted).
808
*/
809
unicodeHighlight?: IUnicodeHighlightOptions;
810
811
/**
812
* Configures bracket pair colorization (disabled by default).
813
*/
814
bracketPairColorization?: IBracketPairColorizationOptions;
815
816
/**
817
* Controls dropping into the editor from an external source.
818
*
819
* When enabled, this shows a preview of the drop location and triggers an `onDropIntoEditor` event.
820
*/
821
dropIntoEditor?: IDropIntoEditorOptions;
822
823
/**
824
* Sets whether the new experimental edit context should be used instead of the text area.
825
*/
826
editContext?: boolean;
827
828
/**
829
* Controls whether to render rich HTML screen reader content when the EditContext is enabled
830
*/
831
renderRichScreenReaderContent?: boolean;
832
833
/**
834
* Controls support for changing how content is pasted into the editor.
835
*/
836
pasteAs?: IPasteAsOptions;
837
838
/**
839
* Controls whether the editor / terminal receives tabs or defers them to the workbench for navigation.
840
*/
841
tabFocusMode?: boolean;
842
843
/**
844
* Controls whether the accessibility hint should be provided to screen reader users when an inline completion is shown.
845
*/
846
inlineCompletionsAccessibilityVerbose?: boolean;
847
}
848
849
/**
850
* @internal
851
* The width of the minimap gutter, in pixels.
852
*/
853
export const MINIMAP_GUTTER_WIDTH = 8;
854
855
export interface IDiffEditorBaseOptions {
856
/**
857
* Allow the user to resize the diff editor split view.
858
* Defaults to true.
859
*/
860
enableSplitViewResizing?: boolean;
861
862
/**
863
* The default ratio when rendering side-by-side editors.
864
* Must be a number between 0 and 1, min sizes apply.
865
* Defaults to 0.5
866
*/
867
splitViewDefaultRatio?: number;
868
869
/**
870
* Render the differences in two side-by-side editors.
871
* Defaults to true.
872
*/
873
renderSideBySide?: boolean;
874
875
/**
876
* When `renderSideBySide` is enabled, `useInlineViewWhenSpaceIsLimited` is set,
877
* and the diff editor has a width less than `renderSideBySideInlineBreakpoint`, the inline view is used.
878
*/
879
renderSideBySideInlineBreakpoint?: number | undefined;
880
881
/**
882
* When `renderSideBySide` is enabled, `useInlineViewWhenSpaceIsLimited` is set,
883
* and the diff editor has a width less than `renderSideBySideInlineBreakpoint`, the inline view is used.
884
*/
885
useInlineViewWhenSpaceIsLimited?: boolean;
886
887
/**
888
* If set, the diff editor is optimized for small views.
889
* Defaults to `false`.
890
*/
891
compactMode?: boolean;
892
893
/**
894
* Timeout in milliseconds after which diff computation is cancelled.
895
* Defaults to 5000.
896
*/
897
maxComputationTime?: number;
898
899
/**
900
* Maximum supported file size in MB.
901
* Defaults to 50.
902
*/
903
maxFileSize?: number;
904
905
/**
906
* Compute the diff by ignoring leading/trailing whitespace
907
* Defaults to true.
908
*/
909
ignoreTrimWhitespace?: boolean;
910
911
/**
912
* Render +/- indicators for added/deleted changes.
913
* Defaults to true.
914
*/
915
renderIndicators?: boolean;
916
917
/**
918
* Shows icons in the glyph margin to revert changes.
919
* Default to true.
920
*/
921
renderMarginRevertIcon?: boolean;
922
923
/**
924
* Indicates if the gutter menu should be rendered.
925
*/
926
renderGutterMenu?: boolean;
927
928
/**
929
* Original model should be editable?
930
* Defaults to false.
931
*/
932
originalEditable?: boolean;
933
934
/**
935
* Should the diff editor enable code lens?
936
* Defaults to false.
937
*/
938
diffCodeLens?: boolean;
939
940
/**
941
* Is the diff editor should render overview ruler
942
* Defaults to true
943
*/
944
renderOverviewRuler?: boolean;
945
946
/**
947
* Control the wrapping of the diff editor.
948
*/
949
diffWordWrap?: 'off' | 'on' | 'inherit';
950
951
/**
952
* Diff Algorithm
953
*/
954
diffAlgorithm?: 'legacy' | 'advanced';
955
956
/**
957
* Whether the diff editor aria label should be verbose.
958
*/
959
accessibilityVerbose?: boolean;
960
961
experimental?: {
962
/**
963
* Defaults to false.
964
*/
965
showMoves?: boolean;
966
967
showEmptyDecorations?: boolean;
968
969
/**
970
* Only applies when `renderSideBySide` is set to false.
971
*/
972
useTrueInlineView?: boolean;
973
};
974
975
/**
976
* Is the diff editor inside another editor
977
* Defaults to false
978
*/
979
isInEmbeddedEditor?: boolean;
980
981
/**
982
* If the diff editor should only show the difference review mode.
983
*/
984
onlyShowAccessibleDiffViewer?: boolean;
985
986
hideUnchangedRegions?: {
987
enabled?: boolean;
988
revealLineCount?: number;
989
minimumLineCount?: number;
990
contextLineCount?: number;
991
};
992
}
993
994
/**
995
* Configuration options for the diff editor.
996
*/
997
export interface IDiffEditorOptions extends IEditorOptions, IDiffEditorBaseOptions {
998
}
999
1000
/**
1001
* @internal
1002
*/
1003
export type ValidDiffEditorBaseOptions = Readonly<Required<IDiffEditorBaseOptions>>;
1004
1005
//#endregion
1006
1007
/**
1008
* An event describing that the configuration of the editor has changed.
1009
*/
1010
export class ConfigurationChangedEvent {
1011
private readonly _values: boolean[];
1012
/**
1013
* @internal
1014
*/
1015
constructor(values: boolean[]) {
1016
this._values = values;
1017
}
1018
public hasChanged(id: EditorOption): boolean {
1019
return this._values[id];
1020
}
1021
}
1022
1023
/**
1024
* All computed editor options.
1025
*/
1026
export interface IComputedEditorOptions {
1027
get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
1028
}
1029
1030
//#region IEditorOption
1031
1032
/**
1033
* @internal
1034
*/
1035
export interface IEnvironmentalOptions {
1036
readonly memory: ComputeOptionsMemory | null;
1037
readonly outerWidth: number;
1038
readonly outerHeight: number;
1039
readonly fontInfo: FontInfo;
1040
readonly extraEditorClassName: string;
1041
readonly isDominatedByLongLines: boolean;
1042
readonly viewLineCount: number;
1043
readonly lineNumbersDigitCount: number;
1044
readonly emptySelectionClipboard: boolean;
1045
readonly pixelRatio: number;
1046
readonly tabFocusMode: boolean;
1047
readonly inputMode: 'insert' | 'overtype';
1048
readonly accessibilitySupport: AccessibilitySupport;
1049
readonly glyphMarginDecorationLaneCount: number;
1050
readonly editContextSupported: boolean;
1051
}
1052
1053
/**
1054
* @internal
1055
*/
1056
export class ComputeOptionsMemory {
1057
1058
public stableMinimapLayoutInput: IMinimapLayoutInput | null;
1059
public stableFitMaxMinimapScale: number;
1060
public stableFitRemainingWidth: number;
1061
1062
constructor() {
1063
this.stableMinimapLayoutInput = null;
1064
this.stableFitMaxMinimapScale = 0;
1065
this.stableFitRemainingWidth = 0;
1066
}
1067
}
1068
1069
export interface IEditorOption<K extends EditorOption, V> {
1070
readonly id: K;
1071
readonly name: string;
1072
defaultValue: V;
1073
/**
1074
* @internal
1075
*/
1076
readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema } | undefined;
1077
/**
1078
* @internal
1079
*/
1080
validate(input: any): V;
1081
/**
1082
* @internal
1083
*/
1084
compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
1085
1086
/**
1087
* Might modify `value`.
1088
*/
1089
applyUpdate(value: V | undefined, update: V): ApplyUpdateResult<V>;
1090
}
1091
1092
/**
1093
* @internal
1094
*/
1095
type PossibleKeyName0<V> = { [K in keyof IEditorOptions]: IEditorOptions[K] extends V | undefined ? K : never }[keyof IEditorOptions];
1096
/**
1097
* @internal
1098
*/
1099
type PossibleKeyName<V> = NonNullable<PossibleKeyName0<V>>;
1100
1101
/**
1102
* @internal
1103
*/
1104
abstract class BaseEditorOption<K extends EditorOption, T, V> implements IEditorOption<K, V> {
1105
1106
public readonly id: K;
1107
public readonly name: string;
1108
public readonly defaultValue: V;
1109
public readonly schema: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema } | undefined;
1110
1111
constructor(id: K, name: PossibleKeyName<T>, defaultValue: V, schema?: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema }) {
1112
this.id = id;
1113
this.name = name;
1114
this.defaultValue = defaultValue;
1115
this.schema = schema;
1116
}
1117
1118
public applyUpdate(value: V | undefined, update: V): ApplyUpdateResult<V> {
1119
return applyUpdate(value, update);
1120
}
1121
1122
public abstract validate(input: any): V;
1123
1124
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
1125
return value;
1126
}
1127
}
1128
1129
export class ApplyUpdateResult<T> {
1130
constructor(
1131
public readonly newValue: T,
1132
public readonly didChange: boolean
1133
) { }
1134
}
1135
1136
function applyUpdate<T>(value: T | undefined, update: T): ApplyUpdateResult<T> {
1137
if (typeof value !== 'object' || typeof update !== 'object' || !value || !update) {
1138
return new ApplyUpdateResult(update, value !== update);
1139
}
1140
if (Array.isArray(value) || Array.isArray(update)) {
1141
const arrayEquals = Array.isArray(value) && Array.isArray(update) && arrays.equals(value, update);
1142
return new ApplyUpdateResult(update, !arrayEquals);
1143
}
1144
let didChange = false;
1145
for (const key in update) {
1146
if ((update as T & object).hasOwnProperty(key)) {
1147
const result = applyUpdate(value[key], update[key]);
1148
if (result.didChange) {
1149
value[key] = result.newValue;
1150
didChange = true;
1151
}
1152
}
1153
}
1154
return new ApplyUpdateResult(value, didChange);
1155
}
1156
1157
/**
1158
* @internal
1159
*/
1160
abstract class ComputedEditorOption<K extends EditorOption, V> implements IEditorOption<K, V> {
1161
1162
public readonly id: K;
1163
public readonly name: '_never_';
1164
public readonly defaultValue: V;
1165
public readonly schema: IConfigurationPropertySchema | undefined = undefined;
1166
1167
constructor(id: K) {
1168
this.id = id;
1169
this.name = '_never_';
1170
this.defaultValue = <any>undefined;
1171
}
1172
1173
public applyUpdate(value: V | undefined, update: V): ApplyUpdateResult<V> {
1174
return applyUpdate(value, update);
1175
}
1176
1177
public validate(input: any): V {
1178
return this.defaultValue;
1179
}
1180
1181
public abstract compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V;
1182
}
1183
1184
class SimpleEditorOption<K extends EditorOption, V> implements IEditorOption<K, V> {
1185
1186
public readonly id: K;
1187
public readonly name: PossibleKeyName<V>;
1188
public readonly defaultValue: V;
1189
public readonly schema: IConfigurationPropertySchema | undefined;
1190
1191
constructor(id: K, name: PossibleKeyName<V>, defaultValue: V, schema?: IConfigurationPropertySchema) {
1192
this.id = id;
1193
this.name = name;
1194
this.defaultValue = defaultValue;
1195
this.schema = schema;
1196
}
1197
1198
public applyUpdate(value: V | undefined, update: V): ApplyUpdateResult<V> {
1199
return applyUpdate(value, update);
1200
}
1201
1202
public validate(input: any): V {
1203
if (typeof input === 'undefined') {
1204
return this.defaultValue;
1205
}
1206
return input as any;
1207
}
1208
1209
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: V): V {
1210
return value;
1211
}
1212
}
1213
1214
/**
1215
* @internal
1216
*/
1217
export function boolean(value: any, defaultValue: boolean): boolean {
1218
if (typeof value === 'undefined') {
1219
return defaultValue;
1220
}
1221
if (value === 'false') {
1222
// treat the string 'false' as false
1223
return false;
1224
}
1225
return Boolean(value);
1226
}
1227
1228
class EditorBooleanOption<K extends EditorOption> extends SimpleEditorOption<K, boolean> {
1229
1230
constructor(id: K, name: PossibleKeyName<boolean>, defaultValue: boolean, schema: IConfigurationPropertySchema | undefined = undefined) {
1231
if (typeof schema !== 'undefined') {
1232
schema.type = 'boolean';
1233
schema.default = defaultValue;
1234
}
1235
super(id, name, defaultValue, schema);
1236
}
1237
1238
public override validate(input: any): boolean {
1239
return boolean(input, this.defaultValue);
1240
}
1241
}
1242
1243
/**
1244
* @internal
1245
*/
1246
export function clampedInt<T>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
1247
if (typeof value === 'undefined') {
1248
return defaultValue;
1249
}
1250
let r = parseInt(value, 10);
1251
if (isNaN(r)) {
1252
return defaultValue;
1253
}
1254
r = Math.max(minimum, r);
1255
r = Math.min(maximum, r);
1256
return r | 0;
1257
}
1258
1259
class EditorIntOption<K extends EditorOption> extends SimpleEditorOption<K, number> {
1260
1261
public static clampedInt<T>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
1262
return clampedInt(value, defaultValue, minimum, maximum);
1263
}
1264
1265
public readonly minimum: number;
1266
public readonly maximum: number;
1267
1268
constructor(id: K, name: PossibleKeyName<number>, defaultValue: number, minimum: number, maximum: number, schema: IConfigurationPropertySchema | undefined = undefined) {
1269
if (typeof schema !== 'undefined') {
1270
schema.type = 'integer';
1271
schema.default = defaultValue;
1272
schema.minimum = minimum;
1273
schema.maximum = maximum;
1274
}
1275
super(id, name, defaultValue, schema);
1276
this.minimum = minimum;
1277
this.maximum = maximum;
1278
}
1279
1280
public override validate(input: any): number {
1281
return EditorIntOption.clampedInt(input, this.defaultValue, this.minimum, this.maximum);
1282
}
1283
}
1284
/**
1285
* @internal
1286
*/
1287
export function clampedFloat<T extends number>(value: any, defaultValue: T, minimum: number, maximum: number): number | T {
1288
if (typeof value === 'undefined') {
1289
return defaultValue;
1290
}
1291
const r = EditorFloatOption.float(value, defaultValue);
1292
return EditorFloatOption.clamp(r, minimum, maximum);
1293
}
1294
1295
class EditorFloatOption<K extends EditorOption> extends SimpleEditorOption<K, number> {
1296
1297
public readonly minimum: number | undefined;
1298
public readonly maximum: number | undefined;
1299
1300
public static clamp(n: number, min: number, max: number): number {
1301
if (n < min) {
1302
return min;
1303
}
1304
if (n > max) {
1305
return max;
1306
}
1307
return n;
1308
}
1309
1310
public static float(value: any, defaultValue: number): number {
1311
if (typeof value === 'number') {
1312
return value;
1313
}
1314
if (typeof value === 'undefined') {
1315
return defaultValue;
1316
}
1317
const r = parseFloat(value);
1318
return (isNaN(r) ? defaultValue : r);
1319
}
1320
1321
public readonly validationFn: (value: number) => number;
1322
1323
constructor(id: K, name: PossibleKeyName<number>, defaultValue: number, validationFn: (value: number) => number, schema?: IConfigurationPropertySchema, minimum?: number, maximum?: number) {
1324
if (typeof schema !== 'undefined') {
1325
schema.type = 'number';
1326
schema.default = defaultValue;
1327
schema.minimum = minimum;
1328
schema.maximum = maximum;
1329
}
1330
super(id, name, defaultValue, schema);
1331
this.validationFn = validationFn;
1332
this.minimum = minimum;
1333
this.maximum = maximum;
1334
}
1335
1336
public override validate(input: any): number {
1337
return this.validationFn(EditorFloatOption.float(input, this.defaultValue));
1338
}
1339
}
1340
1341
class EditorStringOption<K extends EditorOption> extends SimpleEditorOption<K, string> {
1342
1343
public static string(value: any, defaultValue: string): string {
1344
if (typeof value !== 'string') {
1345
return defaultValue;
1346
}
1347
return value;
1348
}
1349
1350
constructor(id: K, name: PossibleKeyName<string>, defaultValue: string, schema: IConfigurationPropertySchema | undefined = undefined) {
1351
if (typeof schema !== 'undefined') {
1352
schema.type = 'string';
1353
schema.default = defaultValue;
1354
}
1355
super(id, name, defaultValue, schema);
1356
}
1357
1358
public override validate(input: any): string {
1359
return EditorStringOption.string(input, this.defaultValue);
1360
}
1361
}
1362
1363
/**
1364
* @internal
1365
*/
1366
export function stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: ReadonlyArray<T>, renamedValues?: Record<string, T>): T {
1367
if (typeof value !== 'string') {
1368
return defaultValue;
1369
}
1370
if (renamedValues && value in renamedValues) {
1371
return renamedValues[value];
1372
}
1373
if (allowedValues.indexOf(value) === -1) {
1374
return defaultValue;
1375
}
1376
return value;
1377
}
1378
1379
class EditorStringEnumOption<K extends EditorOption, V extends string> extends SimpleEditorOption<K, V> {
1380
1381
private readonly _allowedValues: ReadonlyArray<V>;
1382
1383
constructor(id: K, name: PossibleKeyName<V>, defaultValue: V, allowedValues: ReadonlyArray<V>, schema: IConfigurationPropertySchema | undefined = undefined) {
1384
if (typeof schema !== 'undefined') {
1385
schema.type = 'string';
1386
schema.enum = <any>allowedValues;
1387
schema.default = defaultValue;
1388
}
1389
super(id, name, defaultValue, schema);
1390
this._allowedValues = allowedValues;
1391
}
1392
1393
public override validate(input: any): V {
1394
return stringSet<V>(input, this.defaultValue, this._allowedValues);
1395
}
1396
}
1397
1398
class EditorEnumOption<K extends EditorOption, T extends string, V> extends BaseEditorOption<K, T, V> {
1399
1400
private readonly _allowedValues: T[];
1401
private readonly _convert: (value: T) => V;
1402
1403
constructor(id: K, name: PossibleKeyName<T>, defaultValue: V, defaultStringValue: string, allowedValues: T[], convert: (value: T) => V, schema: IConfigurationPropertySchema | undefined = undefined) {
1404
if (typeof schema !== 'undefined') {
1405
schema.type = 'string';
1406
schema.enum = allowedValues;
1407
schema.default = defaultStringValue;
1408
}
1409
super(id, name, defaultValue, schema);
1410
this._allowedValues = allowedValues;
1411
this._convert = convert;
1412
}
1413
1414
public validate(input: any): V {
1415
if (typeof input !== 'string') {
1416
return this.defaultValue;
1417
}
1418
if (this._allowedValues.indexOf(<T>input) === -1) {
1419
return this.defaultValue;
1420
}
1421
return this._convert(<any>input);
1422
}
1423
}
1424
1425
//#endregion
1426
1427
//#region autoIndent
1428
1429
function _autoIndentFromString(autoIndent: 'none' | 'keep' | 'brackets' | 'advanced' | 'full'): EditorAutoIndentStrategy {
1430
switch (autoIndent) {
1431
case 'none': return EditorAutoIndentStrategy.None;
1432
case 'keep': return EditorAutoIndentStrategy.Keep;
1433
case 'brackets': return EditorAutoIndentStrategy.Brackets;
1434
case 'advanced': return EditorAutoIndentStrategy.Advanced;
1435
case 'full': return EditorAutoIndentStrategy.Full;
1436
}
1437
}
1438
1439
//#endregion
1440
1441
//#region accessibilitySupport
1442
1443
class EditorAccessibilitySupport extends BaseEditorOption<EditorOption.accessibilitySupport, 'auto' | 'off' | 'on', AccessibilitySupport> {
1444
1445
constructor() {
1446
super(
1447
EditorOption.accessibilitySupport, 'accessibilitySupport', AccessibilitySupport.Unknown,
1448
{
1449
type: 'string',
1450
enum: ['auto', 'on', 'off'],
1451
enumDescriptions: [
1452
nls.localize('accessibilitySupport.auto', "Use platform APIs to detect when a Screen Reader is attached."),
1453
nls.localize('accessibilitySupport.on', "Optimize for usage with a Screen Reader."),
1454
nls.localize('accessibilitySupport.off', "Assume a screen reader is not attached."),
1455
],
1456
default: 'auto',
1457
tags: ['accessibility'],
1458
description: nls.localize('accessibilitySupport', "Controls if the UI should run in a mode where it is optimized for screen readers.")
1459
}
1460
);
1461
}
1462
1463
public validate(input: any): AccessibilitySupport {
1464
switch (input) {
1465
case 'auto': return AccessibilitySupport.Unknown;
1466
case 'off': return AccessibilitySupport.Disabled;
1467
case 'on': return AccessibilitySupport.Enabled;
1468
}
1469
return this.defaultValue;
1470
}
1471
1472
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: AccessibilitySupport): AccessibilitySupport {
1473
if (value === AccessibilitySupport.Unknown) {
1474
// The editor reads the `accessibilitySupport` from the environment
1475
return env.accessibilitySupport;
1476
}
1477
return value;
1478
}
1479
}
1480
1481
//#endregion
1482
1483
//#region comments
1484
1485
/**
1486
* Configuration options for editor comments
1487
*/
1488
export interface IEditorCommentsOptions {
1489
/**
1490
* Insert a space after the line comment token and inside the block comments tokens.
1491
* Defaults to true.
1492
*/
1493
insertSpace?: boolean;
1494
/**
1495
* Ignore empty lines when inserting line comments.
1496
* Defaults to true.
1497
*/
1498
ignoreEmptyLines?: boolean;
1499
}
1500
1501
/**
1502
* @internal
1503
*/
1504
export type EditorCommentsOptions = Readonly<Required<IEditorCommentsOptions>>;
1505
1506
class EditorComments extends BaseEditorOption<EditorOption.comments, IEditorCommentsOptions, EditorCommentsOptions> {
1507
1508
constructor() {
1509
const defaults: EditorCommentsOptions = {
1510
insertSpace: true,
1511
ignoreEmptyLines: true,
1512
};
1513
super(
1514
EditorOption.comments, 'comments', defaults,
1515
{
1516
'editor.comments.insertSpace': {
1517
type: 'boolean',
1518
default: defaults.insertSpace,
1519
description: nls.localize('comments.insertSpace', "Controls whether a space character is inserted when commenting.")
1520
},
1521
'editor.comments.ignoreEmptyLines': {
1522
type: 'boolean',
1523
default: defaults.ignoreEmptyLines,
1524
description: nls.localize('comments.ignoreEmptyLines', 'Controls if empty lines should be ignored with toggle, add or remove actions for line comments.')
1525
},
1526
}
1527
);
1528
}
1529
1530
public validate(_input: any): EditorCommentsOptions {
1531
if (!_input || typeof _input !== 'object') {
1532
return this.defaultValue;
1533
}
1534
const input = _input as IEditorCommentsOptions;
1535
return {
1536
insertSpace: boolean(input.insertSpace, this.defaultValue.insertSpace),
1537
ignoreEmptyLines: boolean(input.ignoreEmptyLines, this.defaultValue.ignoreEmptyLines),
1538
};
1539
}
1540
}
1541
1542
//#endregion
1543
1544
//#region cursorBlinking
1545
1546
/**
1547
* The kind of animation in which the editor's cursor should be rendered.
1548
*/
1549
export const enum TextEditorCursorBlinkingStyle {
1550
/**
1551
* Hidden
1552
*/
1553
Hidden = 0,
1554
/**
1555
* Blinking
1556
*/
1557
Blink = 1,
1558
/**
1559
* Blinking with smooth fading
1560
*/
1561
Smooth = 2,
1562
/**
1563
* Blinking with prolonged filled state and smooth fading
1564
*/
1565
Phase = 3,
1566
/**
1567
* Expand collapse animation on the y axis
1568
*/
1569
Expand = 4,
1570
/**
1571
* No-Blinking
1572
*/
1573
Solid = 5
1574
}
1575
1576
/**
1577
* @internal
1578
*/
1579
export function cursorBlinkingStyleFromString(cursorBlinkingStyle: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid'): TextEditorCursorBlinkingStyle {
1580
switch (cursorBlinkingStyle) {
1581
case 'blink': return TextEditorCursorBlinkingStyle.Blink;
1582
case 'smooth': return TextEditorCursorBlinkingStyle.Smooth;
1583
case 'phase': return TextEditorCursorBlinkingStyle.Phase;
1584
case 'expand': return TextEditorCursorBlinkingStyle.Expand;
1585
case 'solid': return TextEditorCursorBlinkingStyle.Solid;
1586
}
1587
}
1588
1589
//#endregion
1590
1591
//#region cursorStyle
1592
1593
/**
1594
* The style in which the editor's cursor should be rendered.
1595
*/
1596
export enum TextEditorCursorStyle {
1597
/**
1598
* As a vertical line (sitting between two characters).
1599
*/
1600
Line = 1,
1601
/**
1602
* As a block (sitting on top of a character).
1603
*/
1604
Block = 2,
1605
/**
1606
* As a horizontal line (sitting under a character).
1607
*/
1608
Underline = 3,
1609
/**
1610
* As a thin vertical line (sitting between two characters).
1611
*/
1612
LineThin = 4,
1613
/**
1614
* As an outlined block (sitting on top of a character).
1615
*/
1616
BlockOutline = 5,
1617
/**
1618
* As a thin horizontal line (sitting under a character).
1619
*/
1620
UnderlineThin = 6
1621
}
1622
1623
/**
1624
* @internal
1625
*/
1626
export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin' {
1627
switch (cursorStyle) {
1628
case TextEditorCursorStyle.Line: return 'line';
1629
case TextEditorCursorStyle.Block: return 'block';
1630
case TextEditorCursorStyle.Underline: return 'underline';
1631
case TextEditorCursorStyle.LineThin: return 'line-thin';
1632
case TextEditorCursorStyle.BlockOutline: return 'block-outline';
1633
case TextEditorCursorStyle.UnderlineThin: return 'underline-thin';
1634
}
1635
}
1636
1637
/**
1638
* @internal
1639
*/
1640
export function cursorStyleFromString(cursorStyle: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin'): TextEditorCursorStyle {
1641
switch (cursorStyle) {
1642
case 'line': return TextEditorCursorStyle.Line;
1643
case 'block': return TextEditorCursorStyle.Block;
1644
case 'underline': return TextEditorCursorStyle.Underline;
1645
case 'line-thin': return TextEditorCursorStyle.LineThin;
1646
case 'block-outline': return TextEditorCursorStyle.BlockOutline;
1647
case 'underline-thin': return TextEditorCursorStyle.UnderlineThin;
1648
}
1649
}
1650
1651
//#endregion
1652
1653
//#region editorClassName
1654
1655
class EditorClassName extends ComputedEditorOption<EditorOption.editorClassName, string> {
1656
1657
constructor() {
1658
super(EditorOption.editorClassName);
1659
}
1660
1661
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: string): string {
1662
const classNames = ['monaco-editor'];
1663
if (options.get(EditorOption.extraEditorClassName)) {
1664
classNames.push(options.get(EditorOption.extraEditorClassName));
1665
}
1666
if (env.extraEditorClassName) {
1667
classNames.push(env.extraEditorClassName);
1668
}
1669
if (options.get(EditorOption.mouseStyle) === 'default') {
1670
classNames.push('mouse-default');
1671
} else if (options.get(EditorOption.mouseStyle) === 'copy') {
1672
classNames.push('mouse-copy');
1673
}
1674
1675
if (options.get(EditorOption.showUnused)) {
1676
classNames.push('showUnused');
1677
}
1678
1679
if (options.get(EditorOption.showDeprecated)) {
1680
classNames.push('showDeprecated');
1681
}
1682
1683
return classNames.join(' ');
1684
}
1685
}
1686
1687
//#endregion
1688
1689
//#region emptySelectionClipboard
1690
1691
class EditorEmptySelectionClipboard extends EditorBooleanOption<EditorOption.emptySelectionClipboard> {
1692
1693
constructor() {
1694
super(
1695
EditorOption.emptySelectionClipboard, 'emptySelectionClipboard', true,
1696
{ description: nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.") }
1697
);
1698
}
1699
1700
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: boolean): boolean {
1701
return value && env.emptySelectionClipboard;
1702
}
1703
}
1704
1705
//#endregion
1706
1707
//#region find
1708
1709
/**
1710
* Configuration options for editor find widget
1711
*/
1712
export interface IEditorFindOptions {
1713
/**
1714
* Controls whether the cursor should move to find matches while typing.
1715
*/
1716
cursorMoveOnType?: boolean;
1717
/**
1718
* Controls whether the find widget should search as you type.
1719
*/
1720
findOnType?: boolean;
1721
/**
1722
* Controls if we seed search string in the Find Widget with editor selection.
1723
*/
1724
seedSearchStringFromSelection?: 'never' | 'always' | 'selection';
1725
/**
1726
* Controls if Find in Selection flag is turned on in the editor.
1727
*/
1728
autoFindInSelection?: 'never' | 'always' | 'multiline';
1729
/*
1730
* Controls whether the Find Widget should add extra lines on top of the editor.
1731
*/
1732
addExtraSpaceOnTop?: boolean;
1733
/**
1734
* @internal
1735
* Controls if the Find Widget should read or modify the shared find clipboard on macOS
1736
*/
1737
globalFindClipboard?: boolean;
1738
/**
1739
* Controls whether the search result and diff result automatically restarts from the beginning (or the end) when no further matches can be found
1740
*/
1741
loop?: boolean;
1742
/**
1743
* @internal
1744
* Controls how the find widget search history should be stored
1745
*/
1746
history?: 'never' | 'workspace';
1747
/**
1748
* @internal
1749
* Controls how the replace widget search history should be stored
1750
*/
1751
replaceHistory?: 'never' | 'workspace';
1752
}
1753
1754
/**
1755
* @internal
1756
*/
1757
export type EditorFindOptions = Readonly<Required<IEditorFindOptions>>;
1758
1759
class EditorFind extends BaseEditorOption<EditorOption.find, IEditorFindOptions, EditorFindOptions> {
1760
1761
constructor() {
1762
const defaults: EditorFindOptions = {
1763
cursorMoveOnType: true,
1764
findOnType: true,
1765
seedSearchStringFromSelection: 'always',
1766
autoFindInSelection: 'never',
1767
globalFindClipboard: false,
1768
addExtraSpaceOnTop: true,
1769
loop: true,
1770
history: 'workspace',
1771
replaceHistory: 'workspace',
1772
};
1773
super(
1774
EditorOption.find, 'find', defaults,
1775
{
1776
'editor.find.cursorMoveOnType': {
1777
type: 'boolean',
1778
default: defaults.cursorMoveOnType,
1779
description: nls.localize('find.cursorMoveOnType', "Controls whether the cursor should jump to find matches while typing.")
1780
},
1781
'editor.find.seedSearchStringFromSelection': {
1782
type: 'string',
1783
enum: ['never', 'always', 'selection'],
1784
default: defaults.seedSearchStringFromSelection,
1785
enumDescriptions: [
1786
nls.localize('editor.find.seedSearchStringFromSelection.never', 'Never seed search string from the editor selection.'),
1787
nls.localize('editor.find.seedSearchStringFromSelection.always', 'Always seed search string from the editor selection, including word at cursor position.'),
1788
nls.localize('editor.find.seedSearchStringFromSelection.selection', 'Only seed search string from the editor selection.')
1789
],
1790
description: nls.localize('find.seedSearchStringFromSelection', "Controls whether the search string in the Find Widget is seeded from the editor selection.")
1791
},
1792
'editor.find.autoFindInSelection': {
1793
type: 'string',
1794
enum: ['never', 'always', 'multiline'],
1795
default: defaults.autoFindInSelection,
1796
enumDescriptions: [
1797
nls.localize('editor.find.autoFindInSelection.never', 'Never turn on Find in Selection automatically (default).'),
1798
nls.localize('editor.find.autoFindInSelection.always', 'Always turn on Find in Selection automatically.'),
1799
nls.localize('editor.find.autoFindInSelection.multiline', 'Turn on Find in Selection automatically when multiple lines of content are selected.')
1800
],
1801
description: nls.localize('find.autoFindInSelection', "Controls the condition for turning on Find in Selection automatically.")
1802
},
1803
'editor.find.globalFindClipboard': {
1804
type: 'boolean',
1805
default: defaults.globalFindClipboard,
1806
description: nls.localize('find.globalFindClipboard', "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."),
1807
included: platform.isMacintosh
1808
},
1809
'editor.find.addExtraSpaceOnTop': {
1810
type: 'boolean',
1811
default: defaults.addExtraSpaceOnTop,
1812
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.")
1813
},
1814
'editor.find.loop': {
1815
type: 'boolean',
1816
default: defaults.loop,
1817
description: nls.localize('find.loop', "Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found.")
1818
},
1819
'editor.find.history': {
1820
type: 'string',
1821
enum: ['never', 'workspace'],
1822
default: 'workspace',
1823
enumDescriptions: [
1824
nls.localize('editor.find.history.never', 'Do not store search history from the find widget.'),
1825
nls.localize('editor.find.history.workspace', 'Store search history across the active workspace'),
1826
],
1827
description: nls.localize('find.history', "Controls how the find widget history should be stored")
1828
},
1829
'editor.find.replaceHistory': {
1830
type: 'string',
1831
enum: ['never', 'workspace'],
1832
default: 'workspace',
1833
enumDescriptions: [
1834
nls.localize('editor.find.replaceHistory.never', 'Do not store history from the replace widget.'),
1835
nls.localize('editor.find.replaceHistory.workspace', 'Store replace history across the active workspace'),
1836
],
1837
description: nls.localize('find.replaceHistory', "Controls how the replace widget history should be stored")
1838
},
1839
'editor.find.findOnType': {
1840
type: 'boolean',
1841
default: defaults.findOnType,
1842
description: nls.localize('find.findOnType', "Controls whether the Find Widget should search as you type.")
1843
},
1844
}
1845
);
1846
}
1847
1848
public validate(_input: any): EditorFindOptions {
1849
if (!_input || typeof _input !== 'object') {
1850
return this.defaultValue;
1851
}
1852
const input = _input as IEditorFindOptions;
1853
return {
1854
cursorMoveOnType: boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
1855
findOnType: boolean(input.findOnType, this.defaultValue.findOnType),
1856
seedSearchStringFromSelection: typeof _input.seedSearchStringFromSelection === 'boolean'
1857
? (_input.seedSearchStringFromSelection ? 'always' : 'never')
1858
: stringSet<'never' | 'always' | 'selection'>(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection, ['never', 'always', 'selection']),
1859
autoFindInSelection: typeof _input.autoFindInSelection === 'boolean'
1860
? (_input.autoFindInSelection ? 'always' : 'never')
1861
: stringSet<'never' | 'always' | 'multiline'>(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ['never', 'always', 'multiline']),
1862
globalFindClipboard: boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
1863
addExtraSpaceOnTop: boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop),
1864
loop: boolean(input.loop, this.defaultValue.loop),
1865
history: stringSet<'never' | 'workspace'>(input.history, this.defaultValue.history, ['never', 'workspace']),
1866
replaceHistory: stringSet<'never' | 'workspace'>(input.replaceHistory, this.defaultValue.replaceHistory, ['never', 'workspace']),
1867
};
1868
}
1869
}
1870
1871
//#endregion
1872
1873
//#region fontLigatures
1874
1875
/**
1876
* @internal
1877
*/
1878
export class EditorFontLigatures extends BaseEditorOption<EditorOption.fontLigatures, boolean | string, string> {
1879
1880
public static OFF = '"liga" off, "calt" off';
1881
public static ON = '"liga" on, "calt" on';
1882
1883
constructor() {
1884
super(
1885
EditorOption.fontLigatures, 'fontLigatures', EditorFontLigatures.OFF,
1886
{
1887
anyOf: [
1888
{
1889
type: 'boolean',
1890
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."),
1891
},
1892
{
1893
type: 'string',
1894
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.")
1895
}
1896
],
1897
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."),
1898
default: false
1899
}
1900
);
1901
}
1902
1903
public validate(input: any): string {
1904
if (typeof input === 'undefined') {
1905
return this.defaultValue;
1906
}
1907
if (typeof input === 'string') {
1908
if (input === 'false' || input.length === 0) {
1909
return EditorFontLigatures.OFF;
1910
}
1911
if (input === 'true') {
1912
return EditorFontLigatures.ON;
1913
}
1914
return input;
1915
}
1916
if (Boolean(input)) {
1917
return EditorFontLigatures.ON;
1918
}
1919
return EditorFontLigatures.OFF;
1920
}
1921
}
1922
1923
//#endregion
1924
1925
//#region fontVariations
1926
1927
/**
1928
* @internal
1929
*/
1930
export class EditorFontVariations extends BaseEditorOption<EditorOption.fontVariations, boolean | string, string> {
1931
// Text is laid out using default settings.
1932
public static OFF = 'normal';
1933
1934
// Translate `fontWeight` config to the `font-variation-settings` CSS property.
1935
public static TRANSLATE = 'translate';
1936
1937
constructor() {
1938
super(
1939
EditorOption.fontVariations, 'fontVariations', EditorFontVariations.OFF,
1940
{
1941
anyOf: [
1942
{
1943
type: 'boolean',
1944
description: nls.localize('fontVariations', "Enables/Disables the translation from font-weight to font-variation-settings. Change this to a string for fine-grained control of the 'font-variation-settings' CSS property."),
1945
},
1946
{
1947
type: 'string',
1948
description: nls.localize('fontVariationSettings', "Explicit 'font-variation-settings' CSS property. A boolean can be passed instead if one only needs to translate font-weight to font-variation-settings.")
1949
}
1950
],
1951
description: nls.localize('fontVariationsGeneral', "Configures font variations. Can be either a boolean to enable/disable the translation from font-weight to font-variation-settings or a string for the value of the CSS 'font-variation-settings' property."),
1952
default: false
1953
}
1954
);
1955
}
1956
1957
public validate(input: any): string {
1958
if (typeof input === 'undefined') {
1959
return this.defaultValue;
1960
}
1961
if (typeof input === 'string') {
1962
if (input === 'false') {
1963
return EditorFontVariations.OFF;
1964
}
1965
if (input === 'true') {
1966
return EditorFontVariations.TRANSLATE;
1967
}
1968
return input;
1969
}
1970
if (Boolean(input)) {
1971
return EditorFontVariations.TRANSLATE;
1972
}
1973
return EditorFontVariations.OFF;
1974
}
1975
1976
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: string): string {
1977
// The value is computed from the fontWeight if it is true.
1978
// So take the result from env.fontInfo
1979
return env.fontInfo.fontVariationSettings;
1980
}
1981
}
1982
1983
//#endregion
1984
1985
//#region fontInfo
1986
1987
class EditorFontInfo extends ComputedEditorOption<EditorOption.fontInfo, FontInfo> {
1988
1989
constructor() {
1990
super(EditorOption.fontInfo);
1991
}
1992
1993
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: FontInfo): FontInfo {
1994
return env.fontInfo;
1995
}
1996
}
1997
1998
//#endregion
1999
2000
//#region effectiveCursorStyle
2001
2002
class EffectiveCursorStyle extends ComputedEditorOption<EditorOption.effectiveCursorStyle, TextEditorCursorStyle> {
2003
2004
constructor() {
2005
super(EditorOption.effectiveCursorStyle);
2006
}
2007
2008
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: TextEditorCursorStyle): TextEditorCursorStyle {
2009
return env.inputMode === 'overtype' ?
2010
options.get(EditorOption.overtypeCursorStyle) :
2011
options.get(EditorOption.cursorStyle);
2012
}
2013
}
2014
2015
//#endregion
2016
2017
//#region effectiveExperimentalEditContext
2018
2019
class EffectiveEditContextEnabled extends ComputedEditorOption<EditorOption.effectiveEditContext, boolean> {
2020
2021
constructor() {
2022
super(EditorOption.effectiveEditContext);
2023
}
2024
2025
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions): boolean {
2026
return env.editContextSupported && options.get(EditorOption.editContext);
2027
}
2028
}
2029
2030
//#endregion
2031
2032
//#region effectiveAllowVariableFonts
2033
2034
class EffectiveAllowVariableFonts extends ComputedEditorOption<EditorOption.effectiveAllowVariableFonts, boolean> {
2035
2036
constructor() {
2037
super(EditorOption.effectiveAllowVariableFonts);
2038
}
2039
2040
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions): boolean {
2041
const accessibilitySupport = env.accessibilitySupport;
2042
if (accessibilitySupport === AccessibilitySupport.Enabled) {
2043
return options.get(EditorOption.allowVariableFontsInAccessibilityMode);
2044
} else {
2045
return options.get(EditorOption.allowVariableFonts);
2046
}
2047
}
2048
}
2049
2050
//#engregion
2051
2052
//#region fontSize
2053
2054
class EditorFontSize extends SimpleEditorOption<EditorOption.fontSize, number> {
2055
2056
constructor() {
2057
super(
2058
EditorOption.fontSize, 'fontSize', EDITOR_FONT_DEFAULTS.fontSize,
2059
{
2060
type: 'number',
2061
minimum: 6,
2062
maximum: 100,
2063
default: EDITOR_FONT_DEFAULTS.fontSize,
2064
description: nls.localize('fontSize', "Controls the font size in pixels.")
2065
}
2066
);
2067
}
2068
2069
public override validate(input: any): number {
2070
const r = EditorFloatOption.float(input, this.defaultValue);
2071
if (r === 0) {
2072
return EDITOR_FONT_DEFAULTS.fontSize;
2073
}
2074
return EditorFloatOption.clamp(r, 6, 100);
2075
}
2076
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
2077
// The final fontSize respects the editor zoom level.
2078
// So take the result from env.fontInfo
2079
return env.fontInfo.fontSize;
2080
}
2081
}
2082
2083
//#endregion
2084
2085
//#region fontWeight
2086
2087
class EditorFontWeight extends BaseEditorOption<EditorOption.fontWeight, string, string> {
2088
private static SUGGESTION_VALUES = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
2089
private static MINIMUM_VALUE = 1;
2090
private static MAXIMUM_VALUE = 1000;
2091
2092
constructor() {
2093
super(
2094
EditorOption.fontWeight, 'fontWeight', EDITOR_FONT_DEFAULTS.fontWeight,
2095
{
2096
anyOf: [
2097
{
2098
type: 'number',
2099
minimum: EditorFontWeight.MINIMUM_VALUE,
2100
maximum: EditorFontWeight.MAXIMUM_VALUE,
2101
errorMessage: nls.localize('fontWeightErrorMessage', "Only \"normal\" and \"bold\" keywords or numbers between 1 and 1000 are allowed.")
2102
},
2103
{
2104
type: 'string',
2105
pattern: '^(normal|bold|1000|[1-9][0-9]{0,2})$'
2106
},
2107
{
2108
enum: EditorFontWeight.SUGGESTION_VALUES
2109
}
2110
],
2111
default: EDITOR_FONT_DEFAULTS.fontWeight,
2112
description: nls.localize('fontWeight', "Controls the font weight. Accepts \"normal\" and \"bold\" keywords or numbers between 1 and 1000.")
2113
}
2114
);
2115
}
2116
2117
public validate(input: any): string {
2118
if (input === 'normal' || input === 'bold') {
2119
return input;
2120
}
2121
return String(EditorIntOption.clampedInt(input, EDITOR_FONT_DEFAULTS.fontWeight, EditorFontWeight.MINIMUM_VALUE, EditorFontWeight.MAXIMUM_VALUE));
2122
}
2123
}
2124
2125
//#endregion
2126
2127
//#region gotoLocation
2128
2129
export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';
2130
2131
/**
2132
* Configuration options for go to location
2133
*/
2134
export interface IGotoLocationOptions {
2135
2136
multiple?: GoToLocationValues;
2137
2138
multipleDefinitions?: GoToLocationValues;
2139
multipleTypeDefinitions?: GoToLocationValues;
2140
multipleDeclarations?: GoToLocationValues;
2141
multipleImplementations?: GoToLocationValues;
2142
multipleReferences?: GoToLocationValues;
2143
multipleTests?: GoToLocationValues;
2144
2145
alternativeDefinitionCommand?: string;
2146
alternativeTypeDefinitionCommand?: string;
2147
alternativeDeclarationCommand?: string;
2148
alternativeImplementationCommand?: string;
2149
alternativeReferenceCommand?: string;
2150
alternativeTestsCommand?: string;
2151
}
2152
2153
/**
2154
* @internal
2155
*/
2156
export type GoToLocationOptions = Readonly<Required<IGotoLocationOptions>>;
2157
2158
class EditorGoToLocation extends BaseEditorOption<EditorOption.gotoLocation, IGotoLocationOptions, GoToLocationOptions> {
2159
2160
constructor() {
2161
const defaults: GoToLocationOptions = {
2162
multiple: 'peek',
2163
multipleDefinitions: 'peek',
2164
multipleTypeDefinitions: 'peek',
2165
multipleDeclarations: 'peek',
2166
multipleImplementations: 'peek',
2167
multipleReferences: 'peek',
2168
multipleTests: 'peek',
2169
alternativeDefinitionCommand: 'editor.action.goToReferences',
2170
alternativeTypeDefinitionCommand: 'editor.action.goToReferences',
2171
alternativeDeclarationCommand: 'editor.action.goToReferences',
2172
alternativeImplementationCommand: '',
2173
alternativeReferenceCommand: '',
2174
alternativeTestsCommand: '',
2175
};
2176
const jsonSubset: IJSONSchema = {
2177
type: 'string',
2178
enum: ['peek', 'gotoAndPeek', 'goto'],
2179
default: defaults.multiple,
2180
enumDescriptions: [
2181
nls.localize('editor.gotoLocation.multiple.peek', 'Show Peek view of the results (default)'),
2182
nls.localize('editor.gotoLocation.multiple.gotoAndPeek', 'Go to the primary result and show a Peek view'),
2183
nls.localize('editor.gotoLocation.multiple.goto', 'Go to the primary result and enable Peek-less navigation to others')
2184
]
2185
};
2186
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'];
2187
super(
2188
EditorOption.gotoLocation, 'gotoLocation', defaults,
2189
{
2190
'editor.gotoLocation.multiple': {
2191
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."),
2192
},
2193
'editor.gotoLocation.multipleDefinitions': {
2194
description: nls.localize('editor.editor.gotoLocation.multipleDefinitions', "Controls the behavior the 'Go to Definition'-command when multiple target locations exist."),
2195
...jsonSubset,
2196
},
2197
'editor.gotoLocation.multipleTypeDefinitions': {
2198
description: nls.localize('editor.editor.gotoLocation.multipleTypeDefinitions', "Controls the behavior the 'Go to Type Definition'-command when multiple target locations exist."),
2199
...jsonSubset,
2200
},
2201
'editor.gotoLocation.multipleDeclarations': {
2202
description: nls.localize('editor.editor.gotoLocation.multipleDeclarations', "Controls the behavior the 'Go to Declaration'-command when multiple target locations exist."),
2203
...jsonSubset,
2204
},
2205
'editor.gotoLocation.multipleImplementations': {
2206
description: nls.localize('editor.editor.gotoLocation.multipleImplemenattions', "Controls the behavior the 'Go to Implementations'-command when multiple target locations exist."),
2207
...jsonSubset,
2208
},
2209
'editor.gotoLocation.multipleReferences': {
2210
description: nls.localize('editor.editor.gotoLocation.multipleReferences', "Controls the behavior the 'Go to References'-command when multiple target locations exist."),
2211
...jsonSubset,
2212
},
2213
'editor.gotoLocation.alternativeDefinitionCommand': {
2214
type: 'string',
2215
default: defaults.alternativeDefinitionCommand,
2216
enum: alternativeCommandOptions,
2217
description: nls.localize('alternativeDefinitionCommand', "Alternative command id that is being executed when the result of 'Go to Definition' is the current location.")
2218
},
2219
'editor.gotoLocation.alternativeTypeDefinitionCommand': {
2220
type: 'string',
2221
default: defaults.alternativeTypeDefinitionCommand,
2222
enum: alternativeCommandOptions,
2223
description: nls.localize('alternativeTypeDefinitionCommand', "Alternative command id that is being executed when the result of 'Go to Type Definition' is the current location.")
2224
},
2225
'editor.gotoLocation.alternativeDeclarationCommand': {
2226
type: 'string',
2227
default: defaults.alternativeDeclarationCommand,
2228
enum: alternativeCommandOptions,
2229
description: nls.localize('alternativeDeclarationCommand', "Alternative command id that is being executed when the result of 'Go to Declaration' is the current location.")
2230
},
2231
'editor.gotoLocation.alternativeImplementationCommand': {
2232
type: 'string',
2233
default: defaults.alternativeImplementationCommand,
2234
enum: alternativeCommandOptions,
2235
description: nls.localize('alternativeImplementationCommand', "Alternative command id that is being executed when the result of 'Go to Implementation' is the current location.")
2236
},
2237
'editor.gotoLocation.alternativeReferenceCommand': {
2238
type: 'string',
2239
default: defaults.alternativeReferenceCommand,
2240
enum: alternativeCommandOptions,
2241
description: nls.localize('alternativeReferenceCommand', "Alternative command id that is being executed when the result of 'Go to Reference' is the current location.")
2242
},
2243
}
2244
);
2245
}
2246
2247
public validate(_input: any): GoToLocationOptions {
2248
if (!_input || typeof _input !== 'object') {
2249
return this.defaultValue;
2250
}
2251
const input = _input as IGotoLocationOptions;
2252
return {
2253
multiple: stringSet<GoToLocationValues>(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']),
2254
multipleDefinitions: input.multipleDefinitions ?? stringSet<GoToLocationValues>(input.multipleDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2255
multipleTypeDefinitions: input.multipleTypeDefinitions ?? stringSet<GoToLocationValues>(input.multipleTypeDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2256
multipleDeclarations: input.multipleDeclarations ?? stringSet<GoToLocationValues>(input.multipleDeclarations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2257
multipleImplementations: input.multipleImplementations ?? stringSet<GoToLocationValues>(input.multipleImplementations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2258
multipleReferences: input.multipleReferences ?? stringSet<GoToLocationValues>(input.multipleReferences, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2259
multipleTests: input.multipleTests ?? stringSet<GoToLocationValues>(input.multipleTests, 'peek', ['peek', 'gotoAndPeek', 'goto']),
2260
alternativeDefinitionCommand: EditorStringOption.string(input.alternativeDefinitionCommand, this.defaultValue.alternativeDefinitionCommand),
2261
alternativeTypeDefinitionCommand: EditorStringOption.string(input.alternativeTypeDefinitionCommand, this.defaultValue.alternativeTypeDefinitionCommand),
2262
alternativeDeclarationCommand: EditorStringOption.string(input.alternativeDeclarationCommand, this.defaultValue.alternativeDeclarationCommand),
2263
alternativeImplementationCommand: EditorStringOption.string(input.alternativeImplementationCommand, this.defaultValue.alternativeImplementationCommand),
2264
alternativeReferenceCommand: EditorStringOption.string(input.alternativeReferenceCommand, this.defaultValue.alternativeReferenceCommand),
2265
alternativeTestsCommand: EditorStringOption.string(input.alternativeTestsCommand, this.defaultValue.alternativeTestsCommand),
2266
};
2267
}
2268
}
2269
2270
//#endregion
2271
2272
//#region hover
2273
2274
/**
2275
* Configuration options for editor hover
2276
*/
2277
export interface IEditorHoverOptions {
2278
/**
2279
* Enable the hover.
2280
* Defaults to true.
2281
*/
2282
enabled?: boolean;
2283
/**
2284
* Delay for showing the hover.
2285
* Defaults to 300.
2286
*/
2287
delay?: number;
2288
/**
2289
* Is the hover sticky such that it can be clicked and its contents selected?
2290
* Defaults to true.
2291
*/
2292
sticky?: boolean;
2293
/**
2294
* Controls how long the hover is visible after you hovered out of it.
2295
* Require sticky setting to be true.
2296
*/
2297
hidingDelay?: number;
2298
/**
2299
* Should the hover be shown above the line if possible?
2300
* Defaults to false.
2301
*/
2302
above?: boolean;
2303
}
2304
2305
/**
2306
* @internal
2307
*/
2308
export type EditorHoverOptions = Readonly<Required<IEditorHoverOptions>>;
2309
2310
class EditorHover extends BaseEditorOption<EditorOption.hover, IEditorHoverOptions, EditorHoverOptions> {
2311
2312
constructor() {
2313
const defaults: EditorHoverOptions = {
2314
enabled: true,
2315
delay: 300,
2316
hidingDelay: 300,
2317
sticky: true,
2318
above: true,
2319
};
2320
super(
2321
EditorOption.hover, 'hover', defaults,
2322
{
2323
'editor.hover.enabled': {
2324
type: 'boolean',
2325
default: defaults.enabled,
2326
description: nls.localize('hover.enabled', "Controls whether the hover is shown.")
2327
},
2328
'editor.hover.delay': {
2329
type: 'number',
2330
default: defaults.delay,
2331
minimum: 0,
2332
maximum: 10000,
2333
description: nls.localize('hover.delay', "Controls the delay in milliseconds after which the hover is shown.")
2334
},
2335
'editor.hover.sticky': {
2336
type: 'boolean',
2337
default: defaults.sticky,
2338
description: nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.")
2339
},
2340
'editor.hover.hidingDelay': {
2341
type: 'integer',
2342
minimum: 0,
2343
default: defaults.hidingDelay,
2344
markdownDescription: nls.localize('hover.hidingDelay', "Controls the delay in milliseconds after which the hover is hidden. Requires `#editor.hover.sticky#` to be enabled.")
2345
},
2346
'editor.hover.above': {
2347
type: 'boolean',
2348
default: defaults.above,
2349
description: nls.localize('hover.above', "Prefer showing hovers above the line, if there's space.")
2350
},
2351
}
2352
);
2353
}
2354
2355
public validate(_input: any): EditorHoverOptions {
2356
if (!_input || typeof _input !== 'object') {
2357
return this.defaultValue;
2358
}
2359
const input = _input as IEditorHoverOptions;
2360
return {
2361
enabled: boolean(input.enabled, this.defaultValue.enabled),
2362
delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
2363
sticky: boolean(input.sticky, this.defaultValue.sticky),
2364
hidingDelay: EditorIntOption.clampedInt(input.hidingDelay, this.defaultValue.hidingDelay, 0, 600000),
2365
above: boolean(input.above, this.defaultValue.above),
2366
};
2367
}
2368
}
2369
2370
//#endregion
2371
2372
//#region layoutInfo
2373
2374
/**
2375
* A description for the overview ruler position.
2376
*/
2377
export interface OverviewRulerPosition {
2378
/**
2379
* Width of the overview ruler
2380
*/
2381
readonly width: number;
2382
/**
2383
* Height of the overview ruler
2384
*/
2385
readonly height: number;
2386
/**
2387
* Top position for the overview ruler
2388
*/
2389
readonly top: number;
2390
/**
2391
* Right position for the overview ruler
2392
*/
2393
readonly right: number;
2394
}
2395
2396
export const enum RenderMinimap {
2397
None = 0,
2398
Text = 1,
2399
Blocks = 2,
2400
}
2401
2402
/**
2403
* The internal layout details of the editor.
2404
*/
2405
export interface EditorLayoutInfo {
2406
2407
/**
2408
* Full editor width.
2409
*/
2410
readonly width: number;
2411
/**
2412
* Full editor height.
2413
*/
2414
readonly height: number;
2415
2416
/**
2417
* Left position for the glyph margin.
2418
*/
2419
readonly glyphMarginLeft: number;
2420
/**
2421
* The width of the glyph margin.
2422
*/
2423
readonly glyphMarginWidth: number;
2424
2425
/**
2426
* The number of decoration lanes to render in the glyph margin.
2427
*/
2428
readonly glyphMarginDecorationLaneCount: number;
2429
2430
/**
2431
* Left position for the line numbers.
2432
*/
2433
readonly lineNumbersLeft: number;
2434
/**
2435
* The width of the line numbers.
2436
*/
2437
readonly lineNumbersWidth: number;
2438
2439
/**
2440
* Left position for the line decorations.
2441
*/
2442
readonly decorationsLeft: number;
2443
/**
2444
* The width of the line decorations.
2445
*/
2446
readonly decorationsWidth: number;
2447
2448
/**
2449
* Left position for the content (actual text)
2450
*/
2451
readonly contentLeft: number;
2452
/**
2453
* The width of the content (actual text)
2454
*/
2455
readonly contentWidth: number;
2456
2457
/**
2458
* Layout information for the minimap
2459
*/
2460
readonly minimap: EditorMinimapLayoutInfo;
2461
2462
/**
2463
* The number of columns (of typical characters) fitting on a viewport line.
2464
*/
2465
readonly viewportColumn: number;
2466
2467
readonly isWordWrapMinified: boolean;
2468
readonly isViewportWrapping: boolean;
2469
readonly wrappingColumn: number;
2470
2471
/**
2472
* The width of the vertical scrollbar.
2473
*/
2474
readonly verticalScrollbarWidth: number;
2475
/**
2476
* The height of the horizontal scrollbar.
2477
*/
2478
readonly horizontalScrollbarHeight: number;
2479
2480
/**
2481
* The position of the overview ruler.
2482
*/
2483
readonly overviewRuler: OverviewRulerPosition;
2484
}
2485
2486
/**
2487
* The internal layout details of the editor.
2488
*/
2489
export interface EditorMinimapLayoutInfo {
2490
readonly renderMinimap: RenderMinimap;
2491
readonly minimapLeft: number;
2492
readonly minimapWidth: number;
2493
readonly minimapHeightIsEditorHeight: boolean;
2494
readonly minimapIsSampling: boolean;
2495
readonly minimapScale: number;
2496
readonly minimapLineHeight: number;
2497
readonly minimapCanvasInnerWidth: number;
2498
readonly minimapCanvasInnerHeight: number;
2499
readonly minimapCanvasOuterWidth: number;
2500
readonly minimapCanvasOuterHeight: number;
2501
}
2502
2503
/**
2504
* @internal
2505
*/
2506
export interface EditorLayoutInfoComputerEnv {
2507
readonly memory: ComputeOptionsMemory | null;
2508
readonly outerWidth: number;
2509
readonly outerHeight: number;
2510
readonly isDominatedByLongLines: boolean;
2511
readonly lineHeight: number;
2512
readonly viewLineCount: number;
2513
readonly lineNumbersDigitCount: number;
2514
readonly typicalHalfwidthCharacterWidth: number;
2515
readonly maxDigitWidth: number;
2516
readonly pixelRatio: number;
2517
readonly glyphMarginDecorationLaneCount: number;
2518
}
2519
2520
/**
2521
* @internal
2522
*/
2523
export interface IEditorLayoutComputerInput {
2524
readonly outerWidth: number;
2525
readonly outerHeight: number;
2526
readonly isDominatedByLongLines: boolean;
2527
readonly lineHeight: number;
2528
readonly lineNumbersDigitCount: number;
2529
readonly typicalHalfwidthCharacterWidth: number;
2530
readonly maxDigitWidth: number;
2531
readonly pixelRatio: number;
2532
readonly glyphMargin: boolean;
2533
readonly lineDecorationsWidth: string | number;
2534
readonly folding: boolean;
2535
readonly minimap: Readonly<Required<IEditorMinimapOptions>>;
2536
readonly scrollbar: InternalEditorScrollbarOptions;
2537
readonly lineNumbers: InternalEditorRenderLineNumbersOptions;
2538
readonly lineNumbersMinChars: number;
2539
readonly scrollBeyondLastLine: boolean;
2540
readonly wordWrap: 'wordWrapColumn' | 'on' | 'off' | 'bounded';
2541
readonly wordWrapColumn: number;
2542
readonly wordWrapMinified: boolean;
2543
readonly accessibilitySupport: AccessibilitySupport;
2544
}
2545
2546
/**
2547
* @internal
2548
*/
2549
export interface IMinimapLayoutInput {
2550
readonly outerWidth: number;
2551
readonly outerHeight: number;
2552
readonly lineHeight: number;
2553
readonly typicalHalfwidthCharacterWidth: number;
2554
readonly pixelRatio: number;
2555
readonly scrollBeyondLastLine: boolean;
2556
readonly paddingTop: number;
2557
readonly paddingBottom: number;
2558
readonly minimap: Readonly<Required<IEditorMinimapOptions>>;
2559
readonly verticalScrollbarWidth: number;
2560
readonly viewLineCount: number;
2561
readonly remainingWidth: number;
2562
readonly isViewportWrapping: boolean;
2563
}
2564
2565
/**
2566
* @internal
2567
*/
2568
export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.layoutInfo, EditorLayoutInfo> {
2569
2570
constructor() {
2571
super(EditorOption.layoutInfo);
2572
}
2573
2574
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorLayoutInfo): EditorLayoutInfo {
2575
return EditorLayoutInfoComputer.computeLayout(options, {
2576
memory: env.memory,
2577
outerWidth: env.outerWidth,
2578
outerHeight: env.outerHeight,
2579
isDominatedByLongLines: env.isDominatedByLongLines,
2580
lineHeight: env.fontInfo.lineHeight,
2581
viewLineCount: env.viewLineCount,
2582
lineNumbersDigitCount: env.lineNumbersDigitCount,
2583
typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
2584
maxDigitWidth: env.fontInfo.maxDigitWidth,
2585
pixelRatio: env.pixelRatio,
2586
glyphMarginDecorationLaneCount: env.glyphMarginDecorationLaneCount
2587
});
2588
}
2589
2590
public static computeContainedMinimapLineCount(input: {
2591
viewLineCount: number;
2592
scrollBeyondLastLine: boolean;
2593
paddingTop: number;
2594
paddingBottom: number;
2595
height: number;
2596
lineHeight: number;
2597
pixelRatio: number;
2598
}): { typicalViewportLineCount: number; extraLinesBeforeFirstLine: number; extraLinesBeyondLastLine: number; desiredRatio: number; minimapLineCount: number } {
2599
const typicalViewportLineCount = input.height / input.lineHeight;
2600
const extraLinesBeforeFirstLine = Math.floor(input.paddingTop / input.lineHeight);
2601
let extraLinesBeyondLastLine = Math.floor(input.paddingBottom / input.lineHeight);
2602
if (input.scrollBeyondLastLine) {
2603
extraLinesBeyondLastLine = Math.max(extraLinesBeyondLastLine, typicalViewportLineCount - 1);
2604
}
2605
const desiredRatio = (extraLinesBeforeFirstLine + input.viewLineCount + extraLinesBeyondLastLine) / (input.pixelRatio * input.height);
2606
const minimapLineCount = Math.floor(input.viewLineCount / desiredRatio);
2607
return { typicalViewportLineCount, extraLinesBeforeFirstLine, extraLinesBeyondLastLine, desiredRatio, minimapLineCount };
2608
}
2609
2610
private static _computeMinimapLayout(input: IMinimapLayoutInput, memory: ComputeOptionsMemory): EditorMinimapLayoutInfo {
2611
const outerWidth = input.outerWidth;
2612
const outerHeight = input.outerHeight;
2613
const pixelRatio = input.pixelRatio;
2614
2615
if (!input.minimap.enabled) {
2616
return {
2617
renderMinimap: RenderMinimap.None,
2618
minimapLeft: 0,
2619
minimapWidth: 0,
2620
minimapHeightIsEditorHeight: false,
2621
minimapIsSampling: false,
2622
minimapScale: 1,
2623
minimapLineHeight: 1,
2624
minimapCanvasInnerWidth: 0,
2625
minimapCanvasInnerHeight: Math.floor(pixelRatio * outerHeight),
2626
minimapCanvasOuterWidth: 0,
2627
minimapCanvasOuterHeight: outerHeight,
2628
};
2629
}
2630
2631
// Can use memory if only the `viewLineCount` and `remainingWidth` have changed
2632
const stableMinimapLayoutInput = memory.stableMinimapLayoutInput;
2633
const couldUseMemory = (
2634
stableMinimapLayoutInput
2635
// && input.outerWidth === lastMinimapLayoutInput.outerWidth !!! INTENTIONAL OMITTED
2636
&& input.outerHeight === stableMinimapLayoutInput.outerHeight
2637
&& input.lineHeight === stableMinimapLayoutInput.lineHeight
2638
&& input.typicalHalfwidthCharacterWidth === stableMinimapLayoutInput.typicalHalfwidthCharacterWidth
2639
&& input.pixelRatio === stableMinimapLayoutInput.pixelRatio
2640
&& input.scrollBeyondLastLine === stableMinimapLayoutInput.scrollBeyondLastLine
2641
&& input.paddingTop === stableMinimapLayoutInput.paddingTop
2642
&& input.paddingBottom === stableMinimapLayoutInput.paddingBottom
2643
&& input.minimap.enabled === stableMinimapLayoutInput.minimap.enabled
2644
&& input.minimap.side === stableMinimapLayoutInput.minimap.side
2645
&& input.minimap.size === stableMinimapLayoutInput.minimap.size
2646
&& input.minimap.showSlider === stableMinimapLayoutInput.minimap.showSlider
2647
&& input.minimap.renderCharacters === stableMinimapLayoutInput.minimap.renderCharacters
2648
&& input.minimap.maxColumn === stableMinimapLayoutInput.minimap.maxColumn
2649
&& input.minimap.scale === stableMinimapLayoutInput.minimap.scale
2650
&& input.verticalScrollbarWidth === stableMinimapLayoutInput.verticalScrollbarWidth
2651
// && input.viewLineCount === lastMinimapLayoutInput.viewLineCount !!! INTENTIONAL OMITTED
2652
// && input.remainingWidth === lastMinimapLayoutInput.remainingWidth !!! INTENTIONAL OMITTED
2653
&& input.isViewportWrapping === stableMinimapLayoutInput.isViewportWrapping
2654
);
2655
2656
const lineHeight = input.lineHeight;
2657
const typicalHalfwidthCharacterWidth = input.typicalHalfwidthCharacterWidth;
2658
const scrollBeyondLastLine = input.scrollBeyondLastLine;
2659
const minimapRenderCharacters = input.minimap.renderCharacters;
2660
let minimapScale = (pixelRatio >= 2 ? Math.round(input.minimap.scale * 2) : input.minimap.scale);
2661
const minimapMaxColumn = input.minimap.maxColumn;
2662
const minimapSize = input.minimap.size;
2663
const minimapSide = input.minimap.side;
2664
const verticalScrollbarWidth = input.verticalScrollbarWidth;
2665
const viewLineCount = input.viewLineCount;
2666
const remainingWidth = input.remainingWidth;
2667
const isViewportWrapping = input.isViewportWrapping;
2668
2669
const baseCharHeight = minimapRenderCharacters ? 2 : 3;
2670
let minimapCanvasInnerHeight = Math.floor(pixelRatio * outerHeight);
2671
const minimapCanvasOuterHeight = minimapCanvasInnerHeight / pixelRatio;
2672
let minimapHeightIsEditorHeight = false;
2673
let minimapIsSampling = false;
2674
let minimapLineHeight = baseCharHeight * minimapScale;
2675
let minimapCharWidth = minimapScale / pixelRatio;
2676
let minimapWidthMultiplier: number = 1;
2677
2678
if (minimapSize === 'fill' || minimapSize === 'fit') {
2679
const { typicalViewportLineCount, extraLinesBeforeFirstLine, extraLinesBeyondLastLine, desiredRatio, minimapLineCount } = EditorLayoutInfoComputer.computeContainedMinimapLineCount({
2680
viewLineCount: viewLineCount,
2681
scrollBeyondLastLine: scrollBeyondLastLine,
2682
paddingTop: input.paddingTop,
2683
paddingBottom: input.paddingBottom,
2684
height: outerHeight,
2685
lineHeight: lineHeight,
2686
pixelRatio: pixelRatio
2687
});
2688
// ratio is intentionally not part of the layout to avoid the layout changing all the time
2689
// when doing sampling
2690
const ratio = viewLineCount / minimapLineCount;
2691
2692
if (ratio > 1) {
2693
minimapHeightIsEditorHeight = true;
2694
minimapIsSampling = true;
2695
minimapScale = 1;
2696
minimapLineHeight = 1;
2697
minimapCharWidth = minimapScale / pixelRatio;
2698
} else {
2699
let fitBecomesFill = false;
2700
let maxMinimapScale = minimapScale + 1;
2701
2702
if (minimapSize === 'fit') {
2703
const effectiveMinimapHeight = Math.ceil((extraLinesBeforeFirstLine + viewLineCount + extraLinesBeyondLastLine) * minimapLineHeight);
2704
if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
2705
// There is a loop when using `fit` and viewport wrapping:
2706
// - view line count impacts minimap layout
2707
// - minimap layout impacts viewport width
2708
// - viewport width impacts view line count
2709
// To break the loop, once we go to a smaller minimap scale, we try to stick with it.
2710
fitBecomesFill = true;
2711
maxMinimapScale = memory.stableFitMaxMinimapScale;
2712
} else {
2713
fitBecomesFill = (effectiveMinimapHeight > minimapCanvasInnerHeight);
2714
}
2715
}
2716
2717
if (minimapSize === 'fill' || fitBecomesFill) {
2718
minimapHeightIsEditorHeight = true;
2719
const configuredMinimapScale = minimapScale;
2720
minimapLineHeight = Math.min(lineHeight * pixelRatio, Math.max(1, Math.floor(1 / desiredRatio)));
2721
if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
2722
// There is a loop when using `fill` and viewport wrapping:
2723
// - view line count impacts minimap layout
2724
// - minimap layout impacts viewport width
2725
// - viewport width impacts view line count
2726
// To break the loop, once we go to a smaller minimap scale, we try to stick with it.
2727
maxMinimapScale = memory.stableFitMaxMinimapScale;
2728
}
2729
minimapScale = Math.min(maxMinimapScale, Math.max(1, Math.floor(minimapLineHeight / baseCharHeight)));
2730
if (minimapScale > configuredMinimapScale) {
2731
minimapWidthMultiplier = Math.min(2, minimapScale / configuredMinimapScale);
2732
}
2733
minimapCharWidth = minimapScale / pixelRatio / minimapWidthMultiplier;
2734
minimapCanvasInnerHeight = Math.ceil((Math.max(typicalViewportLineCount, extraLinesBeforeFirstLine + viewLineCount + extraLinesBeyondLastLine)) * minimapLineHeight);
2735
if (isViewportWrapping) {
2736
// remember for next time
2737
memory.stableMinimapLayoutInput = input;
2738
memory.stableFitRemainingWidth = remainingWidth;
2739
memory.stableFitMaxMinimapScale = minimapScale;
2740
} else {
2741
memory.stableMinimapLayoutInput = null;
2742
memory.stableFitRemainingWidth = 0;
2743
}
2744
}
2745
}
2746
}
2747
2748
// Given:
2749
// (leaving 2px for the cursor to have space after the last character)
2750
// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
2751
// minimapWidth = viewportColumn * minimapCharWidth
2752
// contentWidth = remainingWidth - minimapWidth
2753
// What are good values for contentWidth and minimapWidth ?
2754
2755
// minimapWidth = ((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth) * minimapCharWidth
2756
// typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth - 2) * minimapCharWidth
2757
// typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth - 2) * minimapCharWidth
2758
// (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth
2759
// minimapWidth = ((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)
2760
2761
const minimapMaxWidth = Math.floor(minimapMaxColumn * minimapCharWidth);
2762
const minimapWidth = Math.min(minimapMaxWidth, Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth))) + MINIMAP_GUTTER_WIDTH);
2763
2764
let minimapCanvasInnerWidth = Math.floor(pixelRatio * minimapWidth);
2765
const minimapCanvasOuterWidth = minimapCanvasInnerWidth / pixelRatio;
2766
minimapCanvasInnerWidth = Math.floor(minimapCanvasInnerWidth * minimapWidthMultiplier);
2767
2768
const renderMinimap = (minimapRenderCharacters ? RenderMinimap.Text : RenderMinimap.Blocks);
2769
const minimapLeft = (minimapSide === 'left' ? 0 : (outerWidth - minimapWidth - verticalScrollbarWidth));
2770
2771
return {
2772
renderMinimap,
2773
minimapLeft,
2774
minimapWidth,
2775
minimapHeightIsEditorHeight,
2776
minimapIsSampling,
2777
minimapScale,
2778
minimapLineHeight,
2779
minimapCanvasInnerWidth,
2780
minimapCanvasInnerHeight,
2781
minimapCanvasOuterWidth,
2782
minimapCanvasOuterHeight,
2783
};
2784
}
2785
2786
public static computeLayout(options: IComputedEditorOptions, env: EditorLayoutInfoComputerEnv): EditorLayoutInfo {
2787
const outerWidth = env.outerWidth | 0;
2788
const outerHeight = env.outerHeight | 0;
2789
const lineHeight = env.lineHeight | 0;
2790
const lineNumbersDigitCount = env.lineNumbersDigitCount | 0;
2791
const typicalHalfwidthCharacterWidth = env.typicalHalfwidthCharacterWidth;
2792
const maxDigitWidth = env.maxDigitWidth;
2793
const pixelRatio = env.pixelRatio;
2794
const viewLineCount = env.viewLineCount;
2795
2796
const wordWrapOverride2 = options.get(EditorOption.wordWrapOverride2);
2797
const wordWrapOverride1 = (wordWrapOverride2 === 'inherit' ? options.get(EditorOption.wordWrapOverride1) : wordWrapOverride2);
2798
const wordWrap = (wordWrapOverride1 === 'inherit' ? options.get(EditorOption.wordWrap) : wordWrapOverride1);
2799
2800
const wordWrapColumn = options.get(EditorOption.wordWrapColumn);
2801
const isDominatedByLongLines = env.isDominatedByLongLines;
2802
2803
const showGlyphMargin = options.get(EditorOption.glyphMargin);
2804
const showLineNumbers = (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off);
2805
const lineNumbersMinChars = options.get(EditorOption.lineNumbersMinChars);
2806
const scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine);
2807
const padding = options.get(EditorOption.padding);
2808
const minimap = options.get(EditorOption.minimap);
2809
2810
const scrollbar = options.get(EditorOption.scrollbar);
2811
const verticalScrollbarWidth = scrollbar.verticalScrollbarSize;
2812
const verticalScrollbarHasArrows = scrollbar.verticalHasArrows;
2813
const scrollbarArrowSize = scrollbar.arrowSize;
2814
const horizontalScrollbarHeight = scrollbar.horizontalScrollbarSize;
2815
2816
const folding = options.get(EditorOption.folding);
2817
const showFoldingDecoration = options.get(EditorOption.showFoldingControls) !== 'never';
2818
2819
let lineDecorationsWidth = options.get(EditorOption.lineDecorationsWidth);
2820
if (folding && showFoldingDecoration) {
2821
lineDecorationsWidth += 16;
2822
}
2823
2824
let lineNumbersWidth = 0;
2825
if (showLineNumbers) {
2826
const digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars);
2827
lineNumbersWidth = Math.round(digitCount * maxDigitWidth);
2828
}
2829
2830
let glyphMarginWidth = 0;
2831
if (showGlyphMargin) {
2832
glyphMarginWidth = lineHeight * env.glyphMarginDecorationLaneCount;
2833
}
2834
2835
let glyphMarginLeft = 0;
2836
let lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
2837
let decorationsLeft = lineNumbersLeft + lineNumbersWidth;
2838
let contentLeft = decorationsLeft + lineDecorationsWidth;
2839
2840
const remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;
2841
2842
let isWordWrapMinified = false;
2843
let isViewportWrapping = false;
2844
let wrappingColumn = -1;
2845
2846
if (options.get(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled && wordWrapOverride1 === 'inherit' && isDominatedByLongLines) {
2847
// Force viewport width wrapping if model is dominated by long lines
2848
isWordWrapMinified = true;
2849
isViewportWrapping = true;
2850
} else if (wordWrap === 'on' || wordWrap === 'bounded') {
2851
isViewportWrapping = true;
2852
} else if (wordWrap === 'wordWrapColumn') {
2853
wrappingColumn = wordWrapColumn;
2854
}
2855
2856
const minimapLayout = EditorLayoutInfoComputer._computeMinimapLayout({
2857
outerWidth: outerWidth,
2858
outerHeight: outerHeight,
2859
lineHeight: lineHeight,
2860
typicalHalfwidthCharacterWidth: typicalHalfwidthCharacterWidth,
2861
pixelRatio: pixelRatio,
2862
scrollBeyondLastLine: scrollBeyondLastLine,
2863
paddingTop: padding.top,
2864
paddingBottom: padding.bottom,
2865
minimap: minimap,
2866
verticalScrollbarWidth: verticalScrollbarWidth,
2867
viewLineCount: viewLineCount,
2868
remainingWidth: remainingWidth,
2869
isViewportWrapping: isViewportWrapping,
2870
}, env.memory || new ComputeOptionsMemory());
2871
2872
if (minimapLayout.renderMinimap !== RenderMinimap.None && minimapLayout.minimapLeft === 0) {
2873
// the minimap is rendered to the left, so move everything to the right
2874
glyphMarginLeft += minimapLayout.minimapWidth;
2875
lineNumbersLeft += minimapLayout.minimapWidth;
2876
decorationsLeft += minimapLayout.minimapWidth;
2877
contentLeft += minimapLayout.minimapWidth;
2878
}
2879
const contentWidth = remainingWidth - minimapLayout.minimapWidth;
2880
2881
// (leaving 2px for the cursor to have space after the last character)
2882
const viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth));
2883
2884
const verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);
2885
2886
if (isViewportWrapping) {
2887
// compute the actual wrappingColumn
2888
wrappingColumn = Math.max(1, viewportColumn);
2889
if (wordWrap === 'bounded') {
2890
wrappingColumn = Math.min(wrappingColumn, wordWrapColumn);
2891
}
2892
}
2893
2894
return {
2895
width: outerWidth,
2896
height: outerHeight,
2897
2898
glyphMarginLeft: glyphMarginLeft,
2899
glyphMarginWidth: glyphMarginWidth,
2900
glyphMarginDecorationLaneCount: env.glyphMarginDecorationLaneCount,
2901
2902
lineNumbersLeft: lineNumbersLeft,
2903
lineNumbersWidth: lineNumbersWidth,
2904
2905
decorationsLeft: decorationsLeft,
2906
decorationsWidth: lineDecorationsWidth,
2907
2908
contentLeft: contentLeft,
2909
contentWidth: contentWidth,
2910
2911
minimap: minimapLayout,
2912
2913
viewportColumn: viewportColumn,
2914
2915
isWordWrapMinified: isWordWrapMinified,
2916
isViewportWrapping: isViewportWrapping,
2917
wrappingColumn: wrappingColumn,
2918
2919
verticalScrollbarWidth: verticalScrollbarWidth,
2920
horizontalScrollbarHeight: horizontalScrollbarHeight,
2921
2922
overviewRuler: {
2923
top: verticalArrowSize,
2924
width: verticalScrollbarWidth,
2925
height: (outerHeight - 2 * verticalArrowSize),
2926
right: 0
2927
}
2928
};
2929
}
2930
}
2931
2932
//#endregion
2933
2934
//#region WrappingStrategy
2935
class WrappingStrategy extends BaseEditorOption<EditorOption.wrappingStrategy, 'simple' | 'advanced', 'simple' | 'advanced'> {
2936
2937
constructor() {
2938
super(EditorOption.wrappingStrategy, 'wrappingStrategy', 'simple',
2939
{
2940
'editor.wrappingStrategy': {
2941
enumDescriptions: [
2942
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."),
2943
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.")
2944
],
2945
type: 'string',
2946
enum: ['simple', 'advanced'],
2947
default: 'simple',
2948
description: nls.localize('wrappingStrategy', "Controls the algorithm that computes wrapping points. Note that when in accessibility mode, advanced will be used for the best experience.")
2949
}
2950
}
2951
);
2952
}
2953
2954
public validate(input: any): 'simple' | 'advanced' {
2955
return stringSet<'simple' | 'advanced'>(input, 'simple', ['simple', 'advanced']);
2956
}
2957
2958
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: 'simple' | 'advanced'): 'simple' | 'advanced' {
2959
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
2960
if (accessibilitySupport === AccessibilitySupport.Enabled) {
2961
// if we know for a fact that a screen reader is attached, we switch our strategy to advanced to
2962
// help that the editor's wrapping points match the textarea's wrapping points
2963
return 'advanced';
2964
}
2965
return value;
2966
}
2967
}
2968
//#endregion
2969
2970
//#region lightbulb
2971
2972
export enum ShowLightbulbIconMode {
2973
Off = 'off',
2974
OnCode = 'onCode',
2975
On = 'on'
2976
}
2977
2978
/**
2979
* Configuration options for editor lightbulb
2980
*/
2981
export interface IEditorLightbulbOptions {
2982
/**
2983
* Enable the lightbulb code action.
2984
* The three possible values are `off`, `on` and `onCode` and the default is `onCode`.
2985
* `off` disables the code action menu.
2986
* `on` shows the code action menu on code and on empty lines.
2987
* `onCode` shows the code action menu on code only.
2988
*/
2989
enabled?: ShowLightbulbIconMode;
2990
}
2991
2992
/**
2993
* @internal
2994
*/
2995
export type EditorLightbulbOptions = Readonly<Required<IEditorLightbulbOptions>>;
2996
2997
class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, IEditorLightbulbOptions, EditorLightbulbOptions> {
2998
2999
constructor() {
3000
const defaults: EditorLightbulbOptions = { enabled: ShowLightbulbIconMode.OnCode };
3001
super(
3002
EditorOption.lightbulb, 'lightbulb', defaults,
3003
{
3004
'editor.lightbulb.enabled': {
3005
type: 'string',
3006
enum: [ShowLightbulbIconMode.Off, ShowLightbulbIconMode.OnCode, ShowLightbulbIconMode.On],
3007
default: defaults.enabled,
3008
enumDescriptions: [
3009
nls.localize('editor.lightbulb.enabled.off', 'Disable the code action menu.'),
3010
nls.localize('editor.lightbulb.enabled.onCode', 'Show the code action menu when the cursor is on lines with code.'),
3011
nls.localize('editor.lightbulb.enabled.on', 'Show the code action menu when the cursor is on lines with code or on empty lines.'),
3012
],
3013
description: nls.localize('enabled', "Enables the Code Action lightbulb in the editor.")
3014
}
3015
}
3016
);
3017
}
3018
3019
public validate(_input: any): EditorLightbulbOptions {
3020
if (!_input || typeof _input !== 'object') {
3021
return this.defaultValue;
3022
}
3023
const input = _input as IEditorLightbulbOptions;
3024
return {
3025
enabled: stringSet(input.enabled, this.defaultValue.enabled, [ShowLightbulbIconMode.Off, ShowLightbulbIconMode.OnCode, ShowLightbulbIconMode.On])
3026
};
3027
}
3028
}
3029
3030
//#endregion
3031
3032
//#region stickyScroll
3033
3034
export interface IEditorStickyScrollOptions {
3035
/**
3036
* Enable the sticky scroll
3037
*/
3038
enabled?: boolean;
3039
/**
3040
* Maximum number of sticky lines to show
3041
*/
3042
maxLineCount?: number;
3043
/**
3044
* Model to choose for sticky scroll by default
3045
*/
3046
defaultModel?: 'outlineModel' | 'foldingProviderModel' | 'indentationModel';
3047
/**
3048
* Define whether to scroll sticky scroll with editor horizontal scrollbae
3049
*/
3050
scrollWithEditor?: boolean;
3051
}
3052
3053
/**
3054
* @internal
3055
*/
3056
export type EditorStickyScrollOptions = Readonly<Required<IEditorStickyScrollOptions>>;
3057
3058
class EditorStickyScroll extends BaseEditorOption<EditorOption.stickyScroll, IEditorStickyScrollOptions, EditorStickyScrollOptions> {
3059
3060
constructor() {
3061
const defaults: EditorStickyScrollOptions = { enabled: true, maxLineCount: 5, defaultModel: 'outlineModel', scrollWithEditor: true };
3062
super(
3063
EditorOption.stickyScroll, 'stickyScroll', defaults,
3064
{
3065
'editor.stickyScroll.enabled': {
3066
type: 'boolean',
3067
default: defaults.enabled,
3068
description: nls.localize('editor.stickyScroll.enabled', "Shows the nested current scopes during the scroll at the top of the editor.")
3069
},
3070
'editor.stickyScroll.maxLineCount': {
3071
type: 'number',
3072
default: defaults.maxLineCount,
3073
minimum: 1,
3074
maximum: 20,
3075
description: nls.localize('editor.stickyScroll.maxLineCount', "Defines the maximum number of sticky lines to show.")
3076
},
3077
'editor.stickyScroll.defaultModel': {
3078
type: 'string',
3079
enum: ['outlineModel', 'foldingProviderModel', 'indentationModel'],
3080
default: defaults.defaultModel,
3081
description: nls.localize('editor.stickyScroll.defaultModel', "Defines the model to use for determining which lines to stick. If the outline model does not exist, it will fall back on the folding provider model which falls back on the indentation model. This order is respected in all three cases.")
3082
},
3083
'editor.stickyScroll.scrollWithEditor': {
3084
type: 'boolean',
3085
default: defaults.scrollWithEditor,
3086
description: nls.localize('editor.stickyScroll.scrollWithEditor', "Enable scrolling of Sticky Scroll with the editor's horizontal scrollbar.")
3087
},
3088
}
3089
);
3090
}
3091
3092
public validate(_input: any): EditorStickyScrollOptions {
3093
if (!_input || typeof _input !== 'object') {
3094
return this.defaultValue;
3095
}
3096
const input = _input as IEditorStickyScrollOptions;
3097
return {
3098
enabled: boolean(input.enabled, this.defaultValue.enabled),
3099
maxLineCount: EditorIntOption.clampedInt(input.maxLineCount, this.defaultValue.maxLineCount, 1, 20),
3100
defaultModel: stringSet<'outlineModel' | 'foldingProviderModel' | 'indentationModel'>(input.defaultModel, this.defaultValue.defaultModel, ['outlineModel', 'foldingProviderModel', 'indentationModel']),
3101
scrollWithEditor: boolean(input.scrollWithEditor, this.defaultValue.scrollWithEditor)
3102
};
3103
}
3104
}
3105
3106
//#endregion
3107
3108
//#region inlayHints
3109
3110
/**
3111
* Configuration options for editor inlayHints
3112
*/
3113
export interface IEditorInlayHintsOptions {
3114
/**
3115
* Enable the inline hints.
3116
* Defaults to true.
3117
*/
3118
enabled?: 'on' | 'off' | 'offUnlessPressed' | 'onUnlessPressed';
3119
3120
/**
3121
* Font size of inline hints.
3122
* Default to 90% of the editor font size.
3123
*/
3124
fontSize?: number;
3125
3126
/**
3127
* Font family of inline hints.
3128
* Defaults to editor font family.
3129
*/
3130
fontFamily?: string;
3131
3132
/**
3133
* Enables the padding around the inlay hint.
3134
* Defaults to false.
3135
*/
3136
padding?: boolean;
3137
3138
/**
3139
* Maximum length for inlay hints per line
3140
* Set to 0 to have an unlimited length.
3141
*/
3142
maximumLength?: number;
3143
}
3144
3145
/**
3146
* @internal
3147
*/
3148
export type EditorInlayHintsOptions = Readonly<Required<IEditorInlayHintsOptions>>;
3149
3150
class EditorInlayHints extends BaseEditorOption<EditorOption.inlayHints, IEditorInlayHintsOptions, EditorInlayHintsOptions> {
3151
3152
constructor() {
3153
const defaults: EditorInlayHintsOptions = { enabled: 'on', fontSize: 0, fontFamily: '', padding: false, maximumLength: 43 };
3154
super(
3155
EditorOption.inlayHints, 'inlayHints', defaults,
3156
{
3157
'editor.inlayHints.enabled': {
3158
type: 'string',
3159
default: defaults.enabled,
3160
description: nls.localize('inlayHints.enable', "Enables the inlay hints in the editor."),
3161
enum: ['on', 'onUnlessPressed', 'offUnlessPressed', 'off'],
3162
markdownEnumDescriptions: [
3163
nls.localize('editor.inlayHints.on', "Inlay hints are enabled"),
3164
nls.localize('editor.inlayHints.onUnlessPressed', "Inlay hints are showing by default and hide when holding {0}", platform.isMacintosh ? `Ctrl+Option` : `Ctrl+Alt`),
3165
nls.localize('editor.inlayHints.offUnlessPressed', "Inlay hints are hidden by default and show when holding {0}", platform.isMacintosh ? `Ctrl+Option` : `Ctrl+Alt`),
3166
nls.localize('editor.inlayHints.off', "Inlay hints are disabled"),
3167
],
3168
},
3169
'editor.inlayHints.fontSize': {
3170
type: 'number',
3171
default: defaults.fontSize,
3172
markdownDescription: nls.localize('inlayHints.fontSize', "Controls font size of inlay hints in the editor. As default the {0} is used when the configured value is less than {1} or greater than the editor font size.", '`#editor.fontSize#`', '`5`')
3173
},
3174
'editor.inlayHints.fontFamily': {
3175
type: 'string',
3176
default: defaults.fontFamily,
3177
markdownDescription: nls.localize('inlayHints.fontFamily', "Controls font family of inlay hints in the editor. When set to empty, the {0} is used.", '`#editor.fontFamily#`')
3178
},
3179
'editor.inlayHints.padding': {
3180
type: 'boolean',
3181
default: defaults.padding,
3182
description: nls.localize('inlayHints.padding', "Enables the padding around the inlay hints in the editor.")
3183
},
3184
'editor.inlayHints.maximumLength': {
3185
type: 'number',
3186
default: defaults.maximumLength,
3187
markdownDescription: nls.localize('inlayHints.maximumLength', "Maximum overall length of inlay hints, for a single line, before they get truncated by the editor. Set to `0` to never truncate")
3188
}
3189
}
3190
);
3191
}
3192
3193
public validate(_input: any): EditorInlayHintsOptions {
3194
if (!_input || typeof _input !== 'object') {
3195
return this.defaultValue;
3196
}
3197
const input = _input as IEditorInlayHintsOptions;
3198
if (typeof input.enabled === 'boolean') {
3199
input.enabled = input.enabled ? 'on' : 'off';
3200
}
3201
return {
3202
enabled: stringSet<'on' | 'off' | 'offUnlessPressed' | 'onUnlessPressed'>(input.enabled, this.defaultValue.enabled, ['on', 'off', 'offUnlessPressed', 'onUnlessPressed']),
3203
fontSize: EditorIntOption.clampedInt(input.fontSize, this.defaultValue.fontSize, 0, 100),
3204
fontFamily: EditorStringOption.string(input.fontFamily, this.defaultValue.fontFamily),
3205
padding: boolean(input.padding, this.defaultValue.padding),
3206
maximumLength: EditorIntOption.clampedInt(input.maximumLength, this.defaultValue.maximumLength, 0, Number.MAX_SAFE_INTEGER),
3207
};
3208
}
3209
}
3210
3211
//#endregion
3212
3213
//#region lineDecorationsWidth
3214
3215
class EditorLineDecorationsWidth extends BaseEditorOption<EditorOption.lineDecorationsWidth, number | string, number> {
3216
3217
constructor() {
3218
super(EditorOption.lineDecorationsWidth, 'lineDecorationsWidth', 10);
3219
}
3220
3221
public validate(input: any): number {
3222
if (typeof input === 'string' && /^\d+(\.\d+)?ch$/.test(input)) {
3223
const multiple = parseFloat(input.substring(0, input.length - 2));
3224
return -multiple; // negative numbers signal a multiple
3225
} else {
3226
return EditorIntOption.clampedInt(input, this.defaultValue, 0, 1000);
3227
}
3228
}
3229
3230
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
3231
if (value < 0) {
3232
// negative numbers signal a multiple
3233
return EditorIntOption.clampedInt(-value * env.fontInfo.typicalHalfwidthCharacterWidth, this.defaultValue, 0, 1000);
3234
} else {
3235
return value;
3236
}
3237
}
3238
}
3239
3240
//#endregion
3241
3242
//#region lineHeight
3243
3244
class EditorLineHeight extends EditorFloatOption<EditorOption.lineHeight> {
3245
3246
constructor() {
3247
super(
3248
EditorOption.lineHeight, 'lineHeight',
3249
EDITOR_FONT_DEFAULTS.lineHeight,
3250
x => EditorFloatOption.clamp(x, 0, 150),
3251
{ 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.") },
3252
0,
3253
150
3254
);
3255
}
3256
3257
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: number): number {
3258
// The lineHeight is computed from the fontSize if it is 0.
3259
// Moreover, the final lineHeight respects the editor zoom level.
3260
// So take the result from env.fontInfo
3261
return env.fontInfo.lineHeight;
3262
}
3263
}
3264
3265
//#endregion
3266
3267
//#region minimap
3268
3269
/**
3270
* Configuration options for editor minimap
3271
*/
3272
export interface IEditorMinimapOptions {
3273
/**
3274
* Enable the rendering of the minimap.
3275
* Defaults to true.
3276
*/
3277
enabled?: boolean;
3278
/**
3279
* Control the rendering of minimap.
3280
*/
3281
autohide?: 'none' | 'mouseover' | 'scroll';
3282
/**
3283
* Control the side of the minimap in editor.
3284
* Defaults to 'right'.
3285
*/
3286
side?: 'right' | 'left';
3287
/**
3288
* Control the minimap rendering mode.
3289
* Defaults to 'actual'.
3290
*/
3291
size?: 'proportional' | 'fill' | 'fit';
3292
/**
3293
* Control the rendering of the minimap slider.
3294
* Defaults to 'mouseover'.
3295
*/
3296
showSlider?: 'always' | 'mouseover';
3297
/**
3298
* Render the actual text on a line (as opposed to color blocks).
3299
* Defaults to true.
3300
*/
3301
renderCharacters?: boolean;
3302
/**
3303
* Limit the width of the minimap to render at most a certain number of columns.
3304
* Defaults to 120.
3305
*/
3306
maxColumn?: number;
3307
/**
3308
* Relative size of the font in the minimap. Defaults to 1.
3309
*/
3310
scale?: number;
3311
/**
3312
* Whether to show named regions as section headers. Defaults to true.
3313
*/
3314
showRegionSectionHeaders?: boolean;
3315
/**
3316
* Whether to show MARK: comments as section headers. Defaults to true.
3317
*/
3318
showMarkSectionHeaders?: boolean;
3319
/**
3320
* When specified, is used to create a custom section header parser regexp.
3321
* Must contain a match group named 'label' (written as (?<label>.+)) that encapsulates the section header.
3322
* Optionally can include another match group named 'separator'.
3323
* To match multi-line headers like:
3324
* // ==========
3325
* // My Section
3326
* // ==========
3327
* Use a pattern like: ^={3,}\n^\/\/ *(?<label>[^\n]*?)\n^={3,}$
3328
*/
3329
markSectionHeaderRegex?: string;
3330
/**
3331
* Font size of section headers. Defaults to 9.
3332
*/
3333
sectionHeaderFontSize?: number;
3334
/**
3335
* Spacing between the section header characters (in CSS px). Defaults to 1.
3336
*/
3337
sectionHeaderLetterSpacing?: number;
3338
}
3339
3340
/**
3341
* @internal
3342
*/
3343
export type EditorMinimapOptions = Readonly<Required<IEditorMinimapOptions>>;
3344
3345
class EditorMinimap extends BaseEditorOption<EditorOption.minimap, IEditorMinimapOptions, EditorMinimapOptions> {
3346
3347
constructor() {
3348
const defaults: EditorMinimapOptions = {
3349
enabled: true,
3350
size: 'proportional',
3351
side: 'right',
3352
showSlider: 'mouseover',
3353
autohide: 'none',
3354
renderCharacters: true,
3355
maxColumn: 120,
3356
scale: 1,
3357
showRegionSectionHeaders: true,
3358
showMarkSectionHeaders: true,
3359
markSectionHeaderRegex: '\\bMARK:\\s*(?<separator>\-?)\\s*(?<label>.*)$',
3360
sectionHeaderFontSize: 9,
3361
sectionHeaderLetterSpacing: 1,
3362
};
3363
super(
3364
EditorOption.minimap, 'minimap', defaults,
3365
{
3366
'editor.minimap.enabled': {
3367
type: 'boolean',
3368
default: defaults.enabled,
3369
description: nls.localize('minimap.enabled', "Controls whether the minimap is shown.")
3370
},
3371
'editor.minimap.autohide': {
3372
type: 'string',
3373
enum: ['none', 'mouseover', 'scroll'],
3374
enumDescriptions: [
3375
nls.localize('minimap.autohide.none', "The minimap is always shown."),
3376
nls.localize('minimap.autohide.mouseover', "The minimap is hidden when mouse is not over the minimap and shown when mouse is over the minimap."),
3377
nls.localize('minimap.autohide.scroll', "The minimap is only shown when the editor is scrolled"),
3378
],
3379
default: defaults.autohide,
3380
description: nls.localize('minimap.autohide', "Controls whether the minimap is hidden automatically.")
3381
},
3382
'editor.minimap.size': {
3383
type: 'string',
3384
enum: ['proportional', 'fill', 'fit'],
3385
enumDescriptions: [
3386
nls.localize('minimap.size.proportional', "The minimap has the same size as the editor contents (and might scroll)."),
3387
nls.localize('minimap.size.fill', "The minimap will stretch or shrink as necessary to fill the height of the editor (no scrolling)."),
3388
nls.localize('minimap.size.fit', "The minimap will shrink as necessary to never be larger than the editor (no scrolling)."),
3389
],
3390
default: defaults.size,
3391
description: nls.localize('minimap.size', "Controls the size of the minimap.")
3392
},
3393
'editor.minimap.side': {
3394
type: 'string',
3395
enum: ['left', 'right'],
3396
default: defaults.side,
3397
description: nls.localize('minimap.side', "Controls the side where to render the minimap.")
3398
},
3399
'editor.minimap.showSlider': {
3400
type: 'string',
3401
enum: ['always', 'mouseover'],
3402
default: defaults.showSlider,
3403
description: nls.localize('minimap.showSlider', "Controls when the minimap slider is shown.")
3404
},
3405
'editor.minimap.scale': {
3406
type: 'number',
3407
default: defaults.scale,
3408
minimum: 1,
3409
maximum: 3,
3410
enum: [1, 2, 3],
3411
description: nls.localize('minimap.scale', "Scale of content drawn in the minimap: 1, 2 or 3.")
3412
},
3413
'editor.minimap.renderCharacters': {
3414
type: 'boolean',
3415
default: defaults.renderCharacters,
3416
description: nls.localize('minimap.renderCharacters', "Render the actual characters on a line as opposed to color blocks.")
3417
},
3418
'editor.minimap.maxColumn': {
3419
type: 'number',
3420
default: defaults.maxColumn,
3421
description: nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns.")
3422
},
3423
'editor.minimap.showRegionSectionHeaders': {
3424
type: 'boolean',
3425
default: defaults.showRegionSectionHeaders,
3426
description: nls.localize('minimap.showRegionSectionHeaders', "Controls whether named regions are shown as section headers in the minimap.")
3427
},
3428
'editor.minimap.showMarkSectionHeaders': {
3429
type: 'boolean',
3430
default: defaults.showMarkSectionHeaders,
3431
description: nls.localize('minimap.showMarkSectionHeaders', "Controls whether MARK: comments are shown as section headers in the minimap.")
3432
},
3433
'editor.minimap.markSectionHeaderRegex': {
3434
type: 'string',
3435
default: defaults.markSectionHeaderRegex,
3436
description: nls.localize('minimap.markSectionHeaderRegex', "Defines the regular expression used to find section headers in comments. The regex must contain a named match group `label` (written as `(?<label>.+)`) that encapsulates the section header, otherwise it will not work. Optionally you can include another match group named `separator`. Use \\n in the pattern to match multi-line headers."),
3437
},
3438
'editor.minimap.sectionHeaderFontSize': {
3439
type: 'number',
3440
default: defaults.sectionHeaderFontSize,
3441
description: nls.localize('minimap.sectionHeaderFontSize', "Controls the font size of section headers in the minimap.")
3442
},
3443
'editor.minimap.sectionHeaderLetterSpacing': {
3444
type: 'number',
3445
default: defaults.sectionHeaderLetterSpacing,
3446
description: nls.localize('minimap.sectionHeaderLetterSpacing', "Controls the amount of space (in pixels) between characters of section header. This helps the readability of the header in small font sizes.")
3447
}
3448
}
3449
);
3450
}
3451
3452
public validate(_input: any): EditorMinimapOptions {
3453
if (!_input || typeof _input !== 'object') {
3454
return this.defaultValue;
3455
}
3456
const input = _input as IEditorMinimapOptions;
3457
3458
// Validate mark section header regex
3459
let markSectionHeaderRegex = this.defaultValue.markSectionHeaderRegex;
3460
const inputRegex = _input.markSectionHeaderRegex;
3461
if (typeof inputRegex === 'string') {
3462
try {
3463
new RegExp(inputRegex, 'd');
3464
markSectionHeaderRegex = inputRegex;
3465
} catch { }
3466
}
3467
3468
return {
3469
enabled: boolean(input.enabled, this.defaultValue.enabled),
3470
autohide: stringSet<'none' | 'mouseover' | 'scroll'>(input.autohide, this.defaultValue.autohide, ['none', 'mouseover', 'scroll']),
3471
size: stringSet<'proportional' | 'fill' | 'fit'>(input.size, this.defaultValue.size, ['proportional', 'fill', 'fit']),
3472
side: stringSet<'right' | 'left'>(input.side, this.defaultValue.side, ['right', 'left']),
3473
showSlider: stringSet<'always' | 'mouseover'>(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
3474
renderCharacters: boolean(input.renderCharacters, this.defaultValue.renderCharacters),
3475
scale: EditorIntOption.clampedInt(input.scale, 1, 1, 3),
3476
maxColumn: EditorIntOption.clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000),
3477
showRegionSectionHeaders: boolean(input.showRegionSectionHeaders, this.defaultValue.showRegionSectionHeaders),
3478
showMarkSectionHeaders: boolean(input.showMarkSectionHeaders, this.defaultValue.showMarkSectionHeaders),
3479
markSectionHeaderRegex: markSectionHeaderRegex,
3480
sectionHeaderFontSize: EditorFloatOption.clamp(input.sectionHeaderFontSize ?? this.defaultValue.sectionHeaderFontSize, 4, 32),
3481
sectionHeaderLetterSpacing: EditorFloatOption.clamp(input.sectionHeaderLetterSpacing ?? this.defaultValue.sectionHeaderLetterSpacing, 0, 5),
3482
};
3483
}
3484
}
3485
3486
//#endregion
3487
3488
//#region multiCursorModifier
3489
3490
function _multiCursorModifierFromString(multiCursorModifier: 'ctrlCmd' | 'alt'): 'altKey' | 'metaKey' | 'ctrlKey' {
3491
if (multiCursorModifier === 'ctrlCmd') {
3492
return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
3493
}
3494
return 'altKey';
3495
}
3496
3497
//#endregion
3498
3499
//#region padding
3500
3501
/**
3502
* Configuration options for editor padding
3503
*/
3504
export interface IEditorPaddingOptions {
3505
/**
3506
* Spacing between top edge of editor and first line.
3507
*/
3508
top?: number;
3509
/**
3510
* Spacing between bottom edge of editor and last line.
3511
*/
3512
bottom?: number;
3513
}
3514
3515
/**
3516
* @internal
3517
*/
3518
export type InternalEditorPaddingOptions = Readonly<Required<IEditorPaddingOptions>>;
3519
3520
class EditorPadding extends BaseEditorOption<EditorOption.padding, IEditorPaddingOptions, InternalEditorPaddingOptions> {
3521
3522
constructor() {
3523
super(
3524
EditorOption.padding, 'padding', { top: 0, bottom: 0 },
3525
{
3526
'editor.padding.top': {
3527
type: 'number',
3528
default: 0,
3529
minimum: 0,
3530
maximum: 1000,
3531
description: nls.localize('padding.top', "Controls the amount of space between the top edge of the editor and the first line.")
3532
},
3533
'editor.padding.bottom': {
3534
type: 'number',
3535
default: 0,
3536
minimum: 0,
3537
maximum: 1000,
3538
description: nls.localize('padding.bottom', "Controls the amount of space between the bottom edge of the editor and the last line.")
3539
}
3540
}
3541
);
3542
}
3543
3544
public validate(_input: any): InternalEditorPaddingOptions {
3545
if (!_input || typeof _input !== 'object') {
3546
return this.defaultValue;
3547
}
3548
const input = _input as IEditorPaddingOptions;
3549
3550
return {
3551
top: EditorIntOption.clampedInt(input.top, 0, 0, 1000),
3552
bottom: EditorIntOption.clampedInt(input.bottom, 0, 0, 1000)
3553
};
3554
}
3555
}
3556
//#endregion
3557
3558
//#region parameterHints
3559
3560
/**
3561
* Configuration options for parameter hints
3562
*/
3563
export interface IEditorParameterHintOptions {
3564
/**
3565
* Enable parameter hints.
3566
* Defaults to true.
3567
*/
3568
enabled?: boolean;
3569
/**
3570
* Enable cycling of parameter hints.
3571
* Defaults to false.
3572
*/
3573
cycle?: boolean;
3574
}
3575
3576
/**
3577
* @internal
3578
*/
3579
export type InternalParameterHintOptions = Readonly<Required<IEditorParameterHintOptions>>;
3580
3581
class EditorParameterHints extends BaseEditorOption<EditorOption.parameterHints, IEditorParameterHintOptions, InternalParameterHintOptions> {
3582
3583
constructor() {
3584
const defaults: InternalParameterHintOptions = {
3585
enabled: true,
3586
cycle: true
3587
};
3588
super(
3589
EditorOption.parameterHints, 'parameterHints', defaults,
3590
{
3591
'editor.parameterHints.enabled': {
3592
type: 'boolean',
3593
default: defaults.enabled,
3594
description: nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.")
3595
},
3596
'editor.parameterHints.cycle': {
3597
type: 'boolean',
3598
default: defaults.cycle,
3599
description: nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
3600
},
3601
}
3602
);
3603
}
3604
3605
public validate(_input: any): InternalParameterHintOptions {
3606
if (!_input || typeof _input !== 'object') {
3607
return this.defaultValue;
3608
}
3609
const input = _input as IEditorParameterHintOptions;
3610
return {
3611
enabled: boolean(input.enabled, this.defaultValue.enabled),
3612
cycle: boolean(input.cycle, this.defaultValue.cycle)
3613
};
3614
}
3615
}
3616
3617
//#endregion
3618
3619
//#region pixelRatio
3620
3621
class EditorPixelRatio extends ComputedEditorOption<EditorOption.pixelRatio, number> {
3622
3623
constructor() {
3624
super(EditorOption.pixelRatio);
3625
}
3626
3627
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: number): number {
3628
return env.pixelRatio;
3629
}
3630
}
3631
3632
//#endregion
3633
3634
//#region
3635
3636
class PlaceholderOption extends BaseEditorOption<EditorOption.placeholder, string | undefined, string | undefined> {
3637
constructor() {
3638
super(EditorOption.placeholder, 'placeholder', undefined);
3639
}
3640
3641
public validate(input: any): string | undefined {
3642
if (typeof input === 'undefined') {
3643
return this.defaultValue;
3644
}
3645
if (typeof input === 'string') {
3646
return input;
3647
}
3648
return this.defaultValue;
3649
}
3650
}
3651
//#endregion
3652
3653
//#region quickSuggestions
3654
3655
export type QuickSuggestionsValue = 'on' | 'inline' | 'off';
3656
3657
/**
3658
* Configuration options for quick suggestions
3659
*/
3660
export interface IQuickSuggestionsOptions {
3661
other?: boolean | QuickSuggestionsValue;
3662
comments?: boolean | QuickSuggestionsValue;
3663
strings?: boolean | QuickSuggestionsValue;
3664
}
3665
3666
export interface InternalQuickSuggestionsOptions {
3667
readonly other: QuickSuggestionsValue;
3668
readonly comments: QuickSuggestionsValue;
3669
readonly strings: QuickSuggestionsValue;
3670
}
3671
3672
class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggestions, boolean | IQuickSuggestionsOptions, InternalQuickSuggestionsOptions> {
3673
3674
public override readonly defaultValue: InternalQuickSuggestionsOptions;
3675
3676
constructor() {
3677
const defaults: InternalQuickSuggestionsOptions = {
3678
other: 'on',
3679
comments: 'off',
3680
strings: 'off'
3681
};
3682
const types: IJSONSchema[] = [
3683
{ type: 'boolean' },
3684
{
3685
type: 'string',
3686
enum: ['on', 'inline', 'off'],
3687
enumDescriptions: [nls.localize('on', "Quick suggestions show inside the suggest widget"), nls.localize('inline', "Quick suggestions show as ghost text"), nls.localize('off', "Quick suggestions are disabled")]
3688
}
3689
];
3690
super(EditorOption.quickSuggestions, 'quickSuggestions', defaults, {
3691
type: 'object',
3692
additionalProperties: false,
3693
properties: {
3694
strings: {
3695
anyOf: types,
3696
default: defaults.strings,
3697
description: nls.localize('quickSuggestions.strings', "Enable quick suggestions inside strings.")
3698
},
3699
comments: {
3700
anyOf: types,
3701
default: defaults.comments,
3702
description: nls.localize('quickSuggestions.comments', "Enable quick suggestions inside comments.")
3703
},
3704
other: {
3705
anyOf: types,
3706
default: defaults.other,
3707
description: nls.localize('quickSuggestions.other', "Enable quick suggestions outside of strings and comments.")
3708
},
3709
},
3710
default: defaults,
3711
markdownDescription: nls.localize('quickSuggestions', "Controls whether suggestions should automatically show up while typing. This can be controlled for typing in comments, strings, and other code. Quick suggestion can be configured to show as ghost text or with the suggest widget. Also be aware of the {0}-setting which controls if suggestions are triggered by special characters.", '`#editor.suggestOnTriggerCharacters#`')
3712
});
3713
this.defaultValue = defaults;
3714
}
3715
3716
public validate(input: any): InternalQuickSuggestionsOptions {
3717
if (typeof input === 'boolean') {
3718
// boolean -> all on/off
3719
const value = input ? 'on' : 'off';
3720
return { comments: value, strings: value, other: value };
3721
}
3722
if (!input || typeof input !== 'object') {
3723
// invalid object
3724
return this.defaultValue;
3725
}
3726
3727
const { other, comments, strings } = (<IQuickSuggestionsOptions>input);
3728
const allowedValues: QuickSuggestionsValue[] = ['on', 'inline', 'off'];
3729
let validatedOther: QuickSuggestionsValue;
3730
let validatedComments: QuickSuggestionsValue;
3731
let validatedStrings: QuickSuggestionsValue;
3732
3733
if (typeof other === 'boolean') {
3734
validatedOther = other ? 'on' : 'off';
3735
} else {
3736
validatedOther = stringSet(other, this.defaultValue.other, allowedValues);
3737
}
3738
if (typeof comments === 'boolean') {
3739
validatedComments = comments ? 'on' : 'off';
3740
} else {
3741
validatedComments = stringSet(comments, this.defaultValue.comments, allowedValues);
3742
}
3743
if (typeof strings === 'boolean') {
3744
validatedStrings = strings ? 'on' : 'off';
3745
} else {
3746
validatedStrings = stringSet(strings, this.defaultValue.strings, allowedValues);
3747
}
3748
return {
3749
other: validatedOther,
3750
comments: validatedComments,
3751
strings: validatedStrings
3752
};
3753
}
3754
}
3755
3756
//#endregion
3757
3758
//#region renderLineNumbers
3759
3760
export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
3761
3762
export const enum RenderLineNumbersType {
3763
Off = 0,
3764
On = 1,
3765
Relative = 2,
3766
Interval = 3,
3767
Custom = 4
3768
}
3769
3770
export interface InternalEditorRenderLineNumbersOptions {
3771
readonly renderType: RenderLineNumbersType;
3772
readonly renderFn: ((lineNumber: number) => string) | null;
3773
}
3774
3775
class EditorRenderLineNumbersOption extends BaseEditorOption<EditorOption.lineNumbers, LineNumbersType, InternalEditorRenderLineNumbersOptions> {
3776
3777
constructor() {
3778
super(
3779
EditorOption.lineNumbers, 'lineNumbers', { renderType: RenderLineNumbersType.On, renderFn: null },
3780
{
3781
type: 'string',
3782
enum: ['off', 'on', 'relative', 'interval'],
3783
enumDescriptions: [
3784
nls.localize('lineNumbers.off', "Line numbers are not rendered."),
3785
nls.localize('lineNumbers.on', "Line numbers are rendered as absolute number."),
3786
nls.localize('lineNumbers.relative', "Line numbers are rendered as distance in lines to cursor position."),
3787
nls.localize('lineNumbers.interval', "Line numbers are rendered every 10 lines.")
3788
],
3789
default: 'on',
3790
description: nls.localize('lineNumbers', "Controls the display of line numbers.")
3791
}
3792
);
3793
}
3794
3795
public validate(lineNumbers: any): InternalEditorRenderLineNumbersOptions {
3796
let renderType: RenderLineNumbersType = this.defaultValue.renderType;
3797
let renderFn: ((lineNumber: number) => string) | null = this.defaultValue.renderFn;
3798
3799
if (typeof lineNumbers !== 'undefined') {
3800
if (typeof lineNumbers === 'function') {
3801
renderType = RenderLineNumbersType.Custom;
3802
renderFn = lineNumbers;
3803
} else if (lineNumbers === 'interval') {
3804
renderType = RenderLineNumbersType.Interval;
3805
} else if (lineNumbers === 'relative') {
3806
renderType = RenderLineNumbersType.Relative;
3807
} else if (lineNumbers === 'on') {
3808
renderType = RenderLineNumbersType.On;
3809
} else {
3810
renderType = RenderLineNumbersType.Off;
3811
}
3812
}
3813
3814
return {
3815
renderType,
3816
renderFn
3817
};
3818
}
3819
}
3820
3821
//#endregion
3822
3823
//#region renderValidationDecorations
3824
3825
/**
3826
* @internal
3827
*/
3828
export function filterValidationDecorations(options: IComputedEditorOptions): boolean {
3829
const renderValidationDecorations = options.get(EditorOption.renderValidationDecorations);
3830
if (renderValidationDecorations === 'editable') {
3831
return options.get(EditorOption.readOnly);
3832
}
3833
return renderValidationDecorations === 'on' ? false : true;
3834
}
3835
3836
//#endregion
3837
3838
//#region filterFontDecorations
3839
3840
/**
3841
* @internal
3842
*/
3843
export function filterFontDecorations(options: IComputedEditorOptions): boolean {
3844
return !options.get(EditorOption.effectiveAllowVariableFonts);
3845
}
3846
3847
//#endregion
3848
3849
//#region rulers
3850
3851
export interface IRulerOption {
3852
readonly column: number;
3853
readonly color: string | null;
3854
}
3855
3856
class EditorRulers extends BaseEditorOption<EditorOption.rulers, (number | IRulerOption)[], IRulerOption[]> {
3857
3858
constructor() {
3859
const defaults: IRulerOption[] = [];
3860
const columnSchema: IJSONSchema = { type: 'number', description: nls.localize('rulers.size', "Number of monospace characters at which this editor ruler will render.") };
3861
super(
3862
EditorOption.rulers, 'rulers', defaults,
3863
{
3864
type: 'array',
3865
items: {
3866
anyOf: [
3867
columnSchema,
3868
{
3869
type: [
3870
'object'
3871
],
3872
properties: {
3873
column: columnSchema,
3874
color: {
3875
type: 'string',
3876
description: nls.localize('rulers.color', "Color of this editor ruler."),
3877
format: 'color-hex'
3878
}
3879
}
3880
}
3881
]
3882
},
3883
default: defaults,
3884
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.")
3885
}
3886
);
3887
}
3888
3889
public validate(input: any): IRulerOption[] {
3890
if (Array.isArray(input)) {
3891
const rulers: IRulerOption[] = [];
3892
for (const _element of input) {
3893
if (typeof _element === 'number') {
3894
rulers.push({
3895
column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
3896
color: null
3897
});
3898
} else if (_element && typeof _element === 'object') {
3899
const element = _element as IRulerOption;
3900
rulers.push({
3901
column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
3902
color: element.color
3903
});
3904
}
3905
}
3906
rulers.sort((a, b) => a.column - b.column);
3907
return rulers;
3908
}
3909
return this.defaultValue;
3910
}
3911
}
3912
3913
//#endregion
3914
3915
//#region readonly
3916
3917
/**
3918
* Configuration options for readonly message
3919
*/
3920
class ReadonlyMessage extends BaseEditorOption<EditorOption.readOnlyMessage, IMarkdownString | undefined, IMarkdownString | undefined> {
3921
constructor() {
3922
const defaults = undefined;
3923
3924
super(
3925
EditorOption.readOnlyMessage, 'readOnlyMessage', defaults
3926
);
3927
}
3928
3929
public validate(_input: any): IMarkdownString | undefined {
3930
if (!_input || typeof _input !== 'object') {
3931
return this.defaultValue;
3932
}
3933
return _input as IMarkdownString;
3934
}
3935
}
3936
3937
//#endregion
3938
3939
//#region scrollbar
3940
3941
/**
3942
* Configuration options for editor scrollbars
3943
*/
3944
export interface IEditorScrollbarOptions {
3945
/**
3946
* The size of arrows (if displayed).
3947
* Defaults to 11.
3948
* **NOTE**: This option cannot be updated using `updateOptions()`
3949
*/
3950
arrowSize?: number;
3951
/**
3952
* Render vertical scrollbar.
3953
* Defaults to 'auto'.
3954
*/
3955
vertical?: 'auto' | 'visible' | 'hidden';
3956
/**
3957
* Render horizontal scrollbar.
3958
* Defaults to 'auto'.
3959
*/
3960
horizontal?: 'auto' | 'visible' | 'hidden';
3961
/**
3962
* Cast horizontal and vertical shadows when the content is scrolled.
3963
* Defaults to true.
3964
* **NOTE**: This option cannot be updated using `updateOptions()`
3965
*/
3966
useShadows?: boolean;
3967
/**
3968
* Render arrows at the top and bottom of the vertical scrollbar.
3969
* Defaults to false.
3970
* **NOTE**: This option cannot be updated using `updateOptions()`
3971
*/
3972
verticalHasArrows?: boolean;
3973
/**
3974
* Render arrows at the left and right of the horizontal scrollbar.
3975
* Defaults to false.
3976
* **NOTE**: This option cannot be updated using `updateOptions()`
3977
*/
3978
horizontalHasArrows?: boolean;
3979
/**
3980
* Listen to mouse wheel events and react to them by scrolling.
3981
* Defaults to true.
3982
*/
3983
handleMouseWheel?: boolean;
3984
/**
3985
* Always consume mouse wheel events (always call preventDefault() and stopPropagation() on the browser events).
3986
* Defaults to true.
3987
* **NOTE**: This option cannot be updated using `updateOptions()`
3988
*/
3989
alwaysConsumeMouseWheel?: boolean;
3990
/**
3991
* Height in pixels for the horizontal scrollbar.
3992
* Defaults to 12 (px).
3993
*/
3994
horizontalScrollbarSize?: number;
3995
/**
3996
* Width in pixels for the vertical scrollbar.
3997
* Defaults to 14 (px).
3998
*/
3999
verticalScrollbarSize?: number;
4000
/**
4001
* Width in pixels for the vertical slider.
4002
* Defaults to `verticalScrollbarSize`.
4003
* **NOTE**: This option cannot be updated using `updateOptions()`
4004
*/
4005
verticalSliderSize?: number;
4006
/**
4007
* Height in pixels for the horizontal slider.
4008
* Defaults to `horizontalScrollbarSize`.
4009
* **NOTE**: This option cannot be updated using `updateOptions()`
4010
*/
4011
horizontalSliderSize?: number;
4012
/**
4013
* Scroll gutter clicks move by page vs jump to position.
4014
* Defaults to false.
4015
*/
4016
scrollByPage?: boolean;
4017
4018
/**
4019
* When set, the horizontal scrollbar will not increase content height.
4020
* Defaults to false.
4021
*/
4022
ignoreHorizontalScrollbarInContentHeight?: boolean;
4023
}
4024
4025
export interface InternalEditorScrollbarOptions {
4026
readonly arrowSize: number;
4027
readonly vertical: ScrollbarVisibility;
4028
readonly horizontal: ScrollbarVisibility;
4029
readonly useShadows: boolean;
4030
readonly verticalHasArrows: boolean;
4031
readonly horizontalHasArrows: boolean;
4032
readonly handleMouseWheel: boolean;
4033
readonly alwaysConsumeMouseWheel: boolean;
4034
readonly horizontalScrollbarSize: number;
4035
readonly horizontalSliderSize: number;
4036
readonly verticalScrollbarSize: number;
4037
readonly verticalSliderSize: number;
4038
readonly scrollByPage: boolean;
4039
readonly ignoreHorizontalScrollbarInContentHeight: boolean;
4040
}
4041
4042
function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
4043
if (typeof visibility !== 'string') {
4044
return defaultValue;
4045
}
4046
switch (visibility) {
4047
case 'hidden': return ScrollbarVisibility.Hidden;
4048
case 'visible': return ScrollbarVisibility.Visible;
4049
default: return ScrollbarVisibility.Auto;
4050
}
4051
}
4052
4053
class EditorScrollbar extends BaseEditorOption<EditorOption.scrollbar, IEditorScrollbarOptions, InternalEditorScrollbarOptions> {
4054
4055
constructor() {
4056
const defaults: InternalEditorScrollbarOptions = {
4057
vertical: ScrollbarVisibility.Auto,
4058
horizontal: ScrollbarVisibility.Auto,
4059
arrowSize: 11,
4060
useShadows: true,
4061
verticalHasArrows: false,
4062
horizontalHasArrows: false,
4063
horizontalScrollbarSize: 12,
4064
horizontalSliderSize: 12,
4065
verticalScrollbarSize: 14,
4066
verticalSliderSize: 14,
4067
handleMouseWheel: true,
4068
alwaysConsumeMouseWheel: true,
4069
scrollByPage: false,
4070
ignoreHorizontalScrollbarInContentHeight: false,
4071
};
4072
super(
4073
EditorOption.scrollbar, 'scrollbar', defaults,
4074
{
4075
'editor.scrollbar.vertical': {
4076
type: 'string',
4077
enum: ['auto', 'visible', 'hidden'],
4078
enumDescriptions: [
4079
nls.localize('scrollbar.vertical.auto', "The vertical scrollbar will be visible only when necessary."),
4080
nls.localize('scrollbar.vertical.visible', "The vertical scrollbar will always be visible."),
4081
nls.localize('scrollbar.vertical.fit', "The vertical scrollbar will always be hidden."),
4082
],
4083
default: 'auto',
4084
description: nls.localize('scrollbar.vertical', "Controls the visibility of the vertical scrollbar.")
4085
},
4086
'editor.scrollbar.horizontal': {
4087
type: 'string',
4088
enum: ['auto', 'visible', 'hidden'],
4089
enumDescriptions: [
4090
nls.localize('scrollbar.horizontal.auto', "The horizontal scrollbar will be visible only when necessary."),
4091
nls.localize('scrollbar.horizontal.visible', "The horizontal scrollbar will always be visible."),
4092
nls.localize('scrollbar.horizontal.fit', "The horizontal scrollbar will always be hidden."),
4093
],
4094
default: 'auto',
4095
description: nls.localize('scrollbar.horizontal', "Controls the visibility of the horizontal scrollbar.")
4096
},
4097
'editor.scrollbar.verticalScrollbarSize': {
4098
type: 'number',
4099
default: defaults.verticalScrollbarSize,
4100
description: nls.localize('scrollbar.verticalScrollbarSize', "The width of the vertical scrollbar.")
4101
},
4102
'editor.scrollbar.horizontalScrollbarSize': {
4103
type: 'number',
4104
default: defaults.horizontalScrollbarSize,
4105
description: nls.localize('scrollbar.horizontalScrollbarSize', "The height of the horizontal scrollbar.")
4106
},
4107
'editor.scrollbar.scrollByPage': {
4108
type: 'boolean',
4109
default: defaults.scrollByPage,
4110
description: nls.localize('scrollbar.scrollByPage', "Controls whether clicks scroll by page or jump to click position.")
4111
},
4112
'editor.scrollbar.ignoreHorizontalScrollbarInContentHeight': {
4113
type: 'boolean',
4114
default: defaults.ignoreHorizontalScrollbarInContentHeight,
4115
description: nls.localize('scrollbar.ignoreHorizontalScrollbarInContentHeight', "When set, the horizontal scrollbar will not increase the size of the editor's content.")
4116
}
4117
}
4118
);
4119
}
4120
4121
public validate(_input: any): InternalEditorScrollbarOptions {
4122
if (!_input || typeof _input !== 'object') {
4123
return this.defaultValue;
4124
}
4125
const input = _input as IEditorScrollbarOptions;
4126
const horizontalScrollbarSize = EditorIntOption.clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000);
4127
const verticalScrollbarSize = EditorIntOption.clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000);
4128
return {
4129
arrowSize: EditorIntOption.clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000),
4130
vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical),
4131
horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal),
4132
useShadows: boolean(input.useShadows, this.defaultValue.useShadows),
4133
verticalHasArrows: boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows),
4134
horizontalHasArrows: boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows),
4135
handleMouseWheel: boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel),
4136
alwaysConsumeMouseWheel: boolean(input.alwaysConsumeMouseWheel, this.defaultValue.alwaysConsumeMouseWheel),
4137
horizontalScrollbarSize: horizontalScrollbarSize,
4138
horizontalSliderSize: EditorIntOption.clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),
4139
verticalScrollbarSize: verticalScrollbarSize,
4140
verticalSliderSize: EditorIntOption.clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000),
4141
scrollByPage: boolean(input.scrollByPage, this.defaultValue.scrollByPage),
4142
ignoreHorizontalScrollbarInContentHeight: boolean(input.ignoreHorizontalScrollbarInContentHeight, this.defaultValue.ignoreHorizontalScrollbarInContentHeight),
4143
};
4144
}
4145
}
4146
4147
//#endregion
4148
4149
//#region UnicodeHighlight
4150
4151
export type InUntrustedWorkspace = 'inUntrustedWorkspace';
4152
4153
/**
4154
* @internal
4155
*/
4156
export const inUntrustedWorkspace: InUntrustedWorkspace = 'inUntrustedWorkspace';
4157
4158
/**
4159
* Configuration options for unicode highlighting.
4160
*/
4161
export interface IUnicodeHighlightOptions {
4162
4163
/**
4164
* Controls whether all non-basic ASCII characters are highlighted. Only characters between U+0020 and U+007E, tab, line-feed and carriage-return are considered basic ASCII.
4165
*/
4166
nonBasicASCII?: boolean | InUntrustedWorkspace;
4167
4168
/**
4169
* Controls whether characters that just reserve space or have no width at all are highlighted.
4170
*/
4171
invisibleCharacters?: boolean;
4172
4173
/**
4174
* Controls whether characters are highlighted that can be confused with basic ASCII characters, except those that are common in the current user locale.
4175
*/
4176
ambiguousCharacters?: boolean;
4177
4178
/**
4179
* Controls whether characters in comments should also be subject to unicode highlighting.
4180
*/
4181
includeComments?: boolean | InUntrustedWorkspace;
4182
4183
/**
4184
* Controls whether characters in strings should also be subject to unicode highlighting.
4185
*/
4186
includeStrings?: boolean | InUntrustedWorkspace;
4187
4188
/**
4189
* Defines allowed characters that are not being highlighted.
4190
*/
4191
allowedCharacters?: Record<string, true>;
4192
4193
/**
4194
* Unicode characters that are common in allowed locales are not being highlighted.
4195
*/
4196
allowedLocales?: Record<string | '_os' | '_vscode', true>;
4197
}
4198
4199
/**
4200
* @internal
4201
*/
4202
export type InternalUnicodeHighlightOptions = Required<Readonly<IUnicodeHighlightOptions>>;
4203
4204
/**
4205
* @internal
4206
*/
4207
export const unicodeHighlightConfigKeys = {
4208
allowedCharacters: 'editor.unicodeHighlight.allowedCharacters',
4209
invisibleCharacters: 'editor.unicodeHighlight.invisibleCharacters',
4210
nonBasicASCII: 'editor.unicodeHighlight.nonBasicASCII',
4211
ambiguousCharacters: 'editor.unicodeHighlight.ambiguousCharacters',
4212
includeComments: 'editor.unicodeHighlight.includeComments',
4213
includeStrings: 'editor.unicodeHighlight.includeStrings',
4214
allowedLocales: 'editor.unicodeHighlight.allowedLocales',
4215
};
4216
4217
class UnicodeHighlight extends BaseEditorOption<EditorOption.unicodeHighlighting, IUnicodeHighlightOptions, InternalUnicodeHighlightOptions> {
4218
constructor() {
4219
const defaults: InternalUnicodeHighlightOptions = {
4220
nonBasicASCII: inUntrustedWorkspace,
4221
invisibleCharacters: true,
4222
ambiguousCharacters: true,
4223
includeComments: inUntrustedWorkspace,
4224
includeStrings: true,
4225
allowedCharacters: {},
4226
allowedLocales: { _os: true, _vscode: true },
4227
};
4228
4229
super(
4230
EditorOption.unicodeHighlighting, 'unicodeHighlight', defaults,
4231
{
4232
[unicodeHighlightConfigKeys.nonBasicASCII]: {
4233
restricted: true,
4234
type: ['boolean', 'string'],
4235
enum: [true, false, inUntrustedWorkspace],
4236
default: defaults.nonBasicASCII,
4237
description: nls.localize('unicodeHighlight.nonBasicASCII', "Controls whether all non-basic ASCII characters are highlighted. Only characters between U+0020 and U+007E, tab, line-feed and carriage-return are considered basic ASCII.")
4238
},
4239
[unicodeHighlightConfigKeys.invisibleCharacters]: {
4240
restricted: true,
4241
type: 'boolean',
4242
default: defaults.invisibleCharacters,
4243
description: nls.localize('unicodeHighlight.invisibleCharacters', "Controls whether characters that just reserve space or have no width at all are highlighted.")
4244
},
4245
[unicodeHighlightConfigKeys.ambiguousCharacters]: {
4246
restricted: true,
4247
type: 'boolean',
4248
default: defaults.ambiguousCharacters,
4249
description: nls.localize('unicodeHighlight.ambiguousCharacters', "Controls whether characters are highlighted that can be confused with basic ASCII characters, except those that are common in the current user locale.")
4250
},
4251
[unicodeHighlightConfigKeys.includeComments]: {
4252
restricted: true,
4253
type: ['boolean', 'string'],
4254
enum: [true, false, inUntrustedWorkspace],
4255
default: defaults.includeComments,
4256
description: nls.localize('unicodeHighlight.includeComments', "Controls whether characters in comments should also be subject to Unicode highlighting.")
4257
},
4258
[unicodeHighlightConfigKeys.includeStrings]: {
4259
restricted: true,
4260
type: ['boolean', 'string'],
4261
enum: [true, false, inUntrustedWorkspace],
4262
default: defaults.includeStrings,
4263
description: nls.localize('unicodeHighlight.includeStrings', "Controls whether characters in strings should also be subject to Unicode highlighting.")
4264
},
4265
[unicodeHighlightConfigKeys.allowedCharacters]: {
4266
restricted: true,
4267
type: 'object',
4268
default: defaults.allowedCharacters,
4269
description: nls.localize('unicodeHighlight.allowedCharacters', "Defines allowed characters that are not being highlighted."),
4270
additionalProperties: {
4271
type: 'boolean'
4272
}
4273
},
4274
[unicodeHighlightConfigKeys.allowedLocales]: {
4275
restricted: true,
4276
type: 'object',
4277
additionalProperties: {
4278
type: 'boolean'
4279
},
4280
default: defaults.allowedLocales,
4281
description: nls.localize('unicodeHighlight.allowedLocales', "Unicode characters that are common in allowed locales are not being highlighted.")
4282
},
4283
}
4284
);
4285
}
4286
4287
public override applyUpdate(value: Required<Readonly<IUnicodeHighlightOptions>> | undefined, update: Required<Readonly<IUnicodeHighlightOptions>>): ApplyUpdateResult<Required<Readonly<IUnicodeHighlightOptions>>> {
4288
let didChange = false;
4289
if (update.allowedCharacters && value) {
4290
// Treat allowedCharacters atomically
4291
if (!objects.equals(value.allowedCharacters, update.allowedCharacters)) {
4292
value = { ...value, allowedCharacters: update.allowedCharacters };
4293
didChange = true;
4294
}
4295
}
4296
if (update.allowedLocales && value) {
4297
// Treat allowedLocales atomically
4298
if (!objects.equals(value.allowedLocales, update.allowedLocales)) {
4299
value = { ...value, allowedLocales: update.allowedLocales };
4300
didChange = true;
4301
}
4302
}
4303
4304
const result = super.applyUpdate(value, update);
4305
if (didChange) {
4306
return new ApplyUpdateResult(result.newValue, true);
4307
}
4308
return result;
4309
}
4310
4311
public validate(_input: any): InternalUnicodeHighlightOptions {
4312
if (!_input || typeof _input !== 'object') {
4313
return this.defaultValue;
4314
}
4315
const input = _input as IUnicodeHighlightOptions;
4316
return {
4317
nonBasicASCII: primitiveSet<boolean | InUntrustedWorkspace>(input.nonBasicASCII, inUntrustedWorkspace, [true, false, inUntrustedWorkspace]),
4318
invisibleCharacters: boolean(input.invisibleCharacters, this.defaultValue.invisibleCharacters),
4319
ambiguousCharacters: boolean(input.ambiguousCharacters, this.defaultValue.ambiguousCharacters),
4320
includeComments: primitiveSet<boolean | InUntrustedWorkspace>(input.includeComments, inUntrustedWorkspace, [true, false, inUntrustedWorkspace]),
4321
includeStrings: primitiveSet<boolean | InUntrustedWorkspace>(input.includeStrings, inUntrustedWorkspace, [true, false, inUntrustedWorkspace]),
4322
allowedCharacters: this.validateBooleanMap(_input.allowedCharacters, this.defaultValue.allowedCharacters),
4323
allowedLocales: this.validateBooleanMap(_input.allowedLocales, this.defaultValue.allowedLocales),
4324
};
4325
}
4326
4327
private validateBooleanMap(map: unknown, defaultValue: Record<string, true>): Record<string, true> {
4328
if ((typeof map !== 'object') || !map) {
4329
return defaultValue;
4330
}
4331
const result: Record<string, true> = {};
4332
for (const [key, value] of Object.entries(map)) {
4333
if (value === true) {
4334
result[key] = true;
4335
}
4336
}
4337
return result;
4338
}
4339
}
4340
4341
//#endregion
4342
4343
//#region inlineSuggest
4344
4345
export interface IInlineSuggestOptions {
4346
/**
4347
* Enable or disable the rendering of automatic inline completions.
4348
*/
4349
enabled?: boolean;
4350
4351
/**
4352
* Configures the mode.
4353
* Use `prefix` to only show ghost text if the text to replace is a prefix of the suggestion text.
4354
* Use `subword` to only show ghost text if the replace text is a subword of the suggestion text.
4355
* 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.
4356
* Defaults to `prefix`.
4357
*/
4358
mode?: 'prefix' | 'subword' | 'subwordSmart';
4359
4360
showToolbar?: 'always' | 'onHover' | 'never';
4361
4362
syntaxHighlightingEnabled?: boolean;
4363
4364
suppressSuggestions?: boolean;
4365
4366
minShowDelay?: number;
4367
4368
/**
4369
* Does not clear active inline suggestions when the editor loses focus.
4370
*/
4371
keepOnBlur?: boolean;
4372
4373
/**
4374
* Font family for inline suggestions.
4375
*/
4376
fontFamily?: string | 'default';
4377
4378
edits?: {
4379
allowCodeShifting?: 'always' | 'horizontal' | 'never';
4380
4381
renderSideBySide?: 'never' | 'auto';
4382
4383
showCollapsed?: boolean;
4384
4385
/**
4386
* @internal
4387
*/
4388
enabled?: boolean;
4389
};
4390
4391
/**
4392
* @internal
4393
*/
4394
triggerCommandOnProviderChange?: boolean;
4395
4396
/**
4397
* @internal
4398
*/
4399
experimental?: {
4400
/**
4401
* @internal
4402
*/
4403
suppressInlineSuggestions?: string;
4404
4405
showOnSuggestConflict?: 'always' | 'never' | 'whenSuggestListIsIncomplete';
4406
};
4407
}
4408
4409
type RequiredRecursive<T> = {
4410
[P in keyof T]-?: T[P] extends object | undefined ? RequiredRecursive<T[P]> : T[P];
4411
};
4412
4413
/**
4414
* @internal
4415
*/
4416
export type InternalInlineSuggestOptions = Readonly<RequiredRecursive<IInlineSuggestOptions>>;
4417
4418
/**
4419
* Configuration options for inline suggestions
4420
*/
4421
class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, IInlineSuggestOptions, InternalInlineSuggestOptions> {
4422
constructor() {
4423
const defaults: InternalInlineSuggestOptions = {
4424
enabled: true,
4425
mode: 'subwordSmart',
4426
showToolbar: 'onHover',
4427
suppressSuggestions: false,
4428
keepOnBlur: false,
4429
fontFamily: 'default',
4430
syntaxHighlightingEnabled: true,
4431
minShowDelay: 0,
4432
edits: {
4433
enabled: true,
4434
showCollapsed: false,
4435
renderSideBySide: 'auto',
4436
allowCodeShifting: 'always',
4437
},
4438
triggerCommandOnProviderChange: false,
4439
experimental: {
4440
suppressInlineSuggestions: '',
4441
showOnSuggestConflict: 'never',
4442
},
4443
};
4444
4445
super(
4446
EditorOption.inlineSuggest, 'inlineSuggest', defaults,
4447
{
4448
'editor.inlineSuggest.enabled': {
4449
type: 'boolean',
4450
default: defaults.enabled,
4451
description: nls.localize('inlineSuggest.enabled', "Controls whether to automatically show inline suggestions in the editor.")
4452
},
4453
'editor.inlineSuggest.showToolbar': {
4454
type: 'string',
4455
default: defaults.showToolbar,
4456
enum: ['always', 'onHover', 'never'],
4457
enumDescriptions: [
4458
nls.localize('inlineSuggest.showToolbar.always', "Show the inline suggestion toolbar whenever an inline suggestion is shown."),
4459
nls.localize('inlineSuggest.showToolbar.onHover', "Show the inline suggestion toolbar when hovering over an inline suggestion."),
4460
nls.localize('inlineSuggest.showToolbar.never', "Never show the inline suggestion toolbar."),
4461
],
4462
description: nls.localize('inlineSuggest.showToolbar', "Controls when to show the inline suggestion toolbar."),
4463
},
4464
'editor.inlineSuggest.syntaxHighlightingEnabled': {
4465
type: 'boolean',
4466
default: defaults.syntaxHighlightingEnabled,
4467
description: nls.localize('inlineSuggest.syntaxHighlightingEnabled', "Controls whether to show syntax highlighting for inline suggestions in the editor."),
4468
},
4469
'editor.inlineSuggest.suppressSuggestions': {
4470
type: 'boolean',
4471
default: defaults.suppressSuggestions,
4472
description: nls.localize('inlineSuggest.suppressSuggestions', "Controls how inline suggestions interact with the suggest widget. If enabled, the suggest widget is not shown automatically when inline suggestions are available.")
4473
},
4474
'editor.inlineSuggest.minShowDelay': {
4475
type: 'number',
4476
default: 0,
4477
minimum: 0,
4478
maximum: 10000,
4479
description: nls.localize('inlineSuggest.minShowDelay', "Controls the minimal delay in milliseconds after which inline suggestions are shown after typing."),
4480
},
4481
'editor.inlineSuggest.experimental.suppressInlineSuggestions': {
4482
type: 'string',
4483
default: defaults.experimental.suppressInlineSuggestions,
4484
tags: ['experimental'],
4485
description: nls.localize('inlineSuggest.suppressInlineSuggestions', "Suppresses inline completions for specified extension IDs -- comma separated."),
4486
experiment: {
4487
mode: 'auto'
4488
}
4489
},
4490
'editor.inlineSuggest.triggerCommandOnProviderChange': {
4491
type: 'boolean',
4492
default: defaults.triggerCommandOnProviderChange,
4493
tags: ['experimental'],
4494
description: nls.localize('inlineSuggest.triggerCommandOnProviderChange', "Controls whether to trigger a command when the inline suggestion provider changes."),
4495
experiment: {
4496
mode: 'auto'
4497
}
4498
},
4499
'editor.inlineSuggest.experimental.showOnSuggestConflict': {
4500
type: 'string',
4501
default: defaults.experimental.showOnSuggestConflict,
4502
tags: ['experimental'],
4503
enum: ['always', 'never', 'whenSuggestListIsIncomplete'],
4504
description: nls.localize('inlineSuggest.showOnSuggestConflict', "Controls whether to show inline suggestions when there is a suggest conflict."),
4505
experiment: {
4506
mode: 'auto'
4507
}
4508
},
4509
'editor.inlineSuggest.fontFamily': {
4510
type: 'string',
4511
default: defaults.fontFamily,
4512
description: nls.localize('inlineSuggest.fontFamily', "Controls the font family of the inline suggestions.")
4513
},
4514
'editor.inlineSuggest.edits.allowCodeShifting': {
4515
type: 'string',
4516
default: defaults.edits.allowCodeShifting,
4517
description: nls.localize('inlineSuggest.edits.allowCodeShifting', "Controls whether showing a suggestion will shift the code to make space for the suggestion inline."),
4518
enum: ['always', 'horizontal', 'never'],
4519
tags: ['nextEditSuggestions']
4520
},
4521
'editor.inlineSuggest.edits.renderSideBySide': {
4522
type: 'string',
4523
default: defaults.edits.renderSideBySide,
4524
description: nls.localize('inlineSuggest.edits.renderSideBySide', "Controls whether larger suggestions can be shown side by side."),
4525
enum: ['auto', 'never'],
4526
enumDescriptions: [
4527
nls.localize('editor.inlineSuggest.edits.renderSideBySide.auto', "Larger suggestions will show side by side if there is enough space, otherwise they will be shown below."),
4528
nls.localize('editor.inlineSuggest.edits.renderSideBySide.never', "Larger suggestions are never shown side by side and will always be shown below."),
4529
],
4530
tags: ['nextEditSuggestions']
4531
},
4532
'editor.inlineSuggest.edits.showCollapsed': {
4533
type: 'boolean',
4534
default: defaults.edits.showCollapsed,
4535
description: nls.localize('inlineSuggest.edits.showCollapsed', "Controls whether the suggestion will show as collapsed until jumping to it."),
4536
tags: ['nextEditSuggestions']
4537
},
4538
}
4539
);
4540
}
4541
4542
public validate(_input: any): InternalInlineSuggestOptions {
4543
if (!_input || typeof _input !== 'object') {
4544
return this.defaultValue;
4545
}
4546
const input = _input as IInlineSuggestOptions;
4547
return {
4548
enabled: boolean(input.enabled, this.defaultValue.enabled),
4549
mode: stringSet(input.mode, this.defaultValue.mode, ['prefix', 'subword', 'subwordSmart']),
4550
showToolbar: stringSet(input.showToolbar, this.defaultValue.showToolbar, ['always', 'onHover', 'never']),
4551
suppressSuggestions: boolean(input.suppressSuggestions, this.defaultValue.suppressSuggestions),
4552
keepOnBlur: boolean(input.keepOnBlur, this.defaultValue.keepOnBlur),
4553
fontFamily: EditorStringOption.string(input.fontFamily, this.defaultValue.fontFamily),
4554
syntaxHighlightingEnabled: boolean(input.syntaxHighlightingEnabled, this.defaultValue.syntaxHighlightingEnabled),
4555
minShowDelay: EditorIntOption.clampedInt(input.minShowDelay, 0, 0, 10000),
4556
edits: {
4557
enabled: boolean(input.edits?.enabled, this.defaultValue.edits.enabled),
4558
showCollapsed: boolean(input.edits?.showCollapsed, this.defaultValue.edits.showCollapsed),
4559
allowCodeShifting: stringSet(input.edits?.allowCodeShifting, this.defaultValue.edits.allowCodeShifting, ['always', 'horizontal', 'never']),
4560
renderSideBySide: stringSet(input.edits?.renderSideBySide, this.defaultValue.edits.renderSideBySide, ['never', 'auto']),
4561
},
4562
triggerCommandOnProviderChange: boolean(input.triggerCommandOnProviderChange, this.defaultValue.triggerCommandOnProviderChange),
4563
experimental: {
4564
suppressInlineSuggestions: EditorStringOption.string(input.experimental?.suppressInlineSuggestions, this.defaultValue.experimental.suppressInlineSuggestions),
4565
showOnSuggestConflict: stringSet(input.experimental?.showOnSuggestConflict, this.defaultValue.experimental.showOnSuggestConflict, ['always', 'never', 'whenSuggestListIsIncomplete']),
4566
},
4567
};
4568
}
4569
}
4570
4571
//#endregion
4572
4573
//#region bracketPairColorization
4574
4575
export interface IBracketPairColorizationOptions {
4576
/**
4577
* Enable or disable bracket pair colorization.
4578
*/
4579
enabled?: boolean;
4580
4581
/**
4582
* Use independent color pool per bracket type.
4583
*/
4584
independentColorPoolPerBracketType?: boolean;
4585
}
4586
4587
/**
4588
* @internal
4589
*/
4590
export type InternalBracketPairColorizationOptions = Readonly<Required<IBracketPairColorizationOptions>>;
4591
4592
/**
4593
* Configuration options for inline suggestions
4594
*/
4595
class BracketPairColorization extends BaseEditorOption<EditorOption.bracketPairColorization, IBracketPairColorizationOptions, InternalBracketPairColorizationOptions> {
4596
constructor() {
4597
const defaults: InternalBracketPairColorizationOptions = {
4598
enabled: EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions.enabled,
4599
independentColorPoolPerBracketType: EDITOR_MODEL_DEFAULTS.bracketPairColorizationOptions.independentColorPoolPerBracketType,
4600
};
4601
4602
super(
4603
EditorOption.bracketPairColorization, 'bracketPairColorization', defaults,
4604
{
4605
'editor.bracketPairColorization.enabled': {
4606
type: 'boolean',
4607
default: defaults.enabled,
4608
markdownDescription: nls.localize('bracketPairColorization.enabled', "Controls whether bracket pair colorization is enabled or not. Use {0} to override the bracket highlight colors.", '`#workbench.colorCustomizations#`')
4609
},
4610
'editor.bracketPairColorization.independentColorPoolPerBracketType': {
4611
type: 'boolean',
4612
default: defaults.independentColorPoolPerBracketType,
4613
description: nls.localize('bracketPairColorization.independentColorPoolPerBracketType', "Controls whether each bracket type has its own independent color pool.")
4614
},
4615
}
4616
);
4617
}
4618
4619
public validate(_input: any): InternalBracketPairColorizationOptions {
4620
if (!_input || typeof _input !== 'object') {
4621
return this.defaultValue;
4622
}
4623
const input = _input as IBracketPairColorizationOptions;
4624
return {
4625
enabled: boolean(input.enabled, this.defaultValue.enabled),
4626
independentColorPoolPerBracketType: boolean(input.independentColorPoolPerBracketType, this.defaultValue.independentColorPoolPerBracketType),
4627
};
4628
}
4629
}
4630
4631
//#endregion
4632
4633
//#region guides
4634
4635
export interface IGuidesOptions {
4636
/**
4637
* Enable rendering of bracket pair guides.
4638
* Defaults to false.
4639
*/
4640
bracketPairs?: boolean | 'active';
4641
4642
/**
4643
* Enable rendering of vertical bracket pair guides.
4644
* Defaults to 'active'.
4645
*/
4646
bracketPairsHorizontal?: boolean | 'active';
4647
4648
/**
4649
* Enable highlighting of the active bracket pair.
4650
* Defaults to true.
4651
*/
4652
highlightActiveBracketPair?: boolean;
4653
4654
/**
4655
* Enable rendering of indent guides.
4656
* Defaults to true.
4657
*/
4658
indentation?: boolean;
4659
4660
/**
4661
* Enable highlighting of the active indent guide.
4662
* Defaults to true.
4663
*/
4664
highlightActiveIndentation?: boolean | 'always';
4665
}
4666
4667
/**
4668
* @internal
4669
*/
4670
export type InternalGuidesOptions = Readonly<Required<IGuidesOptions>>;
4671
4672
/**
4673
* Configuration options for inline suggestions
4674
*/
4675
class GuideOptions extends BaseEditorOption<EditorOption.guides, IGuidesOptions, InternalGuidesOptions> {
4676
constructor() {
4677
const defaults: InternalGuidesOptions = {
4678
bracketPairs: false,
4679
bracketPairsHorizontal: 'active',
4680
highlightActiveBracketPair: true,
4681
4682
indentation: true,
4683
highlightActiveIndentation: true
4684
};
4685
4686
super(
4687
EditorOption.guides, 'guides', defaults,
4688
{
4689
'editor.guides.bracketPairs': {
4690
type: ['boolean', 'string'],
4691
enum: [true, 'active', false],
4692
enumDescriptions: [
4693
nls.localize('editor.guides.bracketPairs.true', "Enables bracket pair guides."),
4694
nls.localize('editor.guides.bracketPairs.active', "Enables bracket pair guides only for the active bracket pair."),
4695
nls.localize('editor.guides.bracketPairs.false', "Disables bracket pair guides."),
4696
],
4697
default: defaults.bracketPairs,
4698
description: nls.localize('editor.guides.bracketPairs', "Controls whether bracket pair guides are enabled or not.")
4699
},
4700
'editor.guides.bracketPairsHorizontal': {
4701
type: ['boolean', 'string'],
4702
enum: [true, 'active', false],
4703
enumDescriptions: [
4704
nls.localize('editor.guides.bracketPairsHorizontal.true', "Enables horizontal guides as addition to vertical bracket pair guides."),
4705
nls.localize('editor.guides.bracketPairsHorizontal.active', "Enables horizontal guides only for the active bracket pair."),
4706
nls.localize('editor.guides.bracketPairsHorizontal.false', "Disables horizontal bracket pair guides."),
4707
],
4708
default: defaults.bracketPairsHorizontal,
4709
description: nls.localize('editor.guides.bracketPairsHorizontal', "Controls whether horizontal bracket pair guides are enabled or not.")
4710
},
4711
'editor.guides.highlightActiveBracketPair': {
4712
type: 'boolean',
4713
default: defaults.highlightActiveBracketPair,
4714
description: nls.localize('editor.guides.highlightActiveBracketPair', "Controls whether the editor should highlight the active bracket pair.")
4715
},
4716
'editor.guides.indentation': {
4717
type: 'boolean',
4718
default: defaults.indentation,
4719
description: nls.localize('editor.guides.indentation', "Controls whether the editor should render indent guides.")
4720
},
4721
'editor.guides.highlightActiveIndentation': {
4722
type: ['boolean', 'string'],
4723
enum: [true, 'always', false],
4724
enumDescriptions: [
4725
nls.localize('editor.guides.highlightActiveIndentation.true', "Highlights the active indent guide."),
4726
nls.localize('editor.guides.highlightActiveIndentation.always', "Highlights the active indent guide even if bracket guides are highlighted."),
4727
nls.localize('editor.guides.highlightActiveIndentation.false', "Do not highlight the active indent guide."),
4728
],
4729
default: defaults.highlightActiveIndentation,
4730
4731
description: nls.localize('editor.guides.highlightActiveIndentation', "Controls whether the editor should highlight the active indent guide.")
4732
}
4733
}
4734
);
4735
}
4736
4737
public validate(_input: any): InternalGuidesOptions {
4738
if (!_input || typeof _input !== 'object') {
4739
return this.defaultValue;
4740
}
4741
const input = _input as IGuidesOptions;
4742
return {
4743
bracketPairs: primitiveSet(input.bracketPairs, this.defaultValue.bracketPairs, [true, false, 'active']),
4744
bracketPairsHorizontal: primitiveSet(input.bracketPairsHorizontal, this.defaultValue.bracketPairsHorizontal, [true, false, 'active']),
4745
highlightActiveBracketPair: boolean(input.highlightActiveBracketPair, this.defaultValue.highlightActiveBracketPair),
4746
4747
indentation: boolean(input.indentation, this.defaultValue.indentation),
4748
highlightActiveIndentation: primitiveSet(input.highlightActiveIndentation, this.defaultValue.highlightActiveIndentation, [true, false, 'always']),
4749
};
4750
}
4751
}
4752
4753
function primitiveSet<T extends string | boolean>(value: unknown, defaultValue: T, allowedValues: T[]): T {
4754
const idx = allowedValues.indexOf(value as any);
4755
if (idx === -1) {
4756
return defaultValue;
4757
}
4758
return allowedValues[idx];
4759
}
4760
4761
//#endregion
4762
4763
//#region suggest
4764
4765
/**
4766
* Configuration options for editor suggest widget
4767
*/
4768
export interface ISuggestOptions {
4769
/**
4770
* Overwrite word ends on accept. Default to false.
4771
*/
4772
insertMode?: 'insert' | 'replace';
4773
/**
4774
* Enable graceful matching. Defaults to true.
4775
*/
4776
filterGraceful?: boolean;
4777
/**
4778
* Prevent quick suggestions when a snippet is active. Defaults to true.
4779
*/
4780
snippetsPreventQuickSuggestions?: boolean;
4781
/**
4782
* Favors words that appear close to the cursor.
4783
*/
4784
localityBonus?: boolean;
4785
/**
4786
* Enable using global storage for remembering suggestions.
4787
*/
4788
shareSuggestSelections?: boolean;
4789
/**
4790
* Select suggestions when triggered via quick suggest or trigger characters
4791
*/
4792
selectionMode?: 'always' | 'never' | 'whenTriggerCharacter' | 'whenQuickSuggestion';
4793
/**
4794
* Enable or disable icons in suggestions. Defaults to true.
4795
*/
4796
showIcons?: boolean;
4797
/**
4798
* Enable or disable the suggest status bar.
4799
*/
4800
showStatusBar?: boolean;
4801
/**
4802
* Enable or disable the rendering of the suggestion preview.
4803
*/
4804
preview?: boolean;
4805
/**
4806
* Configures the mode of the preview.
4807
*/
4808
previewMode?: 'prefix' | 'subword' | 'subwordSmart';
4809
/**
4810
* Show details inline with the label. Defaults to true.
4811
*/
4812
showInlineDetails?: boolean;
4813
/**
4814
* Show method-suggestions.
4815
*/
4816
showMethods?: boolean;
4817
/**
4818
* Show function-suggestions.
4819
*/
4820
showFunctions?: boolean;
4821
/**
4822
* Show constructor-suggestions.
4823
*/
4824
showConstructors?: boolean;
4825
/**
4826
* Show deprecated-suggestions.
4827
*/
4828
showDeprecated?: boolean;
4829
/**
4830
* Controls whether suggestions allow matches in the middle of the word instead of only at the beginning
4831
*/
4832
matchOnWordStartOnly?: boolean;
4833
/**
4834
* Show field-suggestions.
4835
*/
4836
showFields?: boolean;
4837
/**
4838
* Show variable-suggestions.
4839
*/
4840
showVariables?: boolean;
4841
/**
4842
* Show class-suggestions.
4843
*/
4844
showClasses?: boolean;
4845
/**
4846
* Show struct-suggestions.
4847
*/
4848
showStructs?: boolean;
4849
/**
4850
* Show interface-suggestions.
4851
*/
4852
showInterfaces?: boolean;
4853
/**
4854
* Show module-suggestions.
4855
*/
4856
showModules?: boolean;
4857
/**
4858
* Show property-suggestions.
4859
*/
4860
showProperties?: boolean;
4861
/**
4862
* Show event-suggestions.
4863
*/
4864
showEvents?: boolean;
4865
/**
4866
* Show operator-suggestions.
4867
*/
4868
showOperators?: boolean;
4869
/**
4870
* Show unit-suggestions.
4871
*/
4872
showUnits?: boolean;
4873
/**
4874
* Show value-suggestions.
4875
*/
4876
showValues?: boolean;
4877
/**
4878
* Show constant-suggestions.
4879
*/
4880
showConstants?: boolean;
4881
/**
4882
* Show enum-suggestions.
4883
*/
4884
showEnums?: boolean;
4885
/**
4886
* Show enumMember-suggestions.
4887
*/
4888
showEnumMembers?: boolean;
4889
/**
4890
* Show keyword-suggestions.
4891
*/
4892
showKeywords?: boolean;
4893
/**
4894
* Show text-suggestions.
4895
*/
4896
showWords?: boolean;
4897
/**
4898
* Show color-suggestions.
4899
*/
4900
showColors?: boolean;
4901
/**
4902
* Show file-suggestions.
4903
*/
4904
showFiles?: boolean;
4905
/**
4906
* Show reference-suggestions.
4907
*/
4908
showReferences?: boolean;
4909
/**
4910
* Show folder-suggestions.
4911
*/
4912
showFolders?: boolean;
4913
/**
4914
* Show typeParameter-suggestions.
4915
*/
4916
showTypeParameters?: boolean;
4917
/**
4918
* Show issue-suggestions.
4919
*/
4920
showIssues?: boolean;
4921
/**
4922
* Show user-suggestions.
4923
*/
4924
showUsers?: boolean;
4925
/**
4926
* Show snippet-suggestions.
4927
*/
4928
showSnippets?: boolean;
4929
}
4930
4931
/**
4932
* @internal
4933
*/
4934
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
4935
4936
class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptions, InternalSuggestOptions> {
4937
4938
constructor() {
4939
const defaults: InternalSuggestOptions = {
4940
insertMode: 'insert',
4941
filterGraceful: true,
4942
snippetsPreventQuickSuggestions: false,
4943
localityBonus: false,
4944
shareSuggestSelections: false,
4945
selectionMode: 'always',
4946
showIcons: true,
4947
showStatusBar: false,
4948
preview: false,
4949
previewMode: 'subwordSmart',
4950
showInlineDetails: true,
4951
showMethods: true,
4952
showFunctions: true,
4953
showConstructors: true,
4954
showDeprecated: true,
4955
matchOnWordStartOnly: true,
4956
showFields: true,
4957
showVariables: true,
4958
showClasses: true,
4959
showStructs: true,
4960
showInterfaces: true,
4961
showModules: true,
4962
showProperties: true,
4963
showEvents: true,
4964
showOperators: true,
4965
showUnits: true,
4966
showValues: true,
4967
showConstants: true,
4968
showEnums: true,
4969
showEnumMembers: true,
4970
showKeywords: true,
4971
showWords: true,
4972
showColors: true,
4973
showFiles: true,
4974
showReferences: true,
4975
showFolders: true,
4976
showTypeParameters: true,
4977
showSnippets: true,
4978
showUsers: true,
4979
showIssues: true,
4980
};
4981
super(
4982
EditorOption.suggest, 'suggest', defaults,
4983
{
4984
'editor.suggest.insertMode': {
4985
type: 'string',
4986
enum: ['insert', 'replace'],
4987
enumDescriptions: [
4988
nls.localize('suggest.insertMode.insert', "Insert suggestion without overwriting text right of the cursor."),
4989
nls.localize('suggest.insertMode.replace', "Insert suggestion and overwrite text right of the cursor."),
4990
],
4991
default: defaults.insertMode,
4992
description: nls.localize('suggest.insertMode', "Controls whether words are overwritten when accepting completions. Note that this depends on extensions opting into this feature.")
4993
},
4994
'editor.suggest.filterGraceful': {
4995
type: 'boolean',
4996
default: defaults.filterGraceful,
4997
description: nls.localize('suggest.filterGraceful', "Controls whether filtering and sorting suggestions accounts for small typos.")
4998
},
4999
'editor.suggest.localityBonus': {
5000
type: 'boolean',
5001
default: defaults.localityBonus,
5002
description: nls.localize('suggest.localityBonus', "Controls whether sorting favors words that appear close to the cursor.")
5003
},
5004
'editor.suggest.shareSuggestSelections': {
5005
type: 'boolean',
5006
default: defaults.shareSuggestSelections,
5007
markdownDescription: nls.localize('suggest.shareSuggestSelections', "Controls whether remembered suggestion selections are shared between multiple workspaces and windows (needs `#editor.suggestSelection#`).")
5008
},
5009
'editor.suggest.selectionMode': {
5010
type: 'string',
5011
enum: ['always', 'never', 'whenTriggerCharacter', 'whenQuickSuggestion'],
5012
enumDescriptions: [
5013
nls.localize('suggest.insertMode.always', "Always select a suggestion when automatically triggering IntelliSense."),
5014
nls.localize('suggest.insertMode.never', "Never select a suggestion when automatically triggering IntelliSense."),
5015
nls.localize('suggest.insertMode.whenTriggerCharacter', "Select a suggestion only when triggering IntelliSense from a trigger character."),
5016
nls.localize('suggest.insertMode.whenQuickSuggestion', "Select a suggestion only when triggering IntelliSense as you type."),
5017
],
5018
default: defaults.selectionMode,
5019
markdownDescription: nls.localize('suggest.selectionMode', "Controls whether a suggestion is selected when the widget shows. Note that this only applies to automatically triggered suggestions ({0} and {1}) and that a suggestion is always selected when explicitly invoked, e.g via `Ctrl+Space`.", '`#editor.quickSuggestions#`', '`#editor.suggestOnTriggerCharacters#`')
5020
},
5021
'editor.suggest.snippetsPreventQuickSuggestions': {
5022
type: 'boolean',
5023
default: defaults.snippetsPreventQuickSuggestions,
5024
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
5025
},
5026
'editor.suggest.showIcons': {
5027
type: 'boolean',
5028
default: defaults.showIcons,
5029
description: nls.localize('suggest.showIcons', "Controls whether to show or hide icons in suggestions.")
5030
},
5031
'editor.suggest.showStatusBar': {
5032
type: 'boolean',
5033
default: defaults.showStatusBar,
5034
description: nls.localize('suggest.showStatusBar', "Controls the visibility of the status bar at the bottom of the suggest widget.")
5035
},
5036
'editor.suggest.preview': {
5037
type: 'boolean',
5038
default: defaults.preview,
5039
description: nls.localize('suggest.preview', "Controls whether to preview the suggestion outcome in the editor.")
5040
},
5041
'editor.suggest.showInlineDetails': {
5042
type: 'boolean',
5043
default: defaults.showInlineDetails,
5044
description: nls.localize('suggest.showInlineDetails', "Controls whether suggest details show inline with the label or only in the details widget.")
5045
},
5046
'editor.suggest.maxVisibleSuggestions': {
5047
type: 'number',
5048
deprecationMessage: nls.localize('suggest.maxVisibleSuggestions.dep', "This setting is deprecated. The suggest widget can now be resized."),
5049
},
5050
'editor.suggest.filteredTypes': {
5051
type: 'object',
5052
deprecationMessage: nls.localize('deprecated', "This setting is deprecated, please use separate settings like 'editor.suggest.showKeywords' or 'editor.suggest.showSnippets' instead.")
5053
},
5054
'editor.suggest.showMethods': {
5055
type: 'boolean',
5056
default: true,
5057
markdownDescription: nls.localize('editor.suggest.showMethods', "When enabled IntelliSense shows `method`-suggestions.")
5058
},
5059
'editor.suggest.showFunctions': {
5060
type: 'boolean',
5061
default: true,
5062
markdownDescription: nls.localize('editor.suggest.showFunctions', "When enabled IntelliSense shows `function`-suggestions.")
5063
},
5064
'editor.suggest.showConstructors': {
5065
type: 'boolean',
5066
default: true,
5067
markdownDescription: nls.localize('editor.suggest.showConstructors', "When enabled IntelliSense shows `constructor`-suggestions.")
5068
},
5069
'editor.suggest.showDeprecated': {
5070
type: 'boolean',
5071
default: true,
5072
markdownDescription: nls.localize('editor.suggest.showDeprecated', "When enabled IntelliSense shows `deprecated`-suggestions.")
5073
},
5074
'editor.suggest.matchOnWordStartOnly': {
5075
type: 'boolean',
5076
default: true,
5077
markdownDescription: nls.localize('editor.suggest.matchOnWordStartOnly', "When enabled IntelliSense filtering requires that the first character matches on a word start. For example, `c` on `Console` or `WebContext` but _not_ on `description`. When disabled IntelliSense will show more results but still sorts them by match quality.")
5078
},
5079
'editor.suggest.showFields': {
5080
type: 'boolean',
5081
default: true,
5082
markdownDescription: nls.localize('editor.suggest.showFields', "When enabled IntelliSense shows `field`-suggestions.")
5083
},
5084
'editor.suggest.showVariables': {
5085
type: 'boolean',
5086
default: true,
5087
markdownDescription: nls.localize('editor.suggest.showVariables', "When enabled IntelliSense shows `variable`-suggestions.")
5088
},
5089
'editor.suggest.showClasses': {
5090
type: 'boolean',
5091
default: true,
5092
markdownDescription: nls.localize('editor.suggest.showClasss', "When enabled IntelliSense shows `class`-suggestions.")
5093
},
5094
'editor.suggest.showStructs': {
5095
type: 'boolean',
5096
default: true,
5097
markdownDescription: nls.localize('editor.suggest.showStructs', "When enabled IntelliSense shows `struct`-suggestions.")
5098
},
5099
'editor.suggest.showInterfaces': {
5100
type: 'boolean',
5101
default: true,
5102
markdownDescription: nls.localize('editor.suggest.showInterfaces', "When enabled IntelliSense shows `interface`-suggestions.")
5103
},
5104
'editor.suggest.showModules': {
5105
type: 'boolean',
5106
default: true,
5107
markdownDescription: nls.localize('editor.suggest.showModules', "When enabled IntelliSense shows `module`-suggestions.")
5108
},
5109
'editor.suggest.showProperties': {
5110
type: 'boolean',
5111
default: true,
5112
markdownDescription: nls.localize('editor.suggest.showPropertys', "When enabled IntelliSense shows `property`-suggestions.")
5113
},
5114
'editor.suggest.showEvents': {
5115
type: 'boolean',
5116
default: true,
5117
markdownDescription: nls.localize('editor.suggest.showEvents', "When enabled IntelliSense shows `event`-suggestions.")
5118
},
5119
'editor.suggest.showOperators': {
5120
type: 'boolean',
5121
default: true,
5122
markdownDescription: nls.localize('editor.suggest.showOperators', "When enabled IntelliSense shows `operator`-suggestions.")
5123
},
5124
'editor.suggest.showUnits': {
5125
type: 'boolean',
5126
default: true,
5127
markdownDescription: nls.localize('editor.suggest.showUnits', "When enabled IntelliSense shows `unit`-suggestions.")
5128
},
5129
'editor.suggest.showValues': {
5130
type: 'boolean',
5131
default: true,
5132
markdownDescription: nls.localize('editor.suggest.showValues', "When enabled IntelliSense shows `value`-suggestions.")
5133
},
5134
'editor.suggest.showConstants': {
5135
type: 'boolean',
5136
default: true,
5137
markdownDescription: nls.localize('editor.suggest.showConstants', "When enabled IntelliSense shows `constant`-suggestions.")
5138
},
5139
'editor.suggest.showEnums': {
5140
type: 'boolean',
5141
default: true,
5142
markdownDescription: nls.localize('editor.suggest.showEnums', "When enabled IntelliSense shows `enum`-suggestions.")
5143
},
5144
'editor.suggest.showEnumMembers': {
5145
type: 'boolean',
5146
default: true,
5147
markdownDescription: nls.localize('editor.suggest.showEnumMembers', "When enabled IntelliSense shows `enumMember`-suggestions.")
5148
},
5149
'editor.suggest.showKeywords': {
5150
type: 'boolean',
5151
default: true,
5152
markdownDescription: nls.localize('editor.suggest.showKeywords', "When enabled IntelliSense shows `keyword`-suggestions.")
5153
},
5154
'editor.suggest.showWords': {
5155
type: 'boolean',
5156
default: true,
5157
markdownDescription: nls.localize('editor.suggest.showTexts', "When enabled IntelliSense shows `text`-suggestions.")
5158
},
5159
'editor.suggest.showColors': {
5160
type: 'boolean',
5161
default: true,
5162
markdownDescription: nls.localize('editor.suggest.showColors', "When enabled IntelliSense shows `color`-suggestions.")
5163
},
5164
'editor.suggest.showFiles': {
5165
type: 'boolean',
5166
default: true,
5167
markdownDescription: nls.localize('editor.suggest.showFiles', "When enabled IntelliSense shows `file`-suggestions.")
5168
},
5169
'editor.suggest.showReferences': {
5170
type: 'boolean',
5171
default: true,
5172
markdownDescription: nls.localize('editor.suggest.showReferences', "When enabled IntelliSense shows `reference`-suggestions.")
5173
},
5174
'editor.suggest.showCustomcolors': {
5175
type: 'boolean',
5176
default: true,
5177
markdownDescription: nls.localize('editor.suggest.showCustomcolors', "When enabled IntelliSense shows `customcolor`-suggestions.")
5178
},
5179
'editor.suggest.showFolders': {
5180
type: 'boolean',
5181
default: true,
5182
markdownDescription: nls.localize('editor.suggest.showFolders', "When enabled IntelliSense shows `folder`-suggestions.")
5183
},
5184
'editor.suggest.showTypeParameters': {
5185
type: 'boolean',
5186
default: true,
5187
markdownDescription: nls.localize('editor.suggest.showTypeParameters', "When enabled IntelliSense shows `typeParameter`-suggestions.")
5188
},
5189
'editor.suggest.showSnippets': {
5190
type: 'boolean',
5191
default: true,
5192
markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
5193
},
5194
'editor.suggest.showUsers': {
5195
type: 'boolean',
5196
default: true,
5197
markdownDescription: nls.localize('editor.suggest.showUsers', "When enabled IntelliSense shows `user`-suggestions.")
5198
},
5199
'editor.suggest.showIssues': {
5200
type: 'boolean',
5201
default: true,
5202
markdownDescription: nls.localize('editor.suggest.showIssues', "When enabled IntelliSense shows `issues`-suggestions.")
5203
}
5204
}
5205
);
5206
}
5207
5208
public validate(_input: any): InternalSuggestOptions {
5209
if (!_input || typeof _input !== 'object') {
5210
return this.defaultValue;
5211
}
5212
const input = _input as ISuggestOptions;
5213
return {
5214
insertMode: stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
5215
filterGraceful: boolean(input.filterGraceful, this.defaultValue.filterGraceful),
5216
snippetsPreventQuickSuggestions: boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
5217
localityBonus: boolean(input.localityBonus, this.defaultValue.localityBonus),
5218
shareSuggestSelections: boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
5219
selectionMode: stringSet(input.selectionMode, this.defaultValue.selectionMode, ['always', 'never', 'whenQuickSuggestion', 'whenTriggerCharacter']),
5220
showIcons: boolean(input.showIcons, this.defaultValue.showIcons),
5221
showStatusBar: boolean(input.showStatusBar, this.defaultValue.showStatusBar),
5222
preview: boolean(input.preview, this.defaultValue.preview),
5223
previewMode: stringSet(input.previewMode, this.defaultValue.previewMode, ['prefix', 'subword', 'subwordSmart']),
5224
showInlineDetails: boolean(input.showInlineDetails, this.defaultValue.showInlineDetails),
5225
showMethods: boolean(input.showMethods, this.defaultValue.showMethods),
5226
showFunctions: boolean(input.showFunctions, this.defaultValue.showFunctions),
5227
showConstructors: boolean(input.showConstructors, this.defaultValue.showConstructors),
5228
showDeprecated: boolean(input.showDeprecated, this.defaultValue.showDeprecated),
5229
matchOnWordStartOnly: boolean(input.matchOnWordStartOnly, this.defaultValue.matchOnWordStartOnly),
5230
showFields: boolean(input.showFields, this.defaultValue.showFields),
5231
showVariables: boolean(input.showVariables, this.defaultValue.showVariables),
5232
showClasses: boolean(input.showClasses, this.defaultValue.showClasses),
5233
showStructs: boolean(input.showStructs, this.defaultValue.showStructs),
5234
showInterfaces: boolean(input.showInterfaces, this.defaultValue.showInterfaces),
5235
showModules: boolean(input.showModules, this.defaultValue.showModules),
5236
showProperties: boolean(input.showProperties, this.defaultValue.showProperties),
5237
showEvents: boolean(input.showEvents, this.defaultValue.showEvents),
5238
showOperators: boolean(input.showOperators, this.defaultValue.showOperators),
5239
showUnits: boolean(input.showUnits, this.defaultValue.showUnits),
5240
showValues: boolean(input.showValues, this.defaultValue.showValues),
5241
showConstants: boolean(input.showConstants, this.defaultValue.showConstants),
5242
showEnums: boolean(input.showEnums, this.defaultValue.showEnums),
5243
showEnumMembers: boolean(input.showEnumMembers, this.defaultValue.showEnumMembers),
5244
showKeywords: boolean(input.showKeywords, this.defaultValue.showKeywords),
5245
showWords: boolean(input.showWords, this.defaultValue.showWords),
5246
showColors: boolean(input.showColors, this.defaultValue.showColors),
5247
showFiles: boolean(input.showFiles, this.defaultValue.showFiles),
5248
showReferences: boolean(input.showReferences, this.defaultValue.showReferences),
5249
showFolders: boolean(input.showFolders, this.defaultValue.showFolders),
5250
showTypeParameters: boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
5251
showSnippets: boolean(input.showSnippets, this.defaultValue.showSnippets),
5252
showUsers: boolean(input.showUsers, this.defaultValue.showUsers),
5253
showIssues: boolean(input.showIssues, this.defaultValue.showIssues),
5254
};
5255
}
5256
}
5257
5258
//#endregion
5259
5260
//#region smart select
5261
5262
export interface ISmartSelectOptions {
5263
selectLeadingAndTrailingWhitespace?: boolean;
5264
selectSubwords?: boolean;
5265
}
5266
5267
/**
5268
* @internal
5269
*/
5270
export type SmartSelectOptions = Readonly<Required<ISmartSelectOptions>>;
5271
5272
class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, ISmartSelectOptions, SmartSelectOptions> {
5273
5274
constructor() {
5275
super(
5276
EditorOption.smartSelect, 'smartSelect',
5277
{
5278
selectLeadingAndTrailingWhitespace: true,
5279
selectSubwords: true,
5280
},
5281
{
5282
'editor.smartSelect.selectLeadingAndTrailingWhitespace': {
5283
description: nls.localize('selectLeadingAndTrailingWhitespace', "Whether leading and trailing whitespace should always be selected."),
5284
default: true,
5285
type: 'boolean'
5286
},
5287
'editor.smartSelect.selectSubwords': {
5288
description: nls.localize('selectSubwords', "Whether subwords (like 'foo' in 'fooBar' or 'foo_bar') should be selected."),
5289
default: true,
5290
type: 'boolean'
5291
}
5292
}
5293
);
5294
}
5295
5296
public validate(input: any): Readonly<Required<ISmartSelectOptions>> {
5297
if (!input || typeof input !== 'object') {
5298
return this.defaultValue;
5299
}
5300
return {
5301
selectLeadingAndTrailingWhitespace: boolean((input as ISmartSelectOptions).selectLeadingAndTrailingWhitespace, this.defaultValue.selectLeadingAndTrailingWhitespace),
5302
selectSubwords: boolean((input as ISmartSelectOptions).selectSubwords, this.defaultValue.selectSubwords),
5303
};
5304
}
5305
}
5306
5307
//#endregion
5308
5309
//#region wordSegmenterLocales
5310
5311
/**
5312
* Locales used for segmenting lines into words when doing word related navigations or operations.
5313
*
5314
* Specify the BCP 47 language tag of the word you wish to recognize (e.g., ja, zh-CN, zh-Hant-TW, etc.).
5315
*/
5316
class WordSegmenterLocales extends BaseEditorOption<EditorOption.wordSegmenterLocales, string | string[], string[]> {
5317
constructor() {
5318
const defaults: string[] = [];
5319
5320
super(
5321
EditorOption.wordSegmenterLocales, 'wordSegmenterLocales', defaults,
5322
{
5323
anyOf: [
5324
{
5325
type: 'string',
5326
}, {
5327
type: 'array',
5328
items: {
5329
type: 'string'
5330
}
5331
}
5332
],
5333
description: nls.localize('wordSegmenterLocales', "Locales to be used for word segmentation when doing word related navigations or operations. Specify the BCP 47 language tag of the word you wish to recognize (e.g., ja, zh-CN, zh-Hant-TW, etc.)."),
5334
type: 'array',
5335
items: {
5336
type: 'string',
5337
},
5338
default: defaults,
5339
},
5340
);
5341
}
5342
5343
public validate(input: any): string[] {
5344
if (typeof input === 'string') {
5345
input = [input];
5346
}
5347
if (Array.isArray(input)) {
5348
const validLocales: string[] = [];
5349
for (const locale of input) {
5350
if (typeof locale === 'string') {
5351
try {
5352
if (Intl.Segmenter.supportedLocalesOf(locale).length > 0) {
5353
validLocales.push(locale);
5354
}
5355
} catch {
5356
// ignore invalid locales
5357
}
5358
}
5359
}
5360
return validLocales;
5361
}
5362
5363
return this.defaultValue;
5364
}
5365
}
5366
5367
5368
//#endregion
5369
5370
//#region wrappingIndent
5371
5372
/**
5373
* Describes how to indent wrapped lines.
5374
*/
5375
export const enum WrappingIndent {
5376
/**
5377
* No indentation => wrapped lines begin at column 1.
5378
*/
5379
None = 0,
5380
/**
5381
* Same => wrapped lines get the same indentation as the parent.
5382
*/
5383
Same = 1,
5384
/**
5385
* Indent => wrapped lines get +1 indentation toward the parent.
5386
*/
5387
Indent = 2,
5388
/**
5389
* DeepIndent => wrapped lines get +2 indentation toward the parent.
5390
*/
5391
DeepIndent = 3
5392
}
5393
5394
class WrappingIndentOption extends BaseEditorOption<EditorOption.wrappingIndent, 'none' | 'same' | 'indent' | 'deepIndent', WrappingIndent> {
5395
5396
constructor() {
5397
super(EditorOption.wrappingIndent, 'wrappingIndent', WrappingIndent.Same,
5398
{
5399
'editor.wrappingIndent': {
5400
type: 'string',
5401
enum: ['none', 'same', 'indent', 'deepIndent'],
5402
enumDescriptions: [
5403
nls.localize('wrappingIndent.none', "No indentation. Wrapped lines begin at column 1."),
5404
nls.localize('wrappingIndent.same', "Wrapped lines get the same indentation as the parent."),
5405
nls.localize('wrappingIndent.indent', "Wrapped lines get +1 indentation toward the parent."),
5406
nls.localize('wrappingIndent.deepIndent', "Wrapped lines get +2 indentation toward the parent."),
5407
],
5408
description: nls.localize('wrappingIndent', "Controls the indentation of wrapped lines."),
5409
default: 'same'
5410
}
5411
}
5412
);
5413
}
5414
5415
public validate(input: any): WrappingIndent {
5416
switch (input) {
5417
case 'none': return WrappingIndent.None;
5418
case 'same': return WrappingIndent.Same;
5419
case 'indent': return WrappingIndent.Indent;
5420
case 'deepIndent': return WrappingIndent.DeepIndent;
5421
}
5422
return WrappingIndent.Same;
5423
}
5424
5425
public override compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, value: WrappingIndent): WrappingIndent {
5426
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
5427
if (accessibilitySupport === AccessibilitySupport.Enabled) {
5428
// if we know for a fact that a screen reader is attached, we use no indent wrapping to
5429
// help that the editor's wrapping points match the textarea's wrapping points
5430
return WrappingIndent.None;
5431
}
5432
return value;
5433
}
5434
}
5435
5436
//#endregion
5437
5438
//#region wrappingInfo
5439
5440
export interface EditorWrappingInfo {
5441
readonly isDominatedByLongLines: boolean;
5442
readonly isWordWrapMinified: boolean;
5443
readonly isViewportWrapping: boolean;
5444
readonly wrappingColumn: number;
5445
}
5446
5447
class EditorWrappingInfoComputer extends ComputedEditorOption<EditorOption.wrappingInfo, EditorWrappingInfo> {
5448
5449
constructor() {
5450
super(EditorOption.wrappingInfo);
5451
}
5452
5453
public compute(env: IEnvironmentalOptions, options: IComputedEditorOptions, _: EditorWrappingInfo): EditorWrappingInfo {
5454
const layoutInfo = options.get(EditorOption.layoutInfo);
5455
5456
return {
5457
isDominatedByLongLines: env.isDominatedByLongLines,
5458
isWordWrapMinified: layoutInfo.isWordWrapMinified,
5459
isViewportWrapping: layoutInfo.isViewportWrapping,
5460
wrappingColumn: layoutInfo.wrappingColumn,
5461
};
5462
}
5463
}
5464
5465
//#endregion
5466
5467
//#region dropIntoEditor
5468
5469
/**
5470
* Configuration options for editor drop into behavior
5471
*/
5472
export interface IDropIntoEditorOptions {
5473
/**
5474
* Enable dropping into editor.
5475
* Defaults to true.
5476
*/
5477
enabled?: boolean;
5478
5479
/**
5480
* Controls if a widget is shown after a drop.
5481
* Defaults to 'afterDrop'.
5482
*/
5483
showDropSelector?: 'afterDrop' | 'never';
5484
}
5485
5486
/**
5487
* @internal
5488
*/
5489
export type EditorDropIntoEditorOptions = Readonly<Required<IDropIntoEditorOptions>>;
5490
5491
class EditorDropIntoEditor extends BaseEditorOption<EditorOption.dropIntoEditor, IDropIntoEditorOptions, EditorDropIntoEditorOptions> {
5492
5493
constructor() {
5494
const defaults: EditorDropIntoEditorOptions = { enabled: true, showDropSelector: 'afterDrop' };
5495
super(
5496
EditorOption.dropIntoEditor, 'dropIntoEditor', defaults,
5497
{
5498
'editor.dropIntoEditor.enabled': {
5499
type: 'boolean',
5500
default: defaults.enabled,
5501
markdownDescription: nls.localize('dropIntoEditor.enabled', "Controls whether you can drag and drop a file into a text editor by holding down the `Shift` key (instead of opening the file in an editor)."),
5502
},
5503
'editor.dropIntoEditor.showDropSelector': {
5504
type: 'string',
5505
markdownDescription: nls.localize('dropIntoEditor.showDropSelector', "Controls if a widget is shown when dropping files into the editor. This widget lets you control how the file is dropped."),
5506
enum: [
5507
'afterDrop',
5508
'never'
5509
],
5510
enumDescriptions: [
5511
nls.localize('dropIntoEditor.showDropSelector.afterDrop', "Show the drop selector widget after a file is dropped into the editor."),
5512
nls.localize('dropIntoEditor.showDropSelector.never', "Never show the drop selector widget. Instead the default drop provider is always used."),
5513
],
5514
default: 'afterDrop',
5515
},
5516
}
5517
);
5518
}
5519
5520
public validate(_input: any): EditorDropIntoEditorOptions {
5521
if (!_input || typeof _input !== 'object') {
5522
return this.defaultValue;
5523
}
5524
const input = _input as IDropIntoEditorOptions;
5525
return {
5526
enabled: boolean(input.enabled, this.defaultValue.enabled),
5527
showDropSelector: stringSet(input.showDropSelector, this.defaultValue.showDropSelector, ['afterDrop', 'never']),
5528
};
5529
}
5530
}
5531
5532
//#endregion
5533
5534
//#region pasteAs
5535
5536
/**
5537
* Configuration options for editor pasting as into behavior
5538
*/
5539
export interface IPasteAsOptions {
5540
/**
5541
* Enable paste as functionality in editors.
5542
* Defaults to true.
5543
*/
5544
enabled?: boolean;
5545
5546
/**
5547
* Controls if a widget is shown after a drop.
5548
* Defaults to 'afterPaste'.
5549
*/
5550
showPasteSelector?: 'afterPaste' | 'never';
5551
}
5552
5553
/**
5554
* @internal
5555
*/
5556
export type EditorPasteAsOptions = Readonly<Required<IPasteAsOptions>>;
5557
5558
class EditorPasteAs extends BaseEditorOption<EditorOption.pasteAs, IPasteAsOptions, EditorPasteAsOptions> {
5559
5560
constructor() {
5561
const defaults: EditorPasteAsOptions = { enabled: true, showPasteSelector: 'afterPaste' };
5562
super(
5563
EditorOption.pasteAs, 'pasteAs', defaults,
5564
{
5565
'editor.pasteAs.enabled': {
5566
type: 'boolean',
5567
default: defaults.enabled,
5568
markdownDescription: nls.localize('pasteAs.enabled', "Controls whether you can paste content in different ways."),
5569
},
5570
'editor.pasteAs.showPasteSelector': {
5571
type: 'string',
5572
markdownDescription: nls.localize('pasteAs.showPasteSelector', "Controls if a widget is shown when pasting content in to the editor. This widget lets you control how the file is pasted."),
5573
enum: [
5574
'afterPaste',
5575
'never'
5576
],
5577
enumDescriptions: [
5578
nls.localize('pasteAs.showPasteSelector.afterPaste', "Show the paste selector widget after content is pasted into the editor."),
5579
nls.localize('pasteAs.showPasteSelector.never', "Never show the paste selector widget. Instead the default pasting behavior is always used."),
5580
],
5581
default: 'afterPaste',
5582
},
5583
}
5584
);
5585
}
5586
5587
public validate(_input: any): EditorPasteAsOptions {
5588
if (!_input || typeof _input !== 'object') {
5589
return this.defaultValue;
5590
}
5591
const input = _input as IPasteAsOptions;
5592
return {
5593
enabled: boolean(input.enabled, this.defaultValue.enabled),
5594
showPasteSelector: stringSet(input.showPasteSelector, this.defaultValue.showPasteSelector, ['afterPaste', 'never']),
5595
};
5596
}
5597
}
5598
5599
//#endregion
5600
5601
const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
5602
const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
5603
const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace';
5604
5605
/**
5606
* @internal
5607
*/
5608
export const EDITOR_FONT_DEFAULTS = {
5609
fontFamily: (
5610
platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isWindows ? DEFAULT_WINDOWS_FONT_FAMILY : DEFAULT_LINUX_FONT_FAMILY)
5611
),
5612
fontWeight: 'normal',
5613
fontSize: (
5614
platform.isMacintosh ? 12 : 14
5615
),
5616
lineHeight: 0,
5617
letterSpacing: 0,
5618
};
5619
5620
/**
5621
* @internal
5622
*/
5623
export const editorOptionsRegistry: IEditorOption<EditorOption, any>[] = [];
5624
5625
function register<K extends EditorOption, V>(option: IEditorOption<K, V>): IEditorOption<K, V> {
5626
editorOptionsRegistry[option.id] = option;
5627
return option;
5628
}
5629
5630
export const enum EditorOption {
5631
acceptSuggestionOnCommitCharacter,
5632
acceptSuggestionOnEnter,
5633
accessibilitySupport,
5634
accessibilityPageSize,
5635
allowOverflow,
5636
allowVariableLineHeights,
5637
allowVariableFonts,
5638
allowVariableFontsInAccessibilityMode,
5639
ariaLabel,
5640
ariaRequired,
5641
autoClosingBrackets,
5642
autoClosingComments,
5643
screenReaderAnnounceInlineSuggestion,
5644
autoClosingDelete,
5645
autoClosingOvertype,
5646
autoClosingQuotes,
5647
autoIndent,
5648
autoIndentOnPaste,
5649
autoIndentOnPasteWithinString,
5650
automaticLayout,
5651
autoSurround,
5652
bracketPairColorization,
5653
guides,
5654
codeLens,
5655
codeLensFontFamily,
5656
codeLensFontSize,
5657
colorDecorators,
5658
colorDecoratorsLimit,
5659
columnSelection,
5660
comments,
5661
contextmenu,
5662
copyWithSyntaxHighlighting,
5663
cursorBlinking,
5664
cursorSmoothCaretAnimation,
5665
cursorStyle,
5666
cursorSurroundingLines,
5667
cursorSurroundingLinesStyle,
5668
cursorWidth,
5669
cursorHeight,
5670
disableLayerHinting,
5671
disableMonospaceOptimizations,
5672
domReadOnly,
5673
dragAndDrop,
5674
dropIntoEditor,
5675
editContext,
5676
emptySelectionClipboard,
5677
experimentalGpuAcceleration,
5678
experimentalWhitespaceRendering,
5679
extraEditorClassName,
5680
fastScrollSensitivity,
5681
find,
5682
fixedOverflowWidgets,
5683
folding,
5684
foldingStrategy,
5685
foldingHighlight,
5686
foldingImportsByDefault,
5687
foldingMaximumRegions,
5688
unfoldOnClickAfterEndOfLine,
5689
fontFamily,
5690
fontInfo,
5691
fontLigatures,
5692
fontSize,
5693
fontWeight,
5694
fontVariations,
5695
formatOnPaste,
5696
formatOnType,
5697
glyphMargin,
5698
gotoLocation,
5699
hideCursorInOverviewRuler,
5700
hover,
5701
inDiffEditor,
5702
inlineSuggest,
5703
letterSpacing,
5704
lightbulb,
5705
lineDecorationsWidth,
5706
lineHeight,
5707
lineNumbers,
5708
lineNumbersMinChars,
5709
linkedEditing,
5710
links,
5711
matchBrackets,
5712
minimap,
5713
mouseStyle,
5714
mouseWheelScrollSensitivity,
5715
mouseWheelZoom,
5716
multiCursorMergeOverlapping,
5717
multiCursorModifier,
5718
multiCursorPaste,
5719
multiCursorLimit,
5720
occurrencesHighlight,
5721
occurrencesHighlightDelay,
5722
overtypeCursorStyle,
5723
overtypeOnPaste,
5724
overviewRulerBorder,
5725
overviewRulerLanes,
5726
padding,
5727
pasteAs,
5728
parameterHints,
5729
peekWidgetDefaultFocus,
5730
placeholder,
5731
definitionLinkOpensInPeek,
5732
quickSuggestions,
5733
quickSuggestionsDelay,
5734
readOnly,
5735
readOnlyMessage,
5736
renameOnType,
5737
renderRichScreenReaderContent,
5738
renderControlCharacters,
5739
renderFinalNewline,
5740
renderLineHighlight,
5741
renderLineHighlightOnlyWhenFocus,
5742
renderValidationDecorations,
5743
renderWhitespace,
5744
revealHorizontalRightPadding,
5745
roundedSelection,
5746
rulers,
5747
scrollbar,
5748
scrollBeyondLastColumn,
5749
scrollBeyondLastLine,
5750
scrollPredominantAxis,
5751
selectionClipboard,
5752
selectionHighlight,
5753
selectionHighlightMaxLength,
5754
selectionHighlightMultiline,
5755
selectOnLineNumbers,
5756
showFoldingControls,
5757
showUnused,
5758
snippetSuggestions,
5759
smartSelect,
5760
smoothScrolling,
5761
stickyScroll,
5762
stickyTabStops,
5763
stopRenderingLineAfter,
5764
suggest,
5765
suggestFontSize,
5766
suggestLineHeight,
5767
suggestOnTriggerCharacters,
5768
suggestSelection,
5769
tabCompletion,
5770
tabIndex,
5771
trimWhitespaceOnDelete,
5772
unicodeHighlighting,
5773
unusualLineTerminators,
5774
useShadowDOM,
5775
useTabStops,
5776
wordBreak,
5777
wordSegmenterLocales,
5778
wordSeparators,
5779
wordWrap,
5780
wordWrapBreakAfterCharacters,
5781
wordWrapBreakBeforeCharacters,
5782
wordWrapColumn,
5783
wordWrapOverride1,
5784
wordWrapOverride2,
5785
wrappingIndent,
5786
wrappingStrategy,
5787
showDeprecated,
5788
inertialScroll,
5789
inlayHints,
5790
wrapOnEscapedLineFeeds,
5791
// Leave these at the end (because they have dependencies!)
5792
effectiveCursorStyle,
5793
editorClassName,
5794
pixelRatio,
5795
tabFocusMode,
5796
layoutInfo,
5797
wrappingInfo,
5798
defaultColorDecorators,
5799
colorDecoratorsActivatedOn,
5800
inlineCompletionsAccessibilityVerbose,
5801
effectiveEditContext,
5802
scrollOnMiddleClick,
5803
effectiveAllowVariableFonts
5804
}
5805
5806
export const EditorOptions = {
5807
acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption(
5808
EditorOption.acceptSuggestionOnCommitCharacter, 'acceptSuggestionOnCommitCharacter', true,
5809
{ 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.") }
5810
)),
5811
acceptSuggestionOnEnter: register(new EditorStringEnumOption(
5812
EditorOption.acceptSuggestionOnEnter, 'acceptSuggestionOnEnter',
5813
'on' as 'on' | 'smart' | 'off',
5814
['on', 'smart', 'off'] as const,
5815
{
5816
markdownEnumDescriptions: [
5817
'',
5818
nls.localize('acceptSuggestionOnEnterSmart', "Only accept a suggestion with `Enter` when it makes a textual change."),
5819
''
5820
],
5821
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.")
5822
}
5823
)),
5824
accessibilitySupport: register(new EditorAccessibilitySupport()),
5825
accessibilityPageSize: register(new EditorIntOption(EditorOption.accessibilityPageSize, 'accessibilityPageSize', 500, 1, Constants.MAX_SAFE_SMALL_INTEGER,
5826
{
5827
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."),
5828
tags: ['accessibility']
5829
}
5830
)),
5831
allowOverflow: register(new EditorBooleanOption(
5832
EditorOption.allowOverflow, 'allowOverflow', true,
5833
)),
5834
allowVariableLineHeights: register(new EditorBooleanOption(
5835
EditorOption.allowVariableLineHeights, 'allowVariableLineHeights', true,
5836
{
5837
description: nls.localize('allowVariableLineHeights', "Controls whether to allow using variable line heights in the editor.")
5838
}
5839
)),
5840
allowVariableFonts: register(new EditorBooleanOption(
5841
EditorOption.allowVariableFonts, 'allowVariableFonts', true,
5842
{
5843
description: nls.localize('allowVariableFonts', "Controls whether to allow using variable fonts in the editor.")
5844
}
5845
)),
5846
allowVariableFontsInAccessibilityMode: register(new EditorBooleanOption(
5847
EditorOption.allowVariableFontsInAccessibilityMode, 'allowVariableFontsInAccessibilityMode', false,
5848
{
5849
description: nls.localize('allowVariableFontsInAccessibilityMode', "Controls whether to allow using variable fonts in the editor in the accessibility mode."),
5850
tags: ['accessibility']
5851
}
5852
)),
5853
ariaLabel: register(new EditorStringOption(
5854
EditorOption.ariaLabel, 'ariaLabel', nls.localize('editorViewAccessibleLabel', "Editor content")
5855
)),
5856
ariaRequired: register(new EditorBooleanOption(
5857
EditorOption.ariaRequired, 'ariaRequired', false, undefined
5858
)),
5859
screenReaderAnnounceInlineSuggestion: register(new EditorBooleanOption(
5860
EditorOption.screenReaderAnnounceInlineSuggestion, 'screenReaderAnnounceInlineSuggestion', true,
5861
{
5862
description: nls.localize('screenReaderAnnounceInlineSuggestion', "Control whether inline suggestions are announced by a screen reader."),
5863
tags: ['accessibility']
5864
}
5865
)),
5866
autoClosingBrackets: register(new EditorStringEnumOption(
5867
EditorOption.autoClosingBrackets, 'autoClosingBrackets',
5868
'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',
5869
['always', 'languageDefined', 'beforeWhitespace', 'never'] as const,
5870
{
5871
enumDescriptions: [
5872
'',
5873
nls.localize('editor.autoClosingBrackets.languageDefined', "Use language configurations to determine when to autoclose brackets."),
5874
nls.localize('editor.autoClosingBrackets.beforeWhitespace', "Autoclose brackets only when the cursor is to the left of whitespace."),
5875
'',
5876
],
5877
description: nls.localize('autoClosingBrackets', "Controls whether the editor should automatically close brackets after the user adds an opening bracket.")
5878
}
5879
)),
5880
autoClosingComments: register(new EditorStringEnumOption(
5881
EditorOption.autoClosingComments, 'autoClosingComments',
5882
'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',
5883
['always', 'languageDefined', 'beforeWhitespace', 'never'] as const,
5884
{
5885
enumDescriptions: [
5886
'',
5887
nls.localize('editor.autoClosingComments.languageDefined', "Use language configurations to determine when to autoclose comments."),
5888
nls.localize('editor.autoClosingComments.beforeWhitespace', "Autoclose comments only when the cursor is to the left of whitespace."),
5889
'',
5890
],
5891
description: nls.localize('autoClosingComments', "Controls whether the editor should automatically close comments after the user adds an opening comment.")
5892
}
5893
)),
5894
autoClosingDelete: register(new EditorStringEnumOption(
5895
EditorOption.autoClosingDelete, 'autoClosingDelete',
5896
'auto' as 'always' | 'auto' | 'never',
5897
['always', 'auto', 'never'] as const,
5898
{
5899
enumDescriptions: [
5900
'',
5901
nls.localize('editor.autoClosingDelete.auto', "Remove adjacent closing quotes or brackets only if they were automatically inserted."),
5902
'',
5903
],
5904
description: nls.localize('autoClosingDelete', "Controls whether the editor should remove adjacent closing quotes or brackets when deleting.")
5905
}
5906
)),
5907
autoClosingOvertype: register(new EditorStringEnumOption(
5908
EditorOption.autoClosingOvertype, 'autoClosingOvertype',
5909
'auto' as 'always' | 'auto' | 'never',
5910
['always', 'auto', 'never'] as const,
5911
{
5912
enumDescriptions: [
5913
'',
5914
nls.localize('editor.autoClosingOvertype.auto', "Type over closing quotes or brackets only if they were automatically inserted."),
5915
'',
5916
],
5917
description: nls.localize('autoClosingOvertype', "Controls whether the editor should type over closing quotes or brackets.")
5918
}
5919
)),
5920
autoClosingQuotes: register(new EditorStringEnumOption(
5921
EditorOption.autoClosingQuotes, 'autoClosingQuotes',
5922
'languageDefined' as 'always' | 'languageDefined' | 'beforeWhitespace' | 'never',
5923
['always', 'languageDefined', 'beforeWhitespace', 'never'] as const,
5924
{
5925
enumDescriptions: [
5926
'',
5927
nls.localize('editor.autoClosingQuotes.languageDefined', "Use language configurations to determine when to autoclose quotes."),
5928
nls.localize('editor.autoClosingQuotes.beforeWhitespace', "Autoclose quotes only when the cursor is to the left of whitespace."),
5929
'',
5930
],
5931
description: nls.localize('autoClosingQuotes', "Controls whether the editor should automatically close quotes after the user adds an opening quote.")
5932
}
5933
)),
5934
autoIndent: register(new EditorEnumOption(
5935
EditorOption.autoIndent, 'autoIndent',
5936
EditorAutoIndentStrategy.Full, 'full',
5937
['none', 'keep', 'brackets', 'advanced', 'full'],
5938
_autoIndentFromString,
5939
{
5940
enumDescriptions: [
5941
nls.localize('editor.autoIndent.none', "The editor will not insert indentation automatically."),
5942
nls.localize('editor.autoIndent.keep', "The editor will keep the current line's indentation."),
5943
nls.localize('editor.autoIndent.brackets', "The editor will keep the current line's indentation and honor language defined brackets."),
5944
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."),
5945
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."),
5946
],
5947
description: nls.localize('autoIndent', "Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.")
5948
}
5949
)),
5950
autoIndentOnPaste: register(new EditorBooleanOption(
5951
EditorOption.autoIndentOnPaste, 'autoIndentOnPaste', false,
5952
{ description: nls.localize('autoIndentOnPaste', "Controls whether the editor should automatically auto-indent the pasted content.") }
5953
)),
5954
autoIndentOnPasteWithinString: register(new EditorBooleanOption(
5955
EditorOption.autoIndentOnPasteWithinString, 'autoIndentOnPasteWithinString', true,
5956
{ description: nls.localize('autoIndentOnPasteWithinString', "Controls whether the editor should automatically auto-indent the pasted content when pasted within a string. This takes effect when autoIndentOnPaste is true.") }
5957
)),
5958
automaticLayout: register(new EditorBooleanOption(
5959
EditorOption.automaticLayout, 'automaticLayout', false,
5960
)),
5961
autoSurround: register(new EditorStringEnumOption(
5962
EditorOption.autoSurround, 'autoSurround',
5963
'languageDefined' as 'languageDefined' | 'quotes' | 'brackets' | 'never',
5964
['languageDefined', 'quotes', 'brackets', 'never'] as const,
5965
{
5966
enumDescriptions: [
5967
nls.localize('editor.autoSurround.languageDefined', "Use language configurations to determine when to automatically surround selections."),
5968
nls.localize('editor.autoSurround.quotes', "Surround with quotes but not brackets."),
5969
nls.localize('editor.autoSurround.brackets', "Surround with brackets but not quotes."),
5970
''
5971
],
5972
description: nls.localize('autoSurround', "Controls whether the editor should automatically surround selections when typing quotes or brackets.")
5973
}
5974
)),
5975
bracketPairColorization: register(new BracketPairColorization()),
5976
bracketPairGuides: register(new GuideOptions()),
5977
stickyTabStops: register(new EditorBooleanOption(
5978
EditorOption.stickyTabStops, 'stickyTabStops', false,
5979
{ description: nls.localize('stickyTabStops', "Emulate selection behavior of tab characters when using spaces for indentation. Selection will stick to tab stops.") }
5980
)),
5981
codeLens: register(new EditorBooleanOption(
5982
EditorOption.codeLens, 'codeLens', true,
5983
{ description: nls.localize('codeLens', "Controls whether the editor shows CodeLens.") }
5984
)),
5985
codeLensFontFamily: register(new EditorStringOption(
5986
EditorOption.codeLensFontFamily, 'codeLensFontFamily', '',
5987
{ description: nls.localize('codeLensFontFamily', "Controls the font family for CodeLens.") }
5988
)),
5989
codeLensFontSize: register(new EditorIntOption(EditorOption.codeLensFontSize, 'codeLensFontSize', 0, 0, 100, {
5990
type: 'number',
5991
default: 0,
5992
minimum: 0,
5993
maximum: 100,
5994
markdownDescription: nls.localize('codeLensFontSize', "Controls the font size in pixels for CodeLens. When set to 0, 90% of `#editor.fontSize#` is used.")
5995
})),
5996
colorDecorators: register(new EditorBooleanOption(
5997
EditorOption.colorDecorators, 'colorDecorators', true,
5998
{ description: nls.localize('colorDecorators', "Controls whether the editor should render the inline color decorators and color picker.") }
5999
)),
6000
colorDecoratorActivatedOn: register(new EditorStringEnumOption(EditorOption.colorDecoratorsActivatedOn, 'colorDecoratorsActivatedOn', 'clickAndHover' as 'clickAndHover' | 'hover' | 'click', ['clickAndHover', 'hover', 'click'] as const, {
6001
enumDescriptions: [
6002
nls.localize('editor.colorDecoratorActivatedOn.clickAndHover', "Make the color picker appear both on click and hover of the color decorator"),
6003
nls.localize('editor.colorDecoratorActivatedOn.hover', "Make the color picker appear on hover of the color decorator"),
6004
nls.localize('editor.colorDecoratorActivatedOn.click', "Make the color picker appear on click of the color decorator")
6005
],
6006
description: nls.localize('colorDecoratorActivatedOn', "Controls the condition to make a color picker appear from a color decorator.")
6007
})),
6008
colorDecoratorsLimit: register(new EditorIntOption(
6009
EditorOption.colorDecoratorsLimit, 'colorDecoratorsLimit', 500, 1, 1000000,
6010
{
6011
markdownDescription: nls.localize('colorDecoratorsLimit', "Controls the max number of color decorators that can be rendered in an editor at once.")
6012
}
6013
)),
6014
columnSelection: register(new EditorBooleanOption(
6015
EditorOption.columnSelection, 'columnSelection', false,
6016
{ description: nls.localize('columnSelection', "Enable that the selection with the mouse and keys is doing column selection.") }
6017
)),
6018
comments: register(new EditorComments()),
6019
contextmenu: register(new EditorBooleanOption(
6020
EditorOption.contextmenu, 'contextmenu', true,
6021
)),
6022
copyWithSyntaxHighlighting: register(new EditorBooleanOption(
6023
EditorOption.copyWithSyntaxHighlighting, 'copyWithSyntaxHighlighting', true,
6024
{ description: nls.localize('copyWithSyntaxHighlighting', "Controls whether syntax highlighting should be copied into the clipboard.") }
6025
)),
6026
cursorBlinking: register(new EditorEnumOption(
6027
EditorOption.cursorBlinking, 'cursorBlinking',
6028
TextEditorCursorBlinkingStyle.Blink, 'blink',
6029
['blink', 'smooth', 'phase', 'expand', 'solid'],
6030
cursorBlinkingStyleFromString,
6031
{ description: nls.localize('cursorBlinking', "Control the cursor animation style.") }
6032
)),
6033
cursorSmoothCaretAnimation: register(new EditorStringEnumOption(
6034
EditorOption.cursorSmoothCaretAnimation, 'cursorSmoothCaretAnimation',
6035
'off' as 'off' | 'explicit' | 'on',
6036
['off', 'explicit', 'on'] as const,
6037
{
6038
enumDescriptions: [
6039
nls.localize('cursorSmoothCaretAnimation.off', "Smooth caret animation is disabled."),
6040
nls.localize('cursorSmoothCaretAnimation.explicit', "Smooth caret animation is enabled only when the user moves the cursor with an explicit gesture."),
6041
nls.localize('cursorSmoothCaretAnimation.on', "Smooth caret animation is always enabled.")
6042
],
6043
description: nls.localize('cursorSmoothCaretAnimation', "Controls whether the smooth caret animation should be enabled.")
6044
}
6045
)),
6046
cursorStyle: register(new EditorEnumOption(
6047
EditorOption.cursorStyle, 'cursorStyle',
6048
TextEditorCursorStyle.Line, 'line',
6049
['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'],
6050
cursorStyleFromString,
6051
{ description: nls.localize('cursorStyle', "Controls the cursor style in insert input mode.") }
6052
)),
6053
overtypeCursorStyle: register(new EditorEnumOption(
6054
EditorOption.overtypeCursorStyle, 'overtypeCursorStyle',
6055
TextEditorCursorStyle.Block, 'block',
6056
['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'],
6057
cursorStyleFromString,
6058
{ description: nls.localize('overtypeCursorStyle', "Controls the cursor style in overtype input mode.") }
6059
)),
6060
cursorSurroundingLines: register(new EditorIntOption(
6061
EditorOption.cursorSurroundingLines, 'cursorSurroundingLines',
6062
0, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6063
{ description: nls.localize('cursorSurroundingLines', "Controls the minimal number of visible leading lines (minimum 0) and trailing lines (minimum 1) surrounding the cursor. Known as 'scrollOff' or 'scrollOffset' in some other editors.") }
6064
)),
6065
cursorSurroundingLinesStyle: register(new EditorStringEnumOption(
6066
EditorOption.cursorSurroundingLinesStyle, 'cursorSurroundingLinesStyle',
6067
'default' as 'default' | 'all',
6068
['default', 'all'] as const,
6069
{
6070
enumDescriptions: [
6071
nls.localize('cursorSurroundingLinesStyle.default', "`cursorSurroundingLines` is enforced only when triggered via the keyboard or API."),
6072
nls.localize('cursorSurroundingLinesStyle.all', "`cursorSurroundingLines` is enforced always.")
6073
],
6074
markdownDescription: nls.localize('cursorSurroundingLinesStyle', "Controls when `#editor.cursorSurroundingLines#` should be enforced.")
6075
}
6076
)),
6077
cursorWidth: register(new EditorIntOption(
6078
EditorOption.cursorWidth, 'cursorWidth',
6079
0, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6080
{ markdownDescription: nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.") }
6081
)),
6082
cursorHeight: register(new EditorIntOption(
6083
EditorOption.cursorHeight, 'cursorHeight',
6084
0, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6085
{ markdownDescription: nls.localize('cursorHeight', "Controls the height of the cursor when `#editor.cursorStyle#` is set to `line`. Cursor's max height depends on line height.") }
6086
)),
6087
disableLayerHinting: register(new EditorBooleanOption(
6088
EditorOption.disableLayerHinting, 'disableLayerHinting', false,
6089
)),
6090
disableMonospaceOptimizations: register(new EditorBooleanOption(
6091
EditorOption.disableMonospaceOptimizations, 'disableMonospaceOptimizations', false
6092
)),
6093
domReadOnly: register(new EditorBooleanOption(
6094
EditorOption.domReadOnly, 'domReadOnly', false,
6095
)),
6096
dragAndDrop: register(new EditorBooleanOption(
6097
EditorOption.dragAndDrop, 'dragAndDrop', true,
6098
{ description: nls.localize('dragAndDrop', "Controls whether the editor should allow moving selections via drag and drop.") }
6099
)),
6100
emptySelectionClipboard: register(new EditorEmptySelectionClipboard()),
6101
dropIntoEditor: register(new EditorDropIntoEditor()),
6102
editContext: register(new EditorBooleanOption(
6103
EditorOption.editContext, 'editContext', true,
6104
{
6105
description: nls.localize('editContext', "Sets whether the EditContext API should be used instead of the text area to power input in the editor."),
6106
included: platform.isChrome || platform.isEdge || platform.isNative
6107
}
6108
)),
6109
renderRichScreenReaderContent: register(new EditorBooleanOption(
6110
EditorOption.renderRichScreenReaderContent, 'renderRichScreenReaderContent', false,
6111
{
6112
markdownDescription: nls.localize('renderRichScreenReaderContent', "Whether to render rich screen reader content when the `#editor.editContext#` setting is enabled."),
6113
}
6114
)),
6115
stickyScroll: register(new EditorStickyScroll()),
6116
experimentalGpuAcceleration: register(new EditorStringEnumOption(
6117
EditorOption.experimentalGpuAcceleration, 'experimentalGpuAcceleration',
6118
'off' as 'off' | 'on',
6119
['off', 'on'] as const,
6120
{
6121
tags: ['experimental'],
6122
enumDescriptions: [
6123
nls.localize('experimentalGpuAcceleration.off', "Use regular DOM-based rendering."),
6124
nls.localize('experimentalGpuAcceleration.on', "Use GPU acceleration."),
6125
],
6126
description: nls.localize('experimentalGpuAcceleration', "Controls whether to use the experimental GPU acceleration to render the editor.")
6127
}
6128
)),
6129
experimentalWhitespaceRendering: register(new EditorStringEnumOption(
6130
EditorOption.experimentalWhitespaceRendering, 'experimentalWhitespaceRendering',
6131
'svg' as 'svg' | 'font' | 'off',
6132
['svg', 'font', 'off'] as const,
6133
{
6134
enumDescriptions: [
6135
nls.localize('experimentalWhitespaceRendering.svg', "Use a new rendering method with svgs."),
6136
nls.localize('experimentalWhitespaceRendering.font', "Use a new rendering method with font characters."),
6137
nls.localize('experimentalWhitespaceRendering.off', "Use the stable rendering method."),
6138
],
6139
description: nls.localize('experimentalWhitespaceRendering', "Controls whether whitespace is rendered with a new, experimental method.")
6140
}
6141
)),
6142
extraEditorClassName: register(new EditorStringOption(
6143
EditorOption.extraEditorClassName, 'extraEditorClassName', '',
6144
)),
6145
fastScrollSensitivity: register(new EditorFloatOption(
6146
EditorOption.fastScrollSensitivity, 'fastScrollSensitivity',
6147
5, x => (x <= 0 ? 5 : x),
6148
{ markdownDescription: nls.localize('fastScrollSensitivity', "Scrolling speed multiplier when pressing `Alt`.") }
6149
)),
6150
find: register(new EditorFind()),
6151
fixedOverflowWidgets: register(new EditorBooleanOption(
6152
EditorOption.fixedOverflowWidgets, 'fixedOverflowWidgets', false,
6153
)),
6154
folding: register(new EditorBooleanOption(
6155
EditorOption.folding, 'folding', true,
6156
{ description: nls.localize('folding', "Controls whether the editor has code folding enabled.") }
6157
)),
6158
foldingStrategy: register(new EditorStringEnumOption(
6159
EditorOption.foldingStrategy, 'foldingStrategy',
6160
'auto' as 'auto' | 'indentation',
6161
['auto', 'indentation'] as const,
6162
{
6163
enumDescriptions: [
6164
nls.localize('foldingStrategy.auto', "Use a language-specific folding strategy if available, else the indentation-based one."),
6165
nls.localize('foldingStrategy.indentation', "Use the indentation-based folding strategy."),
6166
],
6167
description: nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges.")
6168
}
6169
)),
6170
foldingHighlight: register(new EditorBooleanOption(
6171
EditorOption.foldingHighlight, 'foldingHighlight', true,
6172
{ description: nls.localize('foldingHighlight', "Controls whether the editor should highlight folded ranges.") }
6173
)),
6174
foldingImportsByDefault: register(new EditorBooleanOption(
6175
EditorOption.foldingImportsByDefault, 'foldingImportsByDefault', false,
6176
{ description: nls.localize('foldingImportsByDefault', "Controls whether the editor automatically collapses import ranges.") }
6177
)),
6178
foldingMaximumRegions: register(new EditorIntOption(
6179
EditorOption.foldingMaximumRegions, 'foldingMaximumRegions',
6180
5000, 10, 65000, // limit must be less than foldingRanges MAX_FOLDING_REGIONS
6181
{ description: nls.localize('foldingMaximumRegions', "The maximum number of foldable regions. Increasing this value may result in the editor becoming less responsive when the current source has a large number of foldable regions.") }
6182
)),
6183
unfoldOnClickAfterEndOfLine: register(new EditorBooleanOption(
6184
EditorOption.unfoldOnClickAfterEndOfLine, 'unfoldOnClickAfterEndOfLine', false,
6185
{ description: nls.localize('unfoldOnClickAfterEndOfLine', "Controls whether clicking on the empty content after a folded line will unfold the line.") }
6186
)),
6187
fontFamily: register(new EditorStringOption(
6188
EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
6189
{ description: nls.localize('fontFamily', "Controls the font family.") }
6190
)),
6191
fontInfo: register(new EditorFontInfo()),
6192
fontLigatures2: register(new EditorFontLigatures()),
6193
fontSize: register(new EditorFontSize()),
6194
fontWeight: register(new EditorFontWeight()),
6195
fontVariations: register(new EditorFontVariations()),
6196
formatOnPaste: register(new EditorBooleanOption(
6197
EditorOption.formatOnPaste, 'formatOnPaste', false,
6198
{ 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.") }
6199
)),
6200
formatOnType: register(new EditorBooleanOption(
6201
EditorOption.formatOnType, 'formatOnType', false,
6202
{ description: nls.localize('formatOnType', "Controls whether the editor should automatically format the line after typing.") }
6203
)),
6204
glyphMargin: register(new EditorBooleanOption(
6205
EditorOption.glyphMargin, 'glyphMargin', true,
6206
{ description: nls.localize('glyphMargin', "Controls whether the editor should render the vertical glyph margin. Glyph margin is mostly used for debugging.") }
6207
)),
6208
gotoLocation: register(new EditorGoToLocation()),
6209
hideCursorInOverviewRuler: register(new EditorBooleanOption(
6210
EditorOption.hideCursorInOverviewRuler, 'hideCursorInOverviewRuler', false,
6211
{ description: nls.localize('hideCursorInOverviewRuler', "Controls whether the cursor should be hidden in the overview ruler.") }
6212
)),
6213
hover: register(new EditorHover()),
6214
inDiffEditor: register(new EditorBooleanOption(
6215
EditorOption.inDiffEditor, 'inDiffEditor', false
6216
)),
6217
inertialScroll: register(new EditorBooleanOption(
6218
EditorOption.inertialScroll, 'inertialScroll', false,
6219
{ description: nls.localize('inertialScroll', "Make scrolling inertial - mostly useful with touchpad on linux.") }
6220
)),
6221
letterSpacing: register(new EditorFloatOption(
6222
EditorOption.letterSpacing, 'letterSpacing',
6223
EDITOR_FONT_DEFAULTS.letterSpacing, x => EditorFloatOption.clamp(x, -5, 20),
6224
{ description: nls.localize('letterSpacing', "Controls the letter spacing in pixels.") }
6225
)),
6226
lightbulb: register(new EditorLightbulb()),
6227
lineDecorationsWidth: register(new EditorLineDecorationsWidth()),
6228
lineHeight: register(new EditorLineHeight()),
6229
lineNumbers: register(new EditorRenderLineNumbersOption()),
6230
lineNumbersMinChars: register(new EditorIntOption(
6231
EditorOption.lineNumbersMinChars, 'lineNumbersMinChars',
6232
5, 1, 300
6233
)),
6234
linkedEditing: register(new EditorBooleanOption(
6235
EditorOption.linkedEditing, 'linkedEditing', false,
6236
{ description: nls.localize('linkedEditing', "Controls whether the editor has linked editing enabled. Depending on the language, related symbols such as HTML tags, are updated while editing.") }
6237
)),
6238
links: register(new EditorBooleanOption(
6239
EditorOption.links, 'links', true,
6240
{ description: nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }
6241
)),
6242
matchBrackets: register(new EditorStringEnumOption(
6243
EditorOption.matchBrackets, 'matchBrackets',
6244
'always' as 'never' | 'near' | 'always',
6245
['always', 'near', 'never'] as const,
6246
{ description: nls.localize('matchBrackets', "Highlight matching brackets.") }
6247
)),
6248
minimap: register(new EditorMinimap()),
6249
mouseStyle: register(new EditorStringEnumOption(
6250
EditorOption.mouseStyle, 'mouseStyle',
6251
'text' as 'text' | 'default' | 'copy',
6252
['text', 'default', 'copy'] as const,
6253
)),
6254
mouseWheelScrollSensitivity: register(new EditorFloatOption(
6255
EditorOption.mouseWheelScrollSensitivity, 'mouseWheelScrollSensitivity',
6256
1, x => (x === 0 ? 1 : x),
6257
{ markdownDescription: nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.") }
6258
)),
6259
mouseWheelZoom: register(new EditorBooleanOption(
6260
EditorOption.mouseWheelZoom, 'mouseWheelZoom', false,
6261
{
6262
markdownDescription: platform.isMacintosh
6263
? nls.localize('mouseWheelZoom.mac', "Zoom the font of the editor when using mouse wheel and holding `Cmd`.")
6264
: nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding `Ctrl`.")
6265
}
6266
)),
6267
multiCursorMergeOverlapping: register(new EditorBooleanOption(
6268
EditorOption.multiCursorMergeOverlapping, 'multiCursorMergeOverlapping', true,
6269
{ description: nls.localize('multiCursorMergeOverlapping', "Merge multiple cursors when they are overlapping.") }
6270
)),
6271
multiCursorModifier: register(new EditorEnumOption(
6272
EditorOption.multiCursorModifier, 'multiCursorModifier',
6273
'altKey', 'alt',
6274
['ctrlCmd', 'alt'],
6275
_multiCursorModifierFromString,
6276
{
6277
markdownEnumDescriptions: [
6278
nls.localize('multiCursorModifier.ctrlCmd', "Maps to `Control` on Windows and Linux and to `Command` on macOS."),
6279
nls.localize('multiCursorModifier.alt', "Maps to `Alt` on Windows and Linux and to `Option` on macOS.")
6280
],
6281
markdownDescription: nls.localize({
6282
key: 'multiCursorModifier',
6283
comment: [
6284
'- `ctrlCmd` refers to a value the setting can take and should not be localized.',
6285
'- `Control` and `Command` refer to the modifier keys Ctrl or Cmd on the keyboard and can be localized.'
6286
]
6287
}, "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](https://code.visualstudio.com/docs/editor/codebasics#_multicursor-modifier).")
6288
}
6289
)),
6290
multiCursorPaste: register(new EditorStringEnumOption(
6291
EditorOption.multiCursorPaste, 'multiCursorPaste',
6292
'spread' as 'spread' | 'full',
6293
['spread', 'full'] as const,
6294
{
6295
markdownEnumDescriptions: [
6296
nls.localize('multiCursorPaste.spread', "Each cursor pastes a single line of the text."),
6297
nls.localize('multiCursorPaste.full', "Each cursor pastes the full text.")
6298
],
6299
markdownDescription: nls.localize('multiCursorPaste', "Controls pasting when the line count of the pasted text matches the cursor count.")
6300
}
6301
)),
6302
multiCursorLimit: register(new EditorIntOption(
6303
EditorOption.multiCursorLimit, 'multiCursorLimit', 10000, 1, 100000,
6304
{
6305
markdownDescription: nls.localize('multiCursorLimit', "Controls the max number of cursors that can be in an active editor at once.")
6306
}
6307
)),
6308
occurrencesHighlight: register(new EditorStringEnumOption(
6309
EditorOption.occurrencesHighlight, 'occurrencesHighlight',
6310
'singleFile' as 'off' | 'singleFile' | 'multiFile',
6311
['off', 'singleFile', 'multiFile'] as const,
6312
{
6313
markdownEnumDescriptions: [
6314
nls.localize('occurrencesHighlight.off', "Does not highlight occurrences."),
6315
nls.localize('occurrencesHighlight.singleFile', "Highlights occurrences only in the current file."),
6316
nls.localize('occurrencesHighlight.multiFile', "Experimental: Highlights occurrences across all valid open files.")
6317
],
6318
markdownDescription: nls.localize('occurrencesHighlight', "Controls whether occurrences should be highlighted across open files.")
6319
}
6320
)),
6321
occurrencesHighlightDelay: register(new EditorIntOption(
6322
EditorOption.occurrencesHighlightDelay, 'occurrencesHighlightDelay',
6323
0, 0, 2000,
6324
{
6325
description: nls.localize('occurrencesHighlightDelay', "Controls the delay in milliseconds after which occurrences are highlighted."),
6326
tags: ['preview']
6327
}
6328
)),
6329
overtypeOnPaste: register(new EditorBooleanOption(
6330
EditorOption.overtypeOnPaste, 'overtypeOnPaste', true,
6331
{ description: nls.localize('overtypeOnPaste', "Controls whether pasting should overtype.") }
6332
)),
6333
overviewRulerBorder: register(new EditorBooleanOption(
6334
EditorOption.overviewRulerBorder, 'overviewRulerBorder', true,
6335
{ description: nls.localize('overviewRulerBorder', "Controls whether a border should be drawn around the overview ruler.") }
6336
)),
6337
overviewRulerLanes: register(new EditorIntOption(
6338
EditorOption.overviewRulerLanes, 'overviewRulerLanes',
6339
3, 0, 3
6340
)),
6341
padding: register(new EditorPadding()),
6342
pasteAs: register(new EditorPasteAs()),
6343
parameterHints: register(new EditorParameterHints()),
6344
peekWidgetDefaultFocus: register(new EditorStringEnumOption(
6345
EditorOption.peekWidgetDefaultFocus, 'peekWidgetDefaultFocus',
6346
'tree' as 'tree' | 'editor',
6347
['tree', 'editor'] as const,
6348
{
6349
enumDescriptions: [
6350
nls.localize('peekWidgetDefaultFocus.tree', "Focus the tree when opening peek"),
6351
nls.localize('peekWidgetDefaultFocus.editor', "Focus the editor when opening peek")
6352
],
6353
description: nls.localize('peekWidgetDefaultFocus', "Controls whether to focus the inline editor or the tree in the peek widget.")
6354
}
6355
)),
6356
placeholder: register(new PlaceholderOption()),
6357
definitionLinkOpensInPeek: register(new EditorBooleanOption(
6358
EditorOption.definitionLinkOpensInPeek, 'definitionLinkOpensInPeek', false,
6359
{ description: nls.localize('definitionLinkOpensInPeek', "Controls whether the Go to Definition mouse gesture always opens the peek widget.") }
6360
)),
6361
quickSuggestions: register(new EditorQuickSuggestions()),
6362
quickSuggestionsDelay: register(new EditorIntOption(
6363
EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay',
6364
10, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6365
{
6366
description: nls.localize('quickSuggestionsDelay', "Controls the delay in milliseconds after which quick suggestions will show up."),
6367
experiment: {
6368
mode: 'auto'
6369
}
6370
}
6371
)),
6372
readOnly: register(new EditorBooleanOption(
6373
EditorOption.readOnly, 'readOnly', false,
6374
)),
6375
readOnlyMessage: register(new ReadonlyMessage()),
6376
renameOnType: register(new EditorBooleanOption(
6377
EditorOption.renameOnType, 'renameOnType', false,
6378
{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type."), markdownDeprecationMessage: nls.localize('renameOnTypeDeprecate', "Deprecated, use `#editor.linkedEditing#` instead.") }
6379
)),
6380
renderControlCharacters: register(new EditorBooleanOption(
6381
EditorOption.renderControlCharacters, 'renderControlCharacters', true,
6382
{ description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters."), restricted: true }
6383
)),
6384
renderFinalNewline: register(new EditorStringEnumOption(
6385
EditorOption.renderFinalNewline, 'renderFinalNewline',
6386
(platform.isLinux ? 'dimmed' : 'on') as 'off' | 'on' | 'dimmed',
6387
['off', 'on', 'dimmed'] as const,
6388
{ description: nls.localize('renderFinalNewline', "Render last line number when the file ends with a newline.") }
6389
)),
6390
renderLineHighlight: register(new EditorStringEnumOption(
6391
EditorOption.renderLineHighlight, 'renderLineHighlight',
6392
'line' as 'none' | 'gutter' | 'line' | 'all',
6393
['none', 'gutter', 'line', 'all'] as const,
6394
{
6395
enumDescriptions: [
6396
'',
6397
'',
6398
'',
6399
nls.localize('renderLineHighlight.all', "Highlights both the gutter and the current line."),
6400
],
6401
description: nls.localize('renderLineHighlight', "Controls how the editor should render the current line highlight.")
6402
}
6403
)),
6404
renderLineHighlightOnlyWhenFocus: register(new EditorBooleanOption(
6405
EditorOption.renderLineHighlightOnlyWhenFocus, 'renderLineHighlightOnlyWhenFocus', false,
6406
{ description: nls.localize('renderLineHighlightOnlyWhenFocus', "Controls if the editor should render the current line highlight only when the editor is focused.") }
6407
)),
6408
renderValidationDecorations: register(new EditorStringEnumOption(
6409
EditorOption.renderValidationDecorations, 'renderValidationDecorations',
6410
'editable' as 'editable' | 'on' | 'off',
6411
['editable', 'on', 'off'] as const
6412
)),
6413
renderWhitespace: register(new EditorStringEnumOption(
6414
EditorOption.renderWhitespace, 'renderWhitespace',
6415
'selection' as 'selection' | 'none' | 'boundary' | 'trailing' | 'all',
6416
['none', 'boundary', 'selection', 'trailing', 'all'] as const,
6417
{
6418
enumDescriptions: [
6419
'',
6420
nls.localize('renderWhitespace.boundary', "Render whitespace characters except for single spaces between words."),
6421
nls.localize('renderWhitespace.selection', "Render whitespace characters only on selected text."),
6422
nls.localize('renderWhitespace.trailing', "Render only trailing whitespace characters."),
6423
''
6424
],
6425
description: nls.localize('renderWhitespace', "Controls how the editor should render whitespace characters.")
6426
}
6427
)),
6428
revealHorizontalRightPadding: register(new EditorIntOption(
6429
EditorOption.revealHorizontalRightPadding, 'revealHorizontalRightPadding',
6430
15, 0, 1000,
6431
)),
6432
roundedSelection: register(new EditorBooleanOption(
6433
EditorOption.roundedSelection, 'roundedSelection', true,
6434
{ description: nls.localize('roundedSelection', "Controls whether selections should have rounded corners.") }
6435
)),
6436
rulers: register(new EditorRulers()),
6437
scrollbar: register(new EditorScrollbar()),
6438
scrollBeyondLastColumn: register(new EditorIntOption(
6439
EditorOption.scrollBeyondLastColumn, 'scrollBeyondLastColumn',
6440
4, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6441
{ description: nls.localize('scrollBeyondLastColumn', "Controls the number of extra characters beyond which the editor will scroll horizontally.") }
6442
)),
6443
scrollBeyondLastLine: register(new EditorBooleanOption(
6444
EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true,
6445
{ description: nls.localize('scrollBeyondLastLine', "Controls whether the editor will scroll beyond the last line.") }
6446
)),
6447
scrollOnMiddleClick: register(new EditorBooleanOption(
6448
EditorOption.scrollOnMiddleClick, 'scrollOnMiddleClick', false,
6449
{ description: nls.localize('scrollOnMiddleClick', "Controls whether the editor will scroll when the middle button is pressed.") }
6450
)),
6451
scrollPredominantAxis: register(new EditorBooleanOption(
6452
EditorOption.scrollPredominantAxis, 'scrollPredominantAxis', true,
6453
{ 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.") }
6454
)),
6455
selectionClipboard: register(new EditorBooleanOption(
6456
EditorOption.selectionClipboard, 'selectionClipboard', true,
6457
{
6458
description: nls.localize('selectionClipboard', "Controls whether the Linux primary clipboard should be supported."),
6459
included: platform.isLinux
6460
}
6461
)),
6462
selectionHighlight: register(new EditorBooleanOption(
6463
EditorOption.selectionHighlight, 'selectionHighlight', true,
6464
{ description: nls.localize('selectionHighlight', "Controls whether the editor should highlight matches similar to the selection.") }
6465
)),
6466
selectionHighlightMaxLength: register(new EditorIntOption(
6467
EditorOption.selectionHighlightMaxLength, 'selectionHighlightMaxLength',
6468
200, 0, Constants.MAX_SAFE_SMALL_INTEGER,
6469
{ description: nls.localize('selectionHighlightMaxLength', "Controls how many characters can be in the selection before similiar matches are not highlighted. Set to zero for unlimited.") }
6470
)),
6471
selectionHighlightMultiline: register(new EditorBooleanOption(
6472
EditorOption.selectionHighlightMultiline, 'selectionHighlightMultiline', false,
6473
{ description: nls.localize('selectionHighlightMultiline', "Controls whether the editor should highlight selection matches that span multiple lines.") }
6474
)),
6475
selectOnLineNumbers: register(new EditorBooleanOption(
6476
EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true,
6477
)),
6478
showFoldingControls: register(new EditorStringEnumOption(
6479
EditorOption.showFoldingControls, 'showFoldingControls',
6480
'mouseover' as 'always' | 'never' | 'mouseover',
6481
['always', 'never', 'mouseover'] as const,
6482
{
6483
enumDescriptions: [
6484
nls.localize('showFoldingControls.always', "Always show the folding controls."),
6485
nls.localize('showFoldingControls.never', "Never show the folding controls and reduce the gutter size."),
6486
nls.localize('showFoldingControls.mouseover', "Only show the folding controls when the mouse is over the gutter."),
6487
],
6488
description: nls.localize('showFoldingControls', "Controls when the folding controls on the gutter are shown.")
6489
}
6490
)),
6491
showUnused: register(new EditorBooleanOption(
6492
EditorOption.showUnused, 'showUnused', true,
6493
{ description: nls.localize('showUnused', "Controls fading out of unused code.") }
6494
)),
6495
showDeprecated: register(new EditorBooleanOption(
6496
EditorOption.showDeprecated, 'showDeprecated', true,
6497
{ description: nls.localize('showDeprecated', "Controls strikethrough deprecated variables.") }
6498
)),
6499
inlayHints: register(new EditorInlayHints()),
6500
snippetSuggestions: register(new EditorStringEnumOption(
6501
EditorOption.snippetSuggestions, 'snippetSuggestions',
6502
'inline' as 'top' | 'bottom' | 'inline' | 'none',
6503
['top', 'bottom', 'inline', 'none'] as const,
6504
{
6505
enumDescriptions: [
6506
nls.localize('snippetSuggestions.top', "Show snippet suggestions on top of other suggestions."),
6507
nls.localize('snippetSuggestions.bottom', "Show snippet suggestions below other suggestions."),
6508
nls.localize('snippetSuggestions.inline', "Show snippets suggestions with other suggestions."),
6509
nls.localize('snippetSuggestions.none', "Do not show snippet suggestions."),
6510
],
6511
description: nls.localize('snippetSuggestions', "Controls whether snippets are shown with other suggestions and how they are sorted.")
6512
}
6513
)),
6514
smartSelect: register(new SmartSelect()),
6515
smoothScrolling: register(new EditorBooleanOption(
6516
EditorOption.smoothScrolling, 'smoothScrolling', false,
6517
{ description: nls.localize('smoothScrolling', "Controls whether the editor will scroll using an animation.") }
6518
)),
6519
stopRenderingLineAfter: register(new EditorIntOption(
6520
EditorOption.stopRenderingLineAfter, 'stopRenderingLineAfter',
6521
10000, -1, Constants.MAX_SAFE_SMALL_INTEGER,
6522
)),
6523
suggest: register(new EditorSuggest()),
6524
inlineSuggest: register(new InlineEditorSuggest()),
6525
inlineCompletionsAccessibilityVerbose: register(new EditorBooleanOption(EditorOption.inlineCompletionsAccessibilityVerbose, 'inlineCompletionsAccessibilityVerbose', false,
6526
{ description: nls.localize('inlineCompletionsAccessibilityVerbose', "Controls whether the accessibility hint should be provided to screen reader users when an inline completion is shown.") })),
6527
suggestFontSize: register(new EditorIntOption(
6528
EditorOption.suggestFontSize, 'suggestFontSize',
6529
0, 0, 1000,
6530
{ markdownDescription: nls.localize('suggestFontSize', "Font size for the suggest widget. When set to {0}, the value of {1} is used.", '`0`', '`#editor.fontSize#`') }
6531
)),
6532
suggestLineHeight: register(new EditorIntOption(
6533
EditorOption.suggestLineHeight, 'suggestLineHeight',
6534
0, 0, 1000,
6535
{ markdownDescription: nls.localize('suggestLineHeight', "Line height for the suggest widget. When set to {0}, the value of {1} is used. The minimum value is 8.", '`0`', '`#editor.lineHeight#`') }
6536
)),
6537
suggestOnTriggerCharacters: register(new EditorBooleanOption(
6538
EditorOption.suggestOnTriggerCharacters, 'suggestOnTriggerCharacters', true,
6539
{ description: nls.localize('suggestOnTriggerCharacters', "Controls whether suggestions should automatically show up when typing trigger characters.") }
6540
)),
6541
suggestSelection: register(new EditorStringEnumOption(
6542
EditorOption.suggestSelection, 'suggestSelection',
6543
'first' as 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix',
6544
['first', 'recentlyUsed', 'recentlyUsedByPrefix'] as const,
6545
{
6546
markdownEnumDescriptions: [
6547
nls.localize('suggestSelection.first', "Always select the first suggestion."),
6548
nls.localize('suggestSelection.recentlyUsed', "Select recent suggestions unless further typing selects one, e.g. `console.| -> console.log` because `log` has been completed recently."),
6549
nls.localize('suggestSelection.recentlyUsedByPrefix', "Select suggestions based on previous prefixes that have completed those suggestions, e.g. `co -> console` and `con -> const`."),
6550
],
6551
description: nls.localize('suggestSelection', "Controls how suggestions are pre-selected when showing the suggest list.")
6552
}
6553
)),
6554
tabCompletion: register(new EditorStringEnumOption(
6555
EditorOption.tabCompletion, 'tabCompletion',
6556
'off' as 'on' | 'off' | 'onlySnippets',
6557
['on', 'off', 'onlySnippets'] as const,
6558
{
6559
enumDescriptions: [
6560
nls.localize('tabCompletion.on', "Tab complete will insert the best matching suggestion when pressing tab."),
6561
nls.localize('tabCompletion.off', "Disable tab completions."),
6562
nls.localize('tabCompletion.onlySnippets', "Tab complete snippets when their prefix match. Works best when 'quickSuggestions' aren't enabled."),
6563
],
6564
description: nls.localize('tabCompletion', "Enables tab completions.")
6565
}
6566
)),
6567
tabIndex: register(new EditorIntOption(
6568
EditorOption.tabIndex, 'tabIndex',
6569
0, -1, Constants.MAX_SAFE_SMALL_INTEGER
6570
)),
6571
trimWhitespaceOnDelete: register(new EditorBooleanOption(
6572
EditorOption.trimWhitespaceOnDelete, 'trimWhitespaceOnDelete', false,
6573
{ description: nls.localize('trimWhitespaceOnDelete', "Controls whether the editor will also delete the next line's indentation whitespace when deleting a newline.") }
6574
)),
6575
unicodeHighlight: register(new UnicodeHighlight()),
6576
unusualLineTerminators: register(new EditorStringEnumOption(
6577
EditorOption.unusualLineTerminators, 'unusualLineTerminators',
6578
'prompt' as 'auto' | 'off' | 'prompt',
6579
['auto', 'off', 'prompt'] as const,
6580
{
6581
enumDescriptions: [
6582
nls.localize('unusualLineTerminators.auto', "Unusual line terminators are automatically removed."),
6583
nls.localize('unusualLineTerminators.off', "Unusual line terminators are ignored."),
6584
nls.localize('unusualLineTerminators.prompt', "Unusual line terminators prompt to be removed."),
6585
],
6586
description: nls.localize('unusualLineTerminators', "Remove unusual line terminators that might cause problems.")
6587
}
6588
)),
6589
useShadowDOM: register(new EditorBooleanOption(
6590
EditorOption.useShadowDOM, 'useShadowDOM', true
6591
)),
6592
useTabStops: register(new EditorBooleanOption(
6593
EditorOption.useTabStops, 'useTabStops', true,
6594
{ description: nls.localize('useTabStops', "Spaces and tabs are inserted and deleted in alignment with tab stops.") }
6595
)),
6596
wordBreak: register(new EditorStringEnumOption(
6597
EditorOption.wordBreak, 'wordBreak',
6598
'normal' as 'normal' | 'keepAll',
6599
['normal', 'keepAll'] as const,
6600
{
6601
markdownEnumDescriptions: [
6602
nls.localize('wordBreak.normal', "Use the default line break rule."),
6603
nls.localize('wordBreak.keepAll', "Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as for normal."),
6604
],
6605
description: nls.localize('wordBreak', "Controls the word break rules used for Chinese/Japanese/Korean (CJK) text.")
6606
}
6607
)),
6608
wordSegmenterLocales: register(new WordSegmenterLocales()),
6609
wordSeparators: register(new EditorStringOption(
6610
EditorOption.wordSeparators, 'wordSeparators', USUAL_WORD_SEPARATORS,
6611
{ description: nls.localize('wordSeparators', "Characters that will be used as word separators when doing word related navigations or operations.") }
6612
)),
6613
wordWrap: register(new EditorStringEnumOption(
6614
EditorOption.wordWrap, 'wordWrap',
6615
'off' as 'off' | 'on' | 'wordWrapColumn' | 'bounded',
6616
['off', 'on', 'wordWrapColumn', 'bounded'] as const,
6617
{
6618
markdownEnumDescriptions: [
6619
nls.localize('wordWrap.off', "Lines will never wrap."),
6620
nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
6621
nls.localize({
6622
key: 'wordWrap.wordWrapColumn',
6623
comment: [
6624
'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
6625
]
6626
}, "Lines will wrap at `#editor.wordWrapColumn#`."),
6627
nls.localize({
6628
key: 'wordWrap.bounded',
6629
comment: [
6630
'- viewport means the edge of the visible window size.',
6631
'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
6632
]
6633
}, "Lines will wrap at the minimum of viewport and `#editor.wordWrapColumn#`."),
6634
],
6635
description: nls.localize({
6636
key: 'wordWrap',
6637
comment: [
6638
'- \'off\', \'on\', \'wordWrapColumn\' and \'bounded\' refer to values the setting can take and should not be localized.',
6639
'- `editor.wordWrapColumn` refers to a different setting and should not be localized.'
6640
]
6641
}, "Controls how lines should wrap.")
6642
}
6643
)),
6644
wordWrapBreakAfterCharacters: register(new EditorStringOption(
6645
EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters',
6646
// allow-any-unicode-next-line
6647
' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
6648
)),
6649
wordWrapBreakBeforeCharacters: register(new EditorStringOption(
6650
EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters',
6651
// allow-any-unicode-next-line
6652
'([{‘“〈《「『【〔([{「£¥$£¥++'
6653
)),
6654
wordWrapColumn: register(new EditorIntOption(
6655
EditorOption.wordWrapColumn, 'wordWrapColumn',
6656
80, 1, Constants.MAX_SAFE_SMALL_INTEGER,
6657
{
6658
markdownDescription: nls.localize({
6659
key: 'wordWrapColumn',
6660
comment: [
6661
'- `editor.wordWrap` refers to a different setting and should not be localized.',
6662
'- \'wordWrapColumn\' and \'bounded\' refer to values the different setting can take and should not be localized.'
6663
]
6664
}, "Controls the wrapping column of the editor when `#editor.wordWrap#` is `wordWrapColumn` or `bounded`.")
6665
}
6666
)),
6667
wordWrapOverride1: register(new EditorStringEnumOption(
6668
EditorOption.wordWrapOverride1, 'wordWrapOverride1',
6669
'inherit' as 'off' | 'on' | 'inherit',
6670
['off', 'on', 'inherit'] as const
6671
)),
6672
wordWrapOverride2: register(new EditorStringEnumOption(
6673
EditorOption.wordWrapOverride2, 'wordWrapOverride2',
6674
'inherit' as 'off' | 'on' | 'inherit',
6675
['off', 'on', 'inherit'] as const
6676
)),
6677
wrapOnEscapedLineFeeds: register(new EditorBooleanOption(
6678
EditorOption.wrapOnEscapedLineFeeds, 'wrapOnEscapedLineFeeds', false,
6679
{ markdownDescription: nls.localize('wrapOnEscapedLineFeeds', "Controls whether literal `\\n` shall trigger a wordWrap when `#editor.wordWrap#` is enabled.\n\nFor example:\n```c\nchar* str=\"hello\\nworld\"\n```\nwill be displayed as\n```c\nchar* str=\"hello\\n\n world\"\n```") }
6680
)),
6681
6682
// Leave these at the end (because they have dependencies!)
6683
effectiveCursorStyle: register(new EffectiveCursorStyle()),
6684
editorClassName: register(new EditorClassName()),
6685
defaultColorDecorators: register(new EditorStringEnumOption(
6686
EditorOption.defaultColorDecorators, 'defaultColorDecorators', 'auto' as 'auto' | 'always' | 'never',
6687
['auto', 'always', 'never'] as const,
6688
{
6689
enumDescriptions: [
6690
nls.localize('editor.defaultColorDecorators.auto', "Show default color decorators only when no extension provides colors decorators."),
6691
nls.localize('editor.defaultColorDecorators.always', "Always show default color decorators."),
6692
nls.localize('editor.defaultColorDecorators.never', "Never show default color decorators."),
6693
],
6694
description: nls.localize('defaultColorDecorators', "Controls whether inline color decorations should be shown using the default document color provider.")
6695
}
6696
)),
6697
pixelRatio: register(new EditorPixelRatio()),
6698
tabFocusMode: register(new EditorBooleanOption(EditorOption.tabFocusMode, 'tabFocusMode', false,
6699
{ markdownDescription: nls.localize('tabFocusMode', "Controls whether the editor receives tabs or defers them to the workbench for navigation.") }
6700
)),
6701
layoutInfo: register(new EditorLayoutInfoComputer()),
6702
wrappingInfo: register(new EditorWrappingInfoComputer()),
6703
wrappingIndent: register(new WrappingIndentOption()),
6704
wrappingStrategy: register(new WrappingStrategy()),
6705
effectiveEditContextEnabled: register(new EffectiveEditContextEnabled()),
6706
effectiveAllowVariableFonts: register(new EffectiveAllowVariableFonts())
6707
};
6708
6709
type EditorOptionsType = typeof EditorOptions;
6710
type FindEditorOptionsKeyById<T extends EditorOption> = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType];
6711
type ComputedEditorOptionValue<T extends IEditorOption<any, any>> = T extends IEditorOption<any, infer R> ? R : never;
6712
export type FindComputedEditorOptionValueById<T extends EditorOption> = NonNullable<ComputedEditorOptionValue<EditorOptionsType[FindEditorOptionsKeyById<T>]>>;
6713
6714