33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as nls from 'vs/nls' ;
6+ import * as arrays from 'vs/base/common/arrays' ;
7+ import { IMarkdownString } from 'vs/base/common/htmlContent' ;
8+ import { IJSONSchema } from 'vs/base/common/jsonSchema' ;
9+ import * as objects from 'vs/base/common/objects' ;
710import * as platform from 'vs/base/common/platform' ;
811import { ScrollbarVisibility } from 'vs/base/common/scrollable' ;
9- import { FontInfo } from 'vs/editor/common/config/fontInfo' ;
1012import { Constants } from 'vs/base/common/uint' ;
13+ import { FontInfo } from 'vs/editor/common/config/fontInfo' ;
14+ import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/core/textModelDefaults' ;
1115import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/core/wordHelper' ;
16+ import { IDocumentDiffProvider } from 'vs/editor/common/diff/documentDiffProvider' ;
17+ import * as nls from 'vs/nls' ;
1218import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility' ;
1319import { IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry' ;
14- import { IJSONSchema } from 'vs/base/common/jsonSchema' ;
15- import * as arrays from 'vs/base/common/arrays' ;
16- import * as objects from 'vs/base/common/objects' ;
17- import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/core/textModelDefaults' ;
18- import { IDocumentDiffProvider } from 'vs/editor/common/diff/documentDiffProvider' ;
1920
2021//#region typed options
2122
@@ -151,6 +152,10 @@ export interface IEditorOptions {
151152 * Defaults to false.
152153 */
153154 readOnly ?: boolean ;
155+ /**
156+ * The message to display when the editor is readonly.
157+ */
158+ readOnlyMessage ?: IMarkdownString ;
154159 /**
155160 * Should the textarea used for input use the DOM `readonly` attribute.
156161 * Defaults to false.
@@ -349,6 +354,10 @@ export interface IEditorOptions {
349354 * Enable inline color decorators and color picker rendering.
350355 */
351356 colorDecorators ?: boolean ;
357+ /**
358+ * Controls what is the condition to spawn a color picker from a color dectorator
359+ */
360+ colorDecoratorsActivatedOn ?: 'clickAndHover' | 'click' | 'hover' ;
352361 /**
353362 * Controls the max number of color decorators that can be rendered in an editor at once.
354363 */
@@ -707,6 +716,11 @@ export interface IEditorOptions {
707716 */
708717 dropIntoEditor ?: IDropIntoEditorOptions ;
709718
719+ /**
720+ * Controls support for changing how content is pasted into the editor.
721+ */
722+ pasteAs ?: IPasteAsOptions ;
723+
710724 /**
711725 * Controls whether the editor receives tabs or defers them to the workbench for navigation.
712726 */
@@ -789,6 +803,25 @@ export interface IDiffEditorBaseOptions {
789803 * Whether the diff editor aria label should be verbose.
790804 */
791805 accessibilityVerbose ?: boolean ;
806+
807+ experimental ?: {
808+ /**
809+ * Defaults to false.
810+ */
811+ collapseUnchangedRegions ?: boolean ;
812+ /**
813+ * Defaults to false.
814+ */
815+ showMoves ?: boolean ;
816+
817+ showEmptyDecorations ?: boolean ;
818+ } ;
819+
820+ /**
821+ * Is the diff editor inside another editor
822+ * Defaults to false
823+ */
824+ isInEmbeddedEditor ?: boolean ;
792825}
793826
794827/**
@@ -3434,6 +3467,30 @@ class EditorRulers extends BaseEditorOption<EditorOption.rulers, (number | IRule
34343467
34353468//#endregion
34363469
3470+ //#region readonly
3471+
3472+ /**
3473+ * Configuration options for readonly message
3474+ */
3475+ class ReadonlyMessage extends BaseEditorOption < EditorOption . readOnlyMessage , IMarkdownString | undefined , IMarkdownString | undefined > {
3476+ constructor ( ) {
3477+ const defaults = undefined ;
3478+
3479+ super (
3480+ EditorOption . readOnlyMessage , 'readOnlyMessage' , defaults
3481+ ) ;
3482+ }
3483+
3484+ public validate ( _input : any ) : IMarkdownString | undefined {
3485+ if ( ! _input || typeof _input !== 'object' ) {
3486+ return this . defaultValue ;
3487+ }
3488+ return _input as IMarkdownString ;
3489+ }
3490+ }
3491+
3492+ //#endregion
3493+
34373494//#region scrollbar
34383495
34393496/**
@@ -4282,7 +4339,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
42824339 const defaults : InternalSuggestOptions = {
42834340 insertMode : 'insert' ,
42844341 filterGraceful : true ,
4285- snippetsPreventQuickSuggestions : true ,
4342+ snippetsPreventQuickSuggestions : false ,
42864343 localityBonus : false ,
42874344 shareSuggestSelections : false ,
42884345 selectionMode : 'always' ,
@@ -4604,6 +4661,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
46044661
46054662export interface ISmartSelectOptions {
46064663 selectLeadingAndTrailingWhitespace ?: boolean ;
4664+ selectSubwords ?: boolean ;
46074665}
46084666
46094667/**
@@ -4617,13 +4675,19 @@ class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, ISmartSelec
46174675 super (
46184676 EditorOption . smartSelect , 'smartSelect' ,
46194677 {
4620- selectLeadingAndTrailingWhitespace : true
4678+ selectLeadingAndTrailingWhitespace : true ,
4679+ selectSubwords : true ,
46214680 } ,
46224681 {
46234682 'editor.smartSelect.selectLeadingAndTrailingWhitespace' : {
46244683 description : nls . localize ( 'selectLeadingAndTrailingWhitespace' , "Whether leading and trailing whitespace should always be selected." ) ,
46254684 default : true ,
46264685 type : 'boolean'
4686+ } ,
4687+ 'editor.smartSelect.selectSubwords' : {
4688+ description : nls . localize ( 'selectSubwords' , "Whether subwords (like 'foo' in 'fooBar' or 'foo_bar') should be selected." ) ,
4689+ default : true ,
4690+ type : 'boolean'
46274691 }
46284692 }
46294693 ) ;
@@ -4634,7 +4698,8 @@ class SmartSelect extends BaseEditorOption<EditorOption.smartSelect, ISmartSelec
46344698 return this . defaultValue ;
46354699 }
46364700 return {
4637- selectLeadingAndTrailingWhitespace : boolean ( ( input as ISmartSelectOptions ) . selectLeadingAndTrailingWhitespace , this . defaultValue . selectLeadingAndTrailingWhitespace )
4701+ selectLeadingAndTrailingWhitespace : boolean ( ( input as ISmartSelectOptions ) . selectLeadingAndTrailingWhitespace , this . defaultValue . selectLeadingAndTrailingWhitespace ) ,
4702+ selectSubwords : boolean ( ( input as ISmartSelectOptions ) . selectSubwords , this . defaultValue . selectSubwords ) ,
46384703 } ;
46394704 }
46404705}
@@ -4805,6 +4870,73 @@ class EditorDropIntoEditor extends BaseEditorOption<EditorOption.dropIntoEditor,
48054870
48064871//#endregion
48074872
4873+ //#region pasteAs
4874+
4875+ /**
4876+ * Configuration options for editor pasting as into behavior
4877+ */
4878+ export interface IPasteAsOptions {
4879+ /**
4880+ * Enable paste as functionality in editors.
4881+ * Defaults to true.
4882+ */
4883+ enabled ?: boolean ;
4884+
4885+ /**
4886+ * Controls if a widget is shown after a drop.
4887+ * Defaults to 'afterPaste'.
4888+ */
4889+ showPasteSelector ?: 'afterPaste' | 'never' ;
4890+ }
4891+
4892+ /**
4893+ * @internal
4894+ */
4895+ export type EditorPasteAsOptions = Readonly < Required < IPasteAsOptions > > ;
4896+
4897+ class EditorPasteAs extends BaseEditorOption < EditorOption . pasteAs , IPasteAsOptions , EditorPasteAsOptions > {
4898+
4899+ constructor ( ) {
4900+ const defaults : EditorPasteAsOptions = { enabled : true , showPasteSelector : 'afterPaste' } ;
4901+ super (
4902+ EditorOption . pasteAs , 'pasteAs' , defaults ,
4903+ {
4904+ 'editor.pasteAs.enabled' : {
4905+ type : 'boolean' ,
4906+ default : defaults . enabled ,
4907+ markdownDescription : nls . localize ( 'pasteAs.enabled' , "Controls whether you can paste content in different ways." ) ,
4908+ } ,
4909+ 'editor.pasteAs.showPasteSelector' : {
4910+ type : 'string' ,
4911+ 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." ) ,
4912+ enum : [
4913+ 'afterPaste' ,
4914+ 'never'
4915+ ] ,
4916+ enumDescriptions : [
4917+ nls . localize ( 'pasteAs.showPasteSelector.afterPaste' , "Show the paste selector widget after content is pasted into the editor." ) ,
4918+ nls . localize ( 'pasteAs.showPasteSelector.never' , "Never show the paste selector widget. Instead the default pasting behavior is always used." ) ,
4919+ ] ,
4920+ default : 'afterPaste' ,
4921+ } ,
4922+ }
4923+ ) ;
4924+ }
4925+
4926+ public validate ( _input : any ) : EditorPasteAsOptions {
4927+ if ( ! _input || typeof _input !== 'object' ) {
4928+ return this . defaultValue ;
4929+ }
4930+ const input = _input as IPasteAsOptions ;
4931+ return {
4932+ enabled : boolean ( input . enabled , this . defaultValue . enabled ) ,
4933+ showPasteSelector : stringSet ( input . showPasteSelector , this . defaultValue . showPasteSelector , [ 'afterPaste' , 'never' ] ) ,
4934+ } ;
4935+ }
4936+ }
4937+
4938+ //#endregion
4939+
48084940const DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace' ;
48094941const DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace' ;
48104942const DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace' ;
@@ -4917,12 +5049,14 @@ export const enum EditorOption {
49175049 overviewRulerBorder ,
49185050 overviewRulerLanes ,
49195051 padding ,
5052+ pasteAs ,
49205053 parameterHints ,
49215054 peekWidgetDefaultFocus ,
49225055 definitionLinkOpensInPeek ,
49235056 quickSuggestions ,
49245057 quickSuggestionsDelay ,
49255058 readOnly ,
5059+ readOnlyMessage ,
49265060 renameOnType ,
49275061 renderControlCharacters ,
49285062 renderFinalNewline ,
@@ -4977,7 +5111,8 @@ export const enum EditorOption {
49775111 tabFocusMode ,
49785112 layoutInfo ,
49795113 wrappingInfo ,
4980- defaultColorDecorators
5114+ defaultColorDecorators ,
5115+ colorDecoratorsActivatedOn
49815116}
49825117
49835118export const EditorOptions = {
@@ -5008,9 +5143,9 @@ export const EditorOptions = {
50085143 EditorOption . ariaLabel , 'ariaLabel' , nls . localize ( 'editorViewAccessibleLabel' , "Editor content" )
50095144 ) ) ,
50105145 screenReaderAnnounceInlineSuggestion : register ( new EditorBooleanOption (
5011- EditorOption . screenReaderAnnounceInlineSuggestion , 'screenReaderAnnounceInlineSuggestion' , false ,
5146+ EditorOption . screenReaderAnnounceInlineSuggestion , 'screenReaderAnnounceInlineSuggestion' , true ,
50125147 {
5013- description : nls . localize ( 'screenReaderAnnounceInlineSuggestion' , "Control whether inline suggestions are announced by a screen reader. Note that this does not work on macOS with VoiceOver. " ) ,
5148+ description : nls . localize ( 'screenReaderAnnounceInlineSuggestion' , "Control whether inline suggestions are announced by a screen reader." ) ,
50145149 tags : [ 'accessibility' ]
50155150 }
50165151 ) ) ,
@@ -5126,6 +5261,14 @@ export const EditorOptions = {
51265261 EditorOption . colorDecorators , 'colorDecorators' , true ,
51275262 { description : nls . localize ( 'colorDecorators' , "Controls whether the editor should render the inline color decorators and color picker." ) }
51285263 ) ) ,
5264+ colorDecoratorActivatedOn : register ( new EditorStringEnumOption ( EditorOption . colorDecoratorsActivatedOn , 'colorDecoratorsActivatedOn' , 'clickAndHover' as 'clickAndHover' | 'hover' | 'click' , [ 'clickAndHover' , 'hover' , 'click' ] as const , {
5265+ enumDescriptions : [
5266+ nls . localize ( 'editor.colorDecoratorActivatedOn.clickAndHover' , "Make the color picker appear both on click and hover of the color decorator" ) ,
5267+ nls . localize ( 'editor.colorDecoratorActivatedOn.hover' , "Make the color picker appear on hover of the color decorator" ) ,
5268+ nls . localize ( 'editor.colorDecoratorActivatedOn.click' , "Make the color picker appear on click of the color decorator" )
5269+ ] ,
5270+ description : nls . localize ( 'colorDecoratorActivatedOn' , "Controls the condition to make a color picker appear from a color decorator" )
5271+ } ) ) ,
51295272 colorDecoratorsLimit : register ( new EditorIntOption (
51305273 EditorOption . colorDecoratorsLimit , 'colorDecoratorsLimit' , 500 , 1 , 1000000 ,
51315274 {
@@ -5395,6 +5538,7 @@ export const EditorOptions = {
53955538 3 , 0 , 3
53965539 ) ) ,
53975540 padding : register ( new EditorPadding ( ) ) ,
5541+ pasteAs : register ( new EditorPasteAs ( ) ) ,
53985542 parameterHints : register ( new EditorParameterHints ( ) ) ,
53995543 peekWidgetDefaultFocus : register ( new EditorStringEnumOption (
54005544 EditorOption . peekWidgetDefaultFocus , 'peekWidgetDefaultFocus' ,
@@ -5421,6 +5565,7 @@ export const EditorOptions = {
54215565 readOnly : register ( new EditorBooleanOption (
54225566 EditorOption . readOnly , 'readOnly' , false ,
54235567 ) ) ,
5568+ readOnlyMessage : register ( new ReadonlyMessage ( ) ) ,
54245569 renameOnType : register ( new EditorBooleanOption (
54255570 EditorOption . renameOnType , 'renameOnType' , false ,
54265571 { description : nls . localize ( 'renameOnType' , "Controls whether the editor auto renames on type." ) , markdownDeprecationMessage : nls . localize ( 'renameOnTypeDeprecate' , "Deprecated, use `editor.linkedEditing` instead." ) }
0 commit comments