From 029bc311c79409212c242d5c68399f44b9155e48 Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Tue, 14 Jan 2020 15:09:39 +0100 Subject: [PATCH] Add getters for computed editor options (Fixes microsoft/monaco-editor#1734) --- build/gulpfile.editor.js | 7 + build/monaco/api.js | 53 +- build/monaco/api.ts | 63 +- build/monaco/monaco.d.ts.recipe | 3 +- src/vs/editor/browser/editorBrowser.ts | 4 +- src/vs/editor/common/config/editorOptions.ts | 73 +- .../common/standalone/standaloneEnums.ts | 722 ++++++++++++------ .../standalone/browser/standaloneEditor.ts | 24 +- src/vs/monaco.d.ts | 401 +++++++++- 9 files changed, 1006 insertions(+), 344 deletions(-) diff --git a/build/gulpfile.editor.js b/build/gulpfile.editor.js index 9a6f9fe5721a1..30d9e1e96d559 100644 --- a/build/gulpfile.editor.js +++ b/build/gulpfile.editor.js @@ -353,6 +353,13 @@ gulp.task('editor-distro', ) ); +gulp.task('monacodts', task.define('monacodts', () => { + const result = monacoapi.execute(); + fs.writeFileSync(result.filePath, result.content); + fs.writeFileSync(path.join(root, 'src/vs/editor/common/standalone/standaloneEnums.ts'), result.enums); + return Promise.resolve(true); +})); + //#region monaco type checking function createTscCompileTask(watch) { diff --git a/build/monaco/api.js b/build/monaco/api.js index a429cd66cde20..ee9505c059568 100644 --- a/build/monaco/api.js +++ b/build/monaco/api.js @@ -9,7 +9,7 @@ const ts = require("typescript"); const path = require("path"); const fancyLog = require("fancy-log"); const ansiColors = require("ansi-colors"); -const dtsv = '2'; +const dtsv = '3'; const tsfmt = require('../../tsfmt.json'); const SRC = path.join(__dirname, '../../src'); exports.RECIPE_PATH = path.join(__dirname, './monaco.d.ts.recipe'); @@ -148,12 +148,35 @@ function getMassagedTopLevelDeclarationText(sourceFile, declaration, importName, } }); } + else if (declaration.kind === ts.SyntaxKind.VariableStatement) { + const jsDoc = result.substr(0, declaration.getLeadingTriviaWidth(sourceFile)); + if (jsDoc.indexOf('@monacodtsreplace') >= 0) { + const jsDocLines = jsDoc.split(/\r\n|\r|\n/); + let directives = []; + for (const jsDocLine of jsDocLines) { + const m = jsDocLine.match(/^\s*\* \/([^/]+)\/([^/]+)\/$/); + if (m) { + directives.push([new RegExp(m[1], 'g'), m[2]]); + } + } + // remove the jsdoc + result = result.substr(jsDoc.length); + if (directives.length > 0) { + // apply replace directives + const replacer = createReplacerFromDirectives(directives); + result = replacer(result); + } + } + } result = result.replace(/export default /g, 'export '); result = result.replace(/export declare /g, 'export '); result = result.replace(/declare /g, ''); if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { result = result.replace(/const enum/, 'enum'); - enums.push(result); + enums.push({ + enumName: declaration.name.getText(sourceFile), + text: result + }); } return result; } @@ -277,6 +300,14 @@ function format(text, endl) { return result; } } +function createReplacerFromDirectives(directives) { + return (str) => { + for (let i = 0; i < directives.length; i++) { + str = str.replace(directives[i][0], directives[i][1]); + } + return str; + }; +} function createReplacer(data) { data = data || ''; let rawDirectives = data.split(';'); @@ -292,12 +323,7 @@ function createReplacer(data) { findStr = '\\b' + findStr + '\\b'; directives.push([new RegExp(findStr, 'g'), replaceStr]); }); - return (str) => { - for (let i = 0; i < directives.length; i++) { - str = str.replace(directives[i][0], directives[i][1]); - } - return str; - }; + return createReplacerFromDirectives(directives); } function generateDeclarationFile(recipe, sourceFileGetter) { const endl = /\r\n/.test(recipe) ? '\r\n' : '\n'; @@ -415,6 +441,15 @@ function generateDeclarationFile(recipe, sourceFileGetter) { resultTxt = resultTxt.split(/\r\n|\n|\r/).join(endl); resultTxt = format(resultTxt, endl); resultTxt = resultTxt.split(/\r\n|\n|\r/).join(endl); + enums.sort((e1, e2) => { + if (e1.enumName < e2.enumName) { + return -1; + } + if (e1.enumName > e2.enumName) { + return 1; + } + return 0; + }); let resultEnums = [ '/*---------------------------------------------------------------------------------------------', ' * Copyright (c) Microsoft Corporation. All rights reserved.', @@ -423,7 +458,7 @@ function generateDeclarationFile(recipe, sourceFileGetter) { '', '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', '' - ].concat(enums).join(endl); + ].concat(enums.map(e => e.text)).join(endl); resultEnums = resultEnums.split(/\r\n|\n|\r/).join(endl); resultEnums = format(resultEnums, endl); resultEnums = resultEnums.split(/\r\n|\n|\r/).join(endl); diff --git a/build/monaco/api.ts b/build/monaco/api.ts index ae058292344d7..b52b0b63431fa 100644 --- a/build/monaco/api.ts +++ b/build/monaco/api.ts @@ -9,7 +9,7 @@ import * as path from 'path'; import * as fancyLog from 'fancy-log'; import * as ansiColors from 'ansi-colors'; -const dtsv = '2'; +const dtsv = '3'; const tsfmt = require('../../tsfmt.json'); @@ -138,7 +138,7 @@ function isDefaultExport(declaration: ts.InterfaceDeclaration | ts.ClassDeclarat ); } -function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declaration: TSTopLevelDeclare, importName: string, usage: string[], enums: string[]): string { +function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declaration: TSTopLevelDeclare, importName: string, usage: string[], enums: IEnumEntry[]): string { let result = getNodeText(sourceFile, declaration); if (declaration.kind === ts.SyntaxKind.InterfaceDeclaration || declaration.kind === ts.SyntaxKind.ClassDeclaration) { let interfaceDeclaration = declaration; @@ -177,6 +177,25 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati // life.. } }); + } else if (declaration.kind === ts.SyntaxKind.VariableStatement) { + const jsDoc = result.substr(0, declaration.getLeadingTriviaWidth(sourceFile)); + if (jsDoc.indexOf('@monacodtsreplace') >= 0) { + const jsDocLines = jsDoc.split(/\r\n|\r|\n/); + let directives: [RegExp, string][] = []; + for (const jsDocLine of jsDocLines) { + const m = jsDocLine.match(/^\s*\* \/([^/]+)\/([^/]+)\/$/); + if (m) { + directives.push([new RegExp(m[1], 'g'), m[2]]); + } + } + // remove the jsdoc + result = result.substr(jsDoc.length); + if (directives.length > 0) { + // apply replace directives + const replacer = createReplacerFromDirectives(directives); + result = replacer(result); + } + } } result = result.replace(/export default /g, 'export '); result = result.replace(/export declare /g, 'export '); @@ -184,7 +203,10 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { result = result.replace(/const enum/, 'enum'); - enums.push(result); + enums.push({ + enumName: declaration.name.getText(sourceFile), + text: result + }); } return result; @@ -324,6 +346,15 @@ function format(text: string, endl: string): string { } } +function createReplacerFromDirectives(directives: [RegExp, string][]): (str: string) => string { + return (str: string) => { + for (let i = 0; i < directives.length; i++) { + str = str.replace(directives[i][0], directives[i][1]); + } + return str; + }; +} + function createReplacer(data: string): (str: string) => string { data = data || ''; let rawDirectives = data.split(';'); @@ -341,12 +372,7 @@ function createReplacer(data: string): (str: string) => string { directives.push([new RegExp(findStr, 'g'), replaceStr]); }); - return (str: string) => { - for (let i = 0; i < directives.length; i++) { - str = str.replace(directives[i][0], directives[i][1]); - } - return str; - }; + return createReplacerFromDirectives(directives); } interface ITempResult { @@ -355,6 +381,11 @@ interface ITempResult { enums: string; } +interface IEnumEntry { + enumName: string; + text: string; +} + function generateDeclarationFile(recipe: string, sourceFileGetter: SourceFileGetter): ITempResult | null { const endl = /\r\n/.test(recipe) ? '\r\n' : '\n'; @@ -376,7 +407,7 @@ function generateDeclarationFile(recipe: string, sourceFileGetter: SourceFileGet return importName; }; - let enums: string[] = []; + let enums: IEnumEntry[] = []; let version: string | null = null; lines.forEach(line => { @@ -492,6 +523,16 @@ function generateDeclarationFile(recipe: string, sourceFileGetter: SourceFileGet resultTxt = format(resultTxt, endl); resultTxt = resultTxt.split(/\r\n|\n|\r/).join(endl); + enums.sort((e1, e2) => { + if (e1.enumName < e2.enumName) { + return -1; + } + if (e1.enumName > e2.enumName) { + return 1; + } + return 0; + }); + let resultEnums = [ '/*---------------------------------------------------------------------------------------------', ' * Copyright (c) Microsoft Corporation. All rights reserved.', @@ -500,7 +541,7 @@ function generateDeclarationFile(recipe: string, sourceFileGetter: SourceFileGet '', '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', '' - ].concat(enums).join(endl); + ].concat(enums.map(e => e.text)).join(endl); resultEnums = resultEnums.split(/\r\n|\n|\r/).join(endl); resultEnums = format(resultEnums, endl); resultEnums = resultEnums.split(/\r\n|\n|\r/).join(endl); diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index f16ed378bd579..fdcdf533406e9 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -62,6 +62,7 @@ export interface ICommandHandler { #includeAll(vs/editor/common/editorCommon;editorOptions.=>): IScrollEvent #includeAll(vs/editor/common/model/textModelEvents): #includeAll(vs/editor/common/controller/cursorEvents): +#include(vs/platform/accessibility/common/accessibility): AccessibilitySupport #includeAll(vs/editor/common/config/editorOptions): #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>): #include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo @@ -87,4 +88,4 @@ declare namespace monaco.worker { } -//dtsv=2 +//dtsv=3 diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index c359f7ee54d95..29b6bd138d966 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -532,12 +532,12 @@ export interface ICodeEditor extends editorCommon.IEditor { setModel(model: ITextModel | null): void; /** - * @internal + * Gets all the editor computed options. */ getOptions(): IComputedEditorOptions; /** - * @internal + * Gets a specific editor option. */ getOption(id: T): FindComputedEditorOptionValueById; diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 74217d504b70e..27bf220d5a4b5 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -33,7 +33,6 @@ export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never'; /** * Configuration options for auto indentation in the editor - * @internal */ export const enum EditorAutoIndentStrategy { None = 0, @@ -626,7 +625,7 @@ export class ValidatedEditorOptions { } /** - * @internal + * All computed editor options. */ export interface IComputedEditorOptions { get(id: T): FindComputedEditorOptionValueById; @@ -650,9 +649,6 @@ export interface IEnvironmentalOptions { readonly accessibilitySupport: AccessibilitySupport; } -/** - * @internal - */ export interface IEditorOption { readonly id: K1; readonly name: string; @@ -990,7 +986,6 @@ class EditorAccessibilitySupport extends BaseEditorOption>; class EditorFind extends BaseEditorOption { @@ -1354,9 +1345,6 @@ export interface IGotoLocationOptions { alternativeReferenceCommand?: string; } -/** - * @internal - */ export type GoToLocationOptions = Readonly>; class EditorGoToLocation extends BaseEditorOption { @@ -1486,9 +1474,6 @@ export interface IEditorHoverOptions { sticky?: boolean; } -/** - * @internal - */ export type EditorHoverOptions = Readonly>; class EditorHover extends BaseEditorOption { @@ -1865,9 +1850,6 @@ export interface IEditorLightbulbOptions { enabled?: boolean; } -/** - * @internal - */ export type EditorLightbulbOptions = Readonly>; class EditorLightbulb extends BaseEditorOption { @@ -1959,9 +1941,6 @@ export interface IEditorMinimapOptions { scale?: number; } -/** - * @internal - */ export type EditorMinimapOptions = Readonly>; class EditorMinimap extends BaseEditorOption { @@ -2063,9 +2042,6 @@ export interface IEditorParameterHintOptions { cycle?: boolean; } -/** - * @internal - */ export type InternalParameterHintOptions = Readonly>; class EditorParameterHints extends BaseEditorOption { @@ -2132,9 +2108,6 @@ export interface IQuickSuggestionsOptions { strings: boolean; } -/** - * @internal - */ export type ValidQuickSuggestionsOptions = boolean | Readonly>; class EditorQuickSuggestions extends BaseEditorOption { @@ -2211,9 +2184,6 @@ class EditorQuickSuggestions extends BaseEditorOption string); -/** - * @internal - */ export const enum RenderLineNumbersType { Off = 0, On = 1, @@ -2222,9 +2192,6 @@ export const enum RenderLineNumbersType { Custom = 4 } -/** - * @internal - */ export interface InternalEditorRenderLineNumbersOptions { readonly renderType: RenderLineNumbersType; readonly renderFn: ((lineNumber: number) => string) | null; @@ -2380,9 +2347,6 @@ export interface IEditorScrollbarOptions { horizontalSliderSize?: number; } -/** - * @internal - */ export interface InternalEditorScrollbarOptions { readonly arrowSize: number; readonly vertical: ScrollbarVisibility; @@ -2597,9 +2561,6 @@ export interface ISuggestOptions { showSnippets?: boolean; } -/** - * @internal - */ export type InternalSuggestOptions = Readonly>; class EditorSuggest extends BaseEditorOption { @@ -2893,7 +2854,6 @@ class EditorTabFocusMode extends ComputedEditorOption(option: IEditorOption): IEd return option; } -/** - * @internal - */ export const enum EditorOption { acceptSuggestionOnCommitCharacter, acceptSuggestionOnEnter, @@ -3162,7 +3116,18 @@ export const enum EditorOption { } /** - * @internal + * WORKAROUND: TS emits "any" for complex editor options values (anything except string, bool, enum, etc. ends up being "any") + * @monacodtsreplace + * /accessibilitySupport, any/accessibilitySupport, AccessibilitySupport/ + * /find, any/find, EditorFindOptions/ + * /fontInfo, any/fontInfo, FontInfo/ + * /gotoLocation, any/gotoLocation, GoToLocationOptions/ + * /hover, any/hover, EditorHoverOptions/ + * /lightbulb, any/lightbulb, EditorLightbulbOptions/ + * /minimap, any/minimap, EditorMinimapOptions/ + * /parameterHints, any/parameterHints, InternalParameterHintOptions/ + * /quickSuggestions, any/quickSuggestions, ValidQuickSuggestionsOptions/ + * /suggest, any/suggest, InternalSuggestOptions/ */ export const EditorOptions = { acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption( @@ -3721,19 +3686,7 @@ export const EditorOptions = { wrappingInfo: register(new EditorWrappingInfoComputer()), }; -/** - * @internal - */ type EditorOptionsType = typeof EditorOptions; -/** - * @internal - */ type FindEditorOptionsKeyById = { [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never }[keyof EditorOptionsType]; -/** - * @internal - */ type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; -/** - * @internal - */ export type FindComputedEditorOptionValueById = NonNullable]>>; diff --git a/src/vs/editor/common/standalone/standaloneEnums.ts b/src/vs/editor/common/standalone/standaloneEnums.ts index 3340dd5c045b1..f23767462c37f 100644 --- a/src/vs/editor/common/standalone/standaloneEnums.ts +++ b/src/vs/editor/common/standalone/standaloneEnums.ts @@ -6,16 +6,326 @@ // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. -export enum MarkerTag { - Unnecessary = 1, - Deprecated = 2 +export enum AccessibilitySupport { + /** + * This should be the browser case where it is not known if a screen reader is attached or no. + */ + Unknown = 0, + Disabled = 1, + Enabled = 2 } -export enum MarkerSeverity { - Hint = 1, - Info = 2, - Warning = 4, - Error = 8 +export enum CompletionItemInsertTextRule { + /** + * Adjust whitespace/indentation of multiline insert texts to + * match the current line indentation. + */ + KeepWhitespace = 1, + /** + * `insertText` is a snippet. + */ + InsertAsSnippet = 4 +} + +export enum CompletionItemKind { + Method = 0, + Function = 1, + Constructor = 2, + Field = 3, + Variable = 4, + Class = 5, + Struct = 6, + Interface = 7, + Module = 8, + Property = 9, + Event = 10, + Operator = 11, + Unit = 12, + Value = 13, + Constant = 14, + Enum = 15, + EnumMember = 16, + Keyword = 17, + Text = 18, + Color = 19, + File = 20, + Reference = 21, + Customcolor = 22, + Folder = 23, + TypeParameter = 24, + Snippet = 25 +} + +export enum CompletionItemTag { + Deprecated = 1 +} + +/** + * How a suggest provider was triggered. + */ +export enum CompletionTriggerKind { + Invoke = 0, + TriggerCharacter = 1, + TriggerForIncompleteCompletions = 2 +} + +/** + * A positioning preference for rendering content widgets. + */ +export enum ContentWidgetPositionPreference { + /** + * Place the content widget exactly at a position + */ + EXACT = 0, + /** + * Place the content widget above a position + */ + ABOVE = 1, + /** + * Place the content widget below a position + */ + BELOW = 2 +} + +/** + * Describes the reason the cursor has changed its position. + */ +export enum CursorChangeReason { + /** + * Unknown or not set. + */ + NotSet = 0, + /** + * A `model.setValue()` was called. + */ + ContentFlush = 1, + /** + * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. + */ + RecoverFromMarkers = 2, + /** + * There was an explicit user gesture. + */ + Explicit = 3, + /** + * There was a Paste. + */ + Paste = 4, + /** + * There was an Undo. + */ + Undo = 5, + /** + * There was a Redo. + */ + Redo = 6 +} + +/** + * The default end of line to use when instantiating models. + */ +export enum DefaultEndOfLine { + /** + * Use line feed (\n) as the end of line character. + */ + LF = 1, + /** + * Use carriage return and line feed (\r\n) as the end of line character. + */ + CRLF = 2 +} + +/** + * A document highlight kind. + */ +export enum DocumentHighlightKind { + /** + * A textual occurrence. + */ + Text = 0, + /** + * Read-access of a symbol, like reading a variable. + */ + Read = 1, + /** + * Write-access of a symbol, like writing to a variable. + */ + Write = 2 +} + +/** + * Configuration options for auto indentation in the editor + */ +export enum EditorAutoIndentStrategy { + None = 0, + Keep = 1, + Brackets = 2, + Advanced = 3, + Full = 4 +} + +export enum EditorOption { + acceptSuggestionOnCommitCharacter = 0, + acceptSuggestionOnEnter = 1, + accessibilitySupport = 2, + accessibilityPageSize = 3, + ariaLabel = 4, + autoClosingBrackets = 5, + autoClosingOvertype = 6, + autoClosingQuotes = 7, + autoIndent = 8, + automaticLayout = 9, + autoSurround = 10, + codeLens = 11, + colorDecorators = 12, + contextmenu = 13, + copyWithSyntaxHighlighting = 14, + cursorBlinking = 15, + cursorSmoothCaretAnimation = 16, + cursorStyle = 17, + cursorSurroundingLines = 18, + cursorSurroundingLinesStyle = 19, + cursorWidth = 20, + disableLayerHinting = 21, + disableMonospaceOptimizations = 22, + dragAndDrop = 23, + emptySelectionClipboard = 24, + extraEditorClassName = 25, + fastScrollSensitivity = 26, + find = 27, + fixedOverflowWidgets = 28, + folding = 29, + foldingStrategy = 30, + fontFamily = 31, + fontInfo = 32, + fontLigatures = 33, + fontSize = 34, + fontWeight = 35, + formatOnPaste = 36, + formatOnType = 37, + glyphMargin = 38, + gotoLocation = 39, + hideCursorInOverviewRuler = 40, + highlightActiveIndentGuide = 41, + hover = 42, + inDiffEditor = 43, + letterSpacing = 44, + lightbulb = 45, + lineDecorationsWidth = 46, + lineHeight = 47, + lineNumbers = 48, + lineNumbersMinChars = 49, + links = 50, + matchBrackets = 51, + minimap = 52, + mouseStyle = 53, + mouseWheelScrollSensitivity = 54, + mouseWheelZoom = 55, + multiCursorMergeOverlapping = 56, + multiCursorModifier = 57, + multiCursorPaste = 58, + occurrencesHighlight = 59, + overviewRulerBorder = 60, + overviewRulerLanes = 61, + parameterHints = 62, + quickSuggestions = 63, + quickSuggestionsDelay = 64, + readOnly = 65, + renderControlCharacters = 66, + renderIndentGuides = 67, + renderFinalNewline = 68, + renderLineHighlight = 69, + renderWhitespace = 70, + revealHorizontalRightPadding = 71, + roundedSelection = 72, + rulers = 73, + scrollbar = 74, + scrollBeyondLastColumn = 75, + scrollBeyondLastLine = 76, + selectionClipboard = 77, + selectionHighlight = 78, + selectOnLineNumbers = 79, + showFoldingControls = 80, + showUnused = 81, + snippetSuggestions = 82, + smoothScrolling = 83, + stopRenderingLineAfter = 84, + suggest = 85, + suggestFontSize = 86, + suggestLineHeight = 87, + suggestOnTriggerCharacters = 88, + suggestSelection = 89, + tabCompletion = 90, + useTabStops = 91, + wordSeparators = 92, + wordWrap = 93, + wordWrapBreakAfterCharacters = 94, + wordWrapBreakBeforeCharacters = 95, + wordWrapBreakObtrusiveCharacters = 96, + wordWrapColumn = 97, + wordWrapMinified = 98, + wrappingIndent = 99, + editorClassName = 100, + pixelRatio = 101, + tabFocusMode = 102, + layoutInfo = 103, + wrappingInfo = 104 +} + +/** + * End of line character preference. + */ +export enum EndOfLinePreference { + /** + * Use the end of line character identified in the text buffer. + */ + TextDefined = 0, + /** + * Use line feed (\n) as the end of line character. + */ + LF = 1, + /** + * Use carriage return and line feed (\r\n) as the end of line character. + */ + CRLF = 2 +} + +/** + * End of line character preference. + */ +export enum EndOfLineSequence { + /** + * Use line feed (\n) as the end of line character. + */ + LF = 0, + /** + * Use carriage return and line feed (\r\n) as the end of line character. + */ + CRLF = 1 +} + +/** + * Describes what to do with the indentation when pressing Enter. + */ +export enum IndentAction { + /** + * Insert new line and copy the previous line's indentation. + */ + None = 0, + /** + * Insert new line and indent once (relative to the previous line's indentation). + */ + Indent = 1, + /** + * Insert two new lines: + * - the first one indented which will hold the cursor + * - the second one at the same indentation level + */ + IndentOutdent = 2, + /** + * Insert new line and outdent once (relative to the previous line's indentation). + */ + Outdent = 3 } /** @@ -199,34 +509,16 @@ export enum KeyCode { MAX_VALUE = 112 } -/** - * The direction of a selection. - */ -export enum SelectionDirection { - /** - * The selection starts above where it ends. - */ - LTR = 0, - /** - * The selection starts below where it ends. - */ - RTL = 1 -} - -export enum ScrollbarVisibility { - Auto = 1, - Hidden = 2, - Visible = 3 +export enum MarkerSeverity { + Hint = 1, + Info = 2, + Warning = 4, + Error = 8 } -/** - * Vertical Lane in the overview ruler of the editor. - */ -export enum OverviewRulerLane { - Left = 1, - Center = 2, - Right = 4, - Full = 7 +export enum MarkerTag { + Unnecessary = 1, + Deprecated = 2 } /** @@ -238,155 +530,17 @@ export enum MinimapPosition { } /** - * End of line character preference. + * Type of hit element with the mouse in the editor. */ -export enum EndOfLinePreference { +export enum MouseTargetType { /** - * Use the end of line character identified in the text buffer. + * Mouse is on top of an unknown element. */ - TextDefined = 0, + UNKNOWN = 0, /** - * Use line feed (\n) as the end of line character. + * Mouse is on top of the textarea used for input. */ - LF = 1, - /** - * Use carriage return and line feed (\r\n) as the end of line character. - */ - CRLF = 2 -} - -/** - * The default end of line to use when instantiating models. - */ -export enum DefaultEndOfLine { - /** - * Use line feed (\n) as the end of line character. - */ - LF = 1, - /** - * Use carriage return and line feed (\r\n) as the end of line character. - */ - CRLF = 2 -} - -/** - * End of line character preference. - */ -export enum EndOfLineSequence { - /** - * Use line feed (\n) as the end of line character. - */ - LF = 0, - /** - * Use carriage return and line feed (\r\n) as the end of line character. - */ - CRLF = 1 -} - -/** - * Describes the behavior of decorations when typing/editing near their edges. - * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` - */ -export enum TrackedRangeStickiness { - AlwaysGrowsWhenTypingAtEdges = 0, - NeverGrowsWhenTypingAtEdges = 1, - GrowsOnlyWhenTypingBefore = 2, - GrowsOnlyWhenTypingAfter = 3 -} - -export enum ScrollType { - Smooth = 0, - Immediate = 1 -} - -/** - * Describes the reason the cursor has changed its position. - */ -export enum CursorChangeReason { - /** - * Unknown or not set. - */ - NotSet = 0, - /** - * A `model.setValue()` was called. - */ - ContentFlush = 1, - /** - * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. - */ - RecoverFromMarkers = 2, - /** - * There was an explicit user gesture. - */ - Explicit = 3, - /** - * There was a Paste. - */ - Paste = 4, - /** - * There was an Undo. - */ - Undo = 5, - /** - * There was a Redo. - */ - Redo = 6 -} - -export enum RenderMinimap { - None = 0, - Text = 1, - Blocks = 2 -} - -/** - * A positioning preference for rendering content widgets. - */ -export enum ContentWidgetPositionPreference { - /** - * Place the content widget exactly at a position - */ - EXACT = 0, - /** - * Place the content widget above a position - */ - ABOVE = 1, - /** - * Place the content widget below a position - */ - BELOW = 2 -} - -/** - * A positioning preference for rendering overlay widgets. - */ -export enum OverlayWidgetPositionPreference { - /** - * Position the overlay widget in the top right corner - */ - TOP_RIGHT_CORNER = 0, - /** - * Position the overlay widget in the bottom right corner - */ - BOTTOM_RIGHT_CORNER = 1, - /** - * Position the overlay widget in the top center - */ - TOP_CENTER = 2 -} - -/** - * Type of hit element with the mouse in the editor. - */ -export enum MouseTargetType { - /** - * Mouse is on top of an unknown element. - */ - UNKNOWN = 0, - /** - * Mouse is on top of the textarea used for input. - */ - TEXTAREA = 1, + TEXTAREA = 1, /** * Mouse is on top of the glyph margin */ @@ -438,105 +592,76 @@ export enum MouseTargetType { } /** - * Describes what to do with the indentation when pressing Enter. + * A positioning preference for rendering overlay widgets. */ -export enum IndentAction { - /** - * Insert new line and copy the previous line's indentation. - */ - None = 0, +export enum OverlayWidgetPositionPreference { /** - * Insert new line and indent once (relative to the previous line's indentation). + * Position the overlay widget in the top right corner */ - Indent = 1, + TOP_RIGHT_CORNER = 0, /** - * Insert two new lines: - * - the first one indented which will hold the cursor - * - the second one at the same indentation level + * Position the overlay widget in the bottom right corner */ - IndentOutdent = 2, + BOTTOM_RIGHT_CORNER = 1, /** - * Insert new line and outdent once (relative to the previous line's indentation). + * Position the overlay widget in the top center */ - Outdent = 3 + TOP_CENTER = 2 } -export enum CompletionItemKind { - Method = 0, - Function = 1, - Constructor = 2, - Field = 3, - Variable = 4, - Class = 5, - Struct = 6, - Interface = 7, - Module = 8, - Property = 9, - Event = 10, - Operator = 11, - Unit = 12, - Value = 13, - Constant = 14, - Enum = 15, - EnumMember = 16, - Keyword = 17, - Text = 18, - Color = 19, - File = 20, - Reference = 21, - Customcolor = 22, - Folder = 23, - TypeParameter = 24, - Snippet = 25 +/** + * Vertical Lane in the overview ruler of the editor. + */ +export enum OverviewRulerLane { + Left = 1, + Center = 2, + Right = 4, + Full = 7 } -export enum CompletionItemTag { - Deprecated = 1 +export enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 } -export enum CompletionItemInsertTextRule { - /** - * Adjust whitespace/indentation of multiline insert texts to - * match the current line indentation. - */ - KeepWhitespace = 1, - /** - * `insertText` is a snippet. - */ - InsertAsSnippet = 4 +export enum RenderMinimap { + None = 0, + Text = 1, + Blocks = 2 } -/** - * How a suggest provider was triggered. - */ -export enum CompletionTriggerKind { - Invoke = 0, - TriggerCharacter = 1, - TriggerForIncompleteCompletions = 2 +export enum ScrollType { + Smooth = 0, + Immediate = 1 } -export enum SignatureHelpTriggerKind { - Invoke = 1, - TriggerCharacter = 2, - ContentChange = 3 +export enum ScrollbarVisibility { + Auto = 1, + Hidden = 2, + Visible = 3 } /** - * A document highlight kind. + * The direction of a selection. */ -export enum DocumentHighlightKind { - /** - * A textual occurrence. - */ - Text = 0, +export enum SelectionDirection { /** - * Read-access of a symbol, like reading a variable. + * The selection starts above where it ends. */ - Read = 1, + LTR = 0, /** - * Write-access of a symbol, like writing to a variable. + * The selection starts below where it ends. */ - Write = 2 + RTL = 1 +} + +export enum SignatureHelpTriggerKind { + Invoke = 1, + TriggerCharacter = 2, + ContentChange = 3 } /** @@ -573,4 +698,97 @@ export enum SymbolKind { export enum SymbolTag { Deprecated = 1 +} + +/** + * The kind of animation in which the editor's cursor should be rendered. + */ +export enum TextEditorCursorBlinkingStyle { + /** + * Hidden + */ + Hidden = 0, + /** + * Blinking + */ + Blink = 1, + /** + * Blinking with smooth fading + */ + Smooth = 2, + /** + * Blinking with prolonged filled state and smooth fading + */ + Phase = 3, + /** + * Expand collapse animation on the y axis + */ + Expand = 4, + /** + * No-Blinking + */ + Solid = 5 +} + +/** + * The style in which the editor's cursor should be rendered. + */ +export enum TextEditorCursorStyle { + /** + * As a vertical line (sitting between two characters). + */ + Line = 1, + /** + * As a block (sitting on top of a character). + */ + Block = 2, + /** + * As a horizontal line (sitting under a character). + */ + Underline = 3, + /** + * As a thin vertical line (sitting between two characters). + */ + LineThin = 4, + /** + * As an outlined block (sitting on top of a character). + */ + BlockOutline = 5, + /** + * As a thin horizontal line (sitting under a character). + */ + UnderlineThin = 6 +} + +/** + * Describes the behavior of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` + */ +export enum TrackedRangeStickiness { + AlwaysGrowsWhenTypingAtEdges = 0, + NeverGrowsWhenTypingAtEdges = 1, + GrowsOnlyWhenTypingBefore = 2, + GrowsOnlyWhenTypingAfter = 3 +} + +/** + * Describes how to indent wrapped lines. + */ +export enum WrappingIndent { + /** + * No indentation => wrapped lines begin at column 1. + */ + None = 0, + /** + * Same => wrapped lines get the same indentation as the parent. + */ + Same = 1, + /** + * Indent => wrapped lines get +1 indentation toward the parent. + */ + Indent = 2, + /** + * DeepIndent => wrapped lines get +2 indentation toward the parent. + */ + DeepIndent = 3 } \ No newline at end of file diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index 14e54cbb0bb36..65285eb9a2d2d 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -10,7 +10,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { OpenerService } from 'vs/editor/browser/services/openerService'; import { DiffNavigator, IDiffNavigator } from 'vs/editor/browser/widget/diffNavigator'; -import { ConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; +import { EditorOptions, ConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo'; import { Token } from 'vs/editor/common/core/token'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -346,19 +346,26 @@ export function createMonacoEditorAPI(): typeof monaco.editor { remeasureFonts: remeasureFonts, // enums - ScrollbarVisibility: standaloneEnums.ScrollbarVisibility, - OverviewRulerLane: standaloneEnums.OverviewRulerLane, - MinimapPosition: standaloneEnums.MinimapPosition, - EndOfLinePreference: standaloneEnums.EndOfLinePreference, + AccessibilitySupport: standaloneEnums.AccessibilitySupport, + ContentWidgetPositionPreference: standaloneEnums.ContentWidgetPositionPreference, + CursorChangeReason: standaloneEnums.CursorChangeReason, DefaultEndOfLine: standaloneEnums.DefaultEndOfLine, + EditorAutoIndentStrategy: standaloneEnums.EditorAutoIndentStrategy, + EditorOption: standaloneEnums.EditorOption, + EndOfLinePreference: standaloneEnums.EndOfLinePreference, EndOfLineSequence: standaloneEnums.EndOfLineSequence, - TrackedRangeStickiness: standaloneEnums.TrackedRangeStickiness, - CursorChangeReason: standaloneEnums.CursorChangeReason, + MinimapPosition: standaloneEnums.MinimapPosition, MouseTargetType: standaloneEnums.MouseTargetType, - ContentWidgetPositionPreference: standaloneEnums.ContentWidgetPositionPreference, OverlayWidgetPositionPreference: standaloneEnums.OverlayWidgetPositionPreference, + OverviewRulerLane: standaloneEnums.OverviewRulerLane, + RenderLineNumbersType: standaloneEnums.RenderLineNumbersType, RenderMinimap: standaloneEnums.RenderMinimap, + ScrollbarVisibility: standaloneEnums.ScrollbarVisibility, ScrollType: standaloneEnums.ScrollType, + TextEditorCursorBlinkingStyle: standaloneEnums.TextEditorCursorBlinkingStyle, + TextEditorCursorStyle: standaloneEnums.TextEditorCursorStyle, + TrackedRangeStickiness: standaloneEnums.TrackedRangeStickiness, + WrappingIndent: standaloneEnums.WrappingIndent, // classes ConfigurationChangedEvent: ConfigurationChangedEvent, @@ -369,6 +376,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { // vars EditorType: editorCommon.EditorType, + EditorOptions: EditorOptions }; } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 69028cf79fc19..68991ef8bd22d 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2472,6 +2472,15 @@ declare namespace monaco.editor { readonly reason: CursorChangeReason; } + export enum AccessibilitySupport { + /** + * This should be the browser case where it is not known if a screen reader is attached or no. + */ + Unknown = 0, + Disabled = 1, + Enabled = 2 + } + /** * Configuration options for auto closing quotes and brackets */ @@ -2487,6 +2496,17 @@ declare namespace monaco.editor { */ export type EditorAutoClosingOvertypeStrategy = 'always' | 'auto' | 'never'; + /** + * Configuration options for auto indentation in the editor + */ + export enum EditorAutoIndentStrategy { + None = 0, + Keep = 1, + Brackets = 2, + Advanced = 3, + Full = 4 + } + /** * Configuration options for the editor. */ @@ -3032,6 +3052,79 @@ declare namespace monaco.editor { export class ConfigurationChangedEvent { } + /** + * All computed editor options. + */ + export interface IComputedEditorOptions { + get(id: T): FindComputedEditorOptionValueById; + } + + export interface IEditorOption { + readonly id: K1; + readonly name: string; + defaultValue: V; + } + + /** + * The kind of animation in which the editor's cursor should be rendered. + */ + export enum TextEditorCursorBlinkingStyle { + /** + * Hidden + */ + Hidden = 0, + /** + * Blinking + */ + Blink = 1, + /** + * Blinking with smooth fading + */ + Smooth = 2, + /** + * Blinking with prolonged filled state and smooth fading + */ + Phase = 3, + /** + * Expand collapse animation on the y axis + */ + Expand = 4, + /** + * No-Blinking + */ + Solid = 5 + } + + /** + * The style in which the editor's cursor should be rendered. + */ + export enum TextEditorCursorStyle { + /** + * As a vertical line (sitting between two characters). + */ + Line = 1, + /** + * As a block (sitting on top of a character). + */ + Block = 2, + /** + * As a horizontal line (sitting under a character). + */ + Underline = 3, + /** + * As a thin vertical line (sitting between two characters). + */ + LineThin = 4, + /** + * As an outlined block (sitting on top of a character). + */ + BlockOutline = 5, + /** + * As a thin horizontal line (sitting under a character). + */ + UnderlineThin = 6 + } + /** * Configuration options for editor find widget */ @@ -3047,6 +3140,8 @@ declare namespace monaco.editor { addExtraSpaceOnTop?: boolean; } + export type EditorFindOptions = Readonly>; + export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto'; /** @@ -3066,6 +3161,8 @@ declare namespace monaco.editor { alternativeReferenceCommand?: string; } + export type GoToLocationOptions = Readonly>; + /** * Configuration options for editor hover */ @@ -3087,6 +3184,8 @@ declare namespace monaco.editor { sticky?: boolean; } + export type EditorHoverOptions = Readonly>; + /** * A description for the overview ruler position. */ @@ -3216,6 +3315,8 @@ declare namespace monaco.editor { enabled?: boolean; } + export type EditorLightbulbOptions = Readonly>; + /** * Configuration options for editor minimap */ @@ -3251,6 +3352,8 @@ declare namespace monaco.editor { scale?: number; } + export type EditorMinimapOptions = Readonly>; + /** * Configuration options for parameter hints */ @@ -3267,6 +3370,8 @@ declare namespace monaco.editor { cycle?: boolean; } + export type InternalParameterHintOptions = Readonly>; + /** * Configuration options for quick suggestions */ @@ -3276,8 +3381,23 @@ declare namespace monaco.editor { strings: boolean; } + export type ValidQuickSuggestionsOptions = boolean | Readonly>; + export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string); + export enum RenderLineNumbersType { + Off = 0, + On = 1, + Relative = 2, + Interval = 3, + Custom = 4 + } + + export interface InternalEditorRenderLineNumbersOptions { + readonly renderType: RenderLineNumbersType; + readonly renderFn: ((lineNumber: number) => string) | null; + } + /** * Configuration options for editor scrollbars */ @@ -3344,6 +3464,21 @@ declare namespace monaco.editor { horizontalSliderSize?: number; } + export interface InternalEditorScrollbarOptions { + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly alwaysConsumeMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; + } + /** * Configuration options for editor suggest widget */ @@ -3482,6 +3617,262 @@ declare namespace monaco.editor { showSnippets?: boolean; } + export type InternalSuggestOptions = Readonly>; + + /** + * Describes how to indent wrapped lines. + */ + export enum WrappingIndent { + /** + * No indentation => wrapped lines begin at column 1. + */ + None = 0, + /** + * Same => wrapped lines get the same indentation as the parent. + */ + Same = 1, + /** + * Indent => wrapped lines get +1 indentation toward the parent. + */ + Indent = 2, + /** + * DeepIndent => wrapped lines get +2 indentation toward the parent. + */ + DeepIndent = 3 + } + + export interface EditorWrappingInfo { + readonly isDominatedByLongLines: boolean; + readonly isWordWrapMinified: boolean; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + } + + export enum EditorOption { + acceptSuggestionOnCommitCharacter = 0, + acceptSuggestionOnEnter = 1, + accessibilitySupport = 2, + accessibilityPageSize = 3, + ariaLabel = 4, + autoClosingBrackets = 5, + autoClosingOvertype = 6, + autoClosingQuotes = 7, + autoIndent = 8, + automaticLayout = 9, + autoSurround = 10, + codeLens = 11, + colorDecorators = 12, + contextmenu = 13, + copyWithSyntaxHighlighting = 14, + cursorBlinking = 15, + cursorSmoothCaretAnimation = 16, + cursorStyle = 17, + cursorSurroundingLines = 18, + cursorSurroundingLinesStyle = 19, + cursorWidth = 20, + disableLayerHinting = 21, + disableMonospaceOptimizations = 22, + dragAndDrop = 23, + emptySelectionClipboard = 24, + extraEditorClassName = 25, + fastScrollSensitivity = 26, + find = 27, + fixedOverflowWidgets = 28, + folding = 29, + foldingStrategy = 30, + fontFamily = 31, + fontInfo = 32, + fontLigatures = 33, + fontSize = 34, + fontWeight = 35, + formatOnPaste = 36, + formatOnType = 37, + glyphMargin = 38, + gotoLocation = 39, + hideCursorInOverviewRuler = 40, + highlightActiveIndentGuide = 41, + hover = 42, + inDiffEditor = 43, + letterSpacing = 44, + lightbulb = 45, + lineDecorationsWidth = 46, + lineHeight = 47, + lineNumbers = 48, + lineNumbersMinChars = 49, + links = 50, + matchBrackets = 51, + minimap = 52, + mouseStyle = 53, + mouseWheelScrollSensitivity = 54, + mouseWheelZoom = 55, + multiCursorMergeOverlapping = 56, + multiCursorModifier = 57, + multiCursorPaste = 58, + occurrencesHighlight = 59, + overviewRulerBorder = 60, + overviewRulerLanes = 61, + parameterHints = 62, + quickSuggestions = 63, + quickSuggestionsDelay = 64, + readOnly = 65, + renderControlCharacters = 66, + renderIndentGuides = 67, + renderFinalNewline = 68, + renderLineHighlight = 69, + renderWhitespace = 70, + revealHorizontalRightPadding = 71, + roundedSelection = 72, + rulers = 73, + scrollbar = 74, + scrollBeyondLastColumn = 75, + scrollBeyondLastLine = 76, + selectionClipboard = 77, + selectionHighlight = 78, + selectOnLineNumbers = 79, + showFoldingControls = 80, + showUnused = 81, + snippetSuggestions = 82, + smoothScrolling = 83, + stopRenderingLineAfter = 84, + suggest = 85, + suggestFontSize = 86, + suggestLineHeight = 87, + suggestOnTriggerCharacters = 88, + suggestSelection = 89, + tabCompletion = 90, + useTabStops = 91, + wordSeparators = 92, + wordWrap = 93, + wordWrapBreakAfterCharacters = 94, + wordWrapBreakBeforeCharacters = 95, + wordWrapBreakObtrusiveCharacters = 96, + wordWrapColumn = 97, + wordWrapMinified = 98, + wrappingIndent = 99, + editorClassName = 100, + pixelRatio = 101, + tabFocusMode = 102, + layoutInfo = 103, + wrappingInfo = 104 + } + export const EditorOptions: { + acceptSuggestionOnCommitCharacter: IEditorOption; + acceptSuggestionOnEnter: IEditorOption; + accessibilitySupport: IEditorOption; + accessibilityPageSize: IEditorOption; + ariaLabel: IEditorOption; + autoClosingBrackets: IEditorOption; + autoClosingOvertype: IEditorOption; + autoClosingQuotes: IEditorOption; + autoIndent: IEditorOption; + automaticLayout: IEditorOption; + autoSurround: IEditorOption; + codeLens: IEditorOption; + colorDecorators: IEditorOption; + contextmenu: IEditorOption; + copyWithSyntaxHighlighting: IEditorOption; + cursorBlinking: IEditorOption; + cursorSmoothCaretAnimation: IEditorOption; + cursorStyle: IEditorOption; + cursorSurroundingLines: IEditorOption; + cursorSurroundingLinesStyle: IEditorOption; + cursorWidth: IEditorOption; + disableLayerHinting: IEditorOption; + disableMonospaceOptimizations: IEditorOption; + dragAndDrop: IEditorOption; + emptySelectionClipboard: IEditorOption; + extraEditorClassName: IEditorOption; + fastScrollSensitivity: IEditorOption; + find: IEditorOption; + fixedOverflowWidgets: IEditorOption; + folding: IEditorOption; + foldingStrategy: IEditorOption; + fontFamily: IEditorOption; + fontInfo: IEditorOption; + fontLigatures2: IEditorOption; + fontSize: IEditorOption; + fontWeight: IEditorOption; + formatOnPaste: IEditorOption; + formatOnType: IEditorOption; + glyphMargin: IEditorOption; + gotoLocation: IEditorOption; + hideCursorInOverviewRuler: IEditorOption; + highlightActiveIndentGuide: IEditorOption; + hover: IEditorOption; + inDiffEditor: IEditorOption; + letterSpacing: IEditorOption; + lightbulb: IEditorOption; + lineDecorationsWidth: IEditorOption; + lineHeight: IEditorOption; + lineNumbers: IEditorOption; + lineNumbersMinChars: IEditorOption; + links: IEditorOption; + matchBrackets: IEditorOption; + minimap: IEditorOption; + mouseStyle: IEditorOption; + mouseWheelScrollSensitivity: IEditorOption; + mouseWheelZoom: IEditorOption; + multiCursorMergeOverlapping: IEditorOption; + multiCursorModifier: IEditorOption; + multiCursorPaste: IEditorOption; + occurrencesHighlight: IEditorOption; + overviewRulerBorder: IEditorOption; + overviewRulerLanes: IEditorOption; + parameterHints: IEditorOption; + quickSuggestions: IEditorOption; + quickSuggestionsDelay: IEditorOption; + readOnly: IEditorOption; + renderControlCharacters: IEditorOption; + renderIndentGuides: IEditorOption; + renderFinalNewline: IEditorOption; + renderLineHighlight: IEditorOption; + renderWhitespace: IEditorOption; + revealHorizontalRightPadding: IEditorOption; + roundedSelection: IEditorOption; + rulers: IEditorOption; + scrollbar: IEditorOption; + scrollBeyondLastColumn: IEditorOption; + scrollBeyondLastLine: IEditorOption; + selectionClipboard: IEditorOption; + selectionHighlight: IEditorOption; + selectOnLineNumbers: IEditorOption; + showFoldingControls: IEditorOption; + showUnused: IEditorOption; + snippetSuggestions: IEditorOption; + smoothScrolling: IEditorOption; + stopRenderingLineAfter: IEditorOption; + suggest: IEditorOption; + suggestFontSize: IEditorOption; + suggestLineHeight: IEditorOption; + suggestOnTriggerCharacters: IEditorOption; + suggestSelection: IEditorOption; + tabCompletion: IEditorOption; + useTabStops: IEditorOption; + wordSeparators: IEditorOption; + wordWrap: IEditorOption; + wordWrapBreakAfterCharacters: IEditorOption; + wordWrapBreakBeforeCharacters: IEditorOption; + wordWrapBreakObtrusiveCharacters: IEditorOption; + wordWrapColumn: IEditorOption; + wordWrapMinified: IEditorOption; + wrappingIndent: IEditorOption; + editorClassName: IEditorOption; + pixelRatio: IEditorOption; + tabFocusMode: IEditorOption; + layoutInfo: IEditorOption; + wrappingInfo: IEditorOption; + }; + + type EditorOptionsType = typeof EditorOptions; + + type FindEditorOptionsKeyById = { + [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never; + }[keyof EditorOptionsType]; + + type ComputedEditorOptionValue> = T extends IEditorOption ? R : never; + + export type FindComputedEditorOptionValueById = NonNullable]>>; + /** * A view zone is a full horizontal rectangle that 'pushes' text down. * The editor reserves space for view zones when rendering. @@ -3932,6 +4323,14 @@ declare namespace monaco.editor { * It is safe to call setModel(null) to simply detach the current model from the editor. */ setModel(model: ITextModel | null): void; + /** + * Gets all the editor computed options. + */ + getOptions(): IComputedEditorOptions; + /** + * Gets a specific editor option. + */ + getOption(id: T): FindComputedEditorOptionValueById; /** * Returns the editor's configuration (without any validation or defaults). */ @@ -5683,4 +6082,4 @@ declare namespace monaco.worker { } -//dtsv=2 +//dtsv=3