diff --git a/CHANGELOG.md b/CHANGELOG.md index 45f261bb..9ff16a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,73 @@ # Monaco Editor Changelog +## [0.15.0] (12.11.2018) + +### New & Noteworthy + +* Improved typings in `monaco.d.ts` to better reflect null types. + +### Breaking changes + +* We are slowly migrating our code-base away from WinJS promises, so the exposed `monaco.Promise` API has been reduced to indicate that. We are setting up a Promise polyfill to cover browsers which do not have a native Promise implementation yet (i.e. IE11). +* `CompletionItemProvider.provideCompletionItems` and `CompletionItemProvider.resolveCompletionItem` have been modified to better reflect the API of VS Code. Both arguments and return type have changed. +* `SignatureHelpProvider.provideSignatureHelp` now receives an extra argument for the context. +* Various new editor options or tweaks to existing ones: `parameterHints`, `autoClosingBrackets`, `autoClosingQuotes`, `autoSurround`, `copyWithSyntaxHighlighting`, `tabCompletion`. + +### Thank you + +Contributions to `monaco-editor`: + +* [Arvind S (@arvind0598)](https://github.com/arvind0598): Updated C# sample code for a simpler game. [PR #1160](https://github.com/Microsoft/monaco-editor/pull/1160) +* [Brooks Becton (@brooksbecton)](https://github.com/brooksbecton): Removing obsolete Note in Monarch Docs [PR #1089](https://github.com/Microsoft/monaco-editor/pull/1089) +* [James Orr (@buzzcola)](https://github.com/buzzcola): Correct comma splice in README.md [PR #1111](https://github.com/Microsoft/monaco-editor/pull/1111) +* [Chintogtokh Batbold (@chintogtokh)](https://github.com/chintogtokh): Clarify that repo doesn't contain source code [PR #1119](https://github.com/Microsoft/monaco-editor/pull/1119) +* [Chris Helgert (@chrishelgert)](https://github.com/chrishelgert): Move issue template to '.github' folder and add some styling for better readability [PR #1121](https://github.com/Microsoft/monaco-editor/pull/1121) +* [Steven Bock (@dabockster)](https://github.com/dabockster): Added better Java sample (FizzBuzz instead of JUnit) [PR #1161](https://github.com/Microsoft/monaco-editor/pull/1161) +* [Michele Gobbi (@dynamick)](https://github.com/dynamick): Added Ruby [PR #1102](https://github.com/Microsoft/monaco-editor/pull/1102) +* [Edilson Ngulele (@EdNgulele)](https://github.com/EdNgulele): style: Updated CONTRIBUTING.md [PR #1088](https://github.com/Microsoft/monaco-editor/pull/1088) +* [Evan Walters (@evanwaltersdev)](https://github.com/evanwaltersdev): issue guidelines [PR #1096](https://github.com/Microsoft/monaco-editor/pull/1096) +* [Abdussalam Abdurrahman (@finalfantasia)](https://github.com/finalfantasia): [clojure] Update Clojure example with one that's more representative. [PR #1059](https://github.com/Microsoft/monaco-editor/pull/1059) +* [@flash76](https://github.com/flash76): Update README.md [PR #1141](https://github.com/Microsoft/monaco-editor/pull/1141) +* [Daniel Pasch (@gempir)](https://github.com/gempir): fix 2 of 7 npm package vurnerabilities [PR #1087](https://github.com/Microsoft/monaco-editor/pull/1087) +* [@Hotlar](https://github.com/Hotlar): lingual fixes to readme [PR #1086](https://github.com/Microsoft/monaco-editor/pull/1086) +* [Jeremy Meiss (@jerdog)](https://github.com/jerdog): correct README grammar [PR #1114](https://github.com/Microsoft/monaco-editor/pull/1114) +* [Joaquim Honório (@JoaquimCMH)](https://github.com/JoaquimCMH): Update CHANGELOG [PR #1152](https://github.com/Microsoft/monaco-editor/pull/1152) +* [Ricardo Ambrogi (@KadoBOT)](https://github.com/KadoBOT): Remove commented code [PR #1113](https://github.com/Microsoft/monaco-editor/pull/1113) +* [Abhinav Srivastava (@krototype)](https://github.com/krototype): changed the license block of readme [PR #1133](https://github.com/Microsoft/monaco-editor/pull/1133) +* [Mera Gangapersaud (@Mera-Gangapersaud)](https://github.com/Mera-Gangapersaud): Fixed prerequisites link in Contributing.md [PR #1155](https://github.com/Microsoft/monaco-editor/pull/1155) +* [Michael (@michael-k)](https://github.com/michael-k): Use python examples that work [PR #1053](https://github.com/Microsoft/monaco-editor/pull/1053) +* [Remy Suen (@rcjsuen)](https://github.com/rcjsuen): Add missing links in CHANGELOG.md [PR #1029](https://github.com/Microsoft/monaco-editor/pull/1029) +* [Shivansh Saini (@shivanshs9)](https://github.com/shivanshs9): Fixed typos in website page and CHANGELOG [PR #1153](https://github.com/Microsoft/monaco-editor/pull/1153) +* [Sachin Saini (@thetinygoat)](https://github.com/thetinygoat): hacktoberfest fix [PR #1131](https://github.com/Microsoft/monaco-editor/pull/1131) + +Contributions to `monaco-languages`: + +* [Aastha (@AasthaGupta)](https://github.com/AasthaGupta): Fix markdown bug #1107 [PR #52](https://github.com/Microsoft/monaco-languages/pull/52) +* [Abdussalam Abdurrahman (@finalfantasia)](https://github.com/finalfantasia): [clojure] Improve Clojure syntax highlighting. [PR #45](https://github.com/Microsoft/monaco-languages/pull/45) +* [Abhishek (@GeekAb)](https://github.com/GeekAb): Markdown bug fix for #1107 [PR #51](https://github.com/Microsoft/monaco-languages/pull/51) +* [Matthew D. Miller (@goober99)](https://github.com/goober99): Added support for Perl quote-like operators to fix #1101 [PR #50](https://github.com/Microsoft/monaco-languages/pull/50) +* [Grzegorz Wcisło (@grzegorz-wcislo)](https://github.com/grzegorz-wcislo): Fix yaml string tokenization [PR #47](https://github.com/Microsoft/monaco-languages/pull/47) +* [Pascal Berger (@pascalberger)](https://github.com/pascalberger): Use C# highlighting for Cake scripts [PR #53](https://github.com/Microsoft/monaco-languages/pull/53) +* [Sebastian Pahnke (@spahnke)](https://github.com/spahnke) + * [JS/TS] Add support for alternative octal integer literal syntax [PR #49](https://github.com/Microsoft/monaco-languages/pull/49) + * Improve tokenization of regular expressions [PR #46](https://github.com/Microsoft/monaco-languages/pull/46) +* [Tiago Danin (@TiagoDanin)](https://github.com/TiagoDanin): New rule for non-teminated string in yaml [PR #48](https://github.com/Microsoft/monaco-languages/pull/48) + +Contributions to `monaco-typescript`: + +* [Parikshit Hooda (@Parikshit-Hooda)](https://github.com/Parikshit-Hooda): fixed typo in line 11 [PR #23](https://github.com/Microsoft/monaco-typescript/pull/23) +* [Sebastian Pahnke (@spahnke)](https://github.com/spahnke): Render documentation in suggestion widget as Markdown [PR #22](https://github.com/Microsoft/monaco-typescript/pull/22) + +Contributions to `monaco-json`: + +* [Igor Nesterenko (@nesterone)](https://github.com/nesterone): Provide diagnostic option to enable on-demand schema loading [PR #7](https://github.com/Microsoft/monaco-json/pull/7) + +Contributions to `monaco-css`: + +* [Richard Samuelson (@ricsam)](https://github.com/ricsam): Fix indentation on the CSS test page [PR #7](https://github.com/Microsoft/monaco-css/pull/7) + + + ## [0.14.3] (17.08.2018) * Fixes TypeScript/JavaScript coloring of regular expressions https://github.com/Microsoft/monaco-editor/issues/1009 diff --git a/monaco.d.ts b/monaco.d.ts index 078891c8..439949b1 100644 --- a/monaco.d.ts +++ b/monaco.d.ts @@ -30,44 +30,26 @@ declare namespace monaco { dispose(): void; } + export enum MarkerTag { - Unnecessary = 1, + Unnecessary = 1 } export enum MarkerSeverity { Hint = 1, Info = 2, Warning = 4, - Error = 8, + Error = 8 } - - - export type TValueCallback = (value: T | PromiseLike) => void; - - export type ProgressCallback = (progress: TProgress) => void; - - - export class Promise { - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason: any) => void, - progress: (progress: TProgress) => void) => void, - oncancel?: () => void); + export class Promise { + constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason: any) => void) => void); public then( onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: any) => TResult2 | PromiseLike) | null, - onprogress?: (progress: TProgress) => void): Promise; + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; - public done( - onfulfilled?: (value: T) => void, - onrejected?: (reason: any) => void, - onprogress?: (progress: TProgress) => void): void; - - public cancel(): void; public static as(value: null): Promise; public static as(value: undefined): Promise; @@ -75,15 +57,9 @@ declare namespace monaco { public static as>(value: SomePromise): SomePromise; public static as(value: T): Promise; - public static is(value: any): value is PromiseLike; - - public static timeout(delay: number): Promise; - public static join(promises: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; public static join(promises: (T | PromiseLike)[]): Promise; - public static any(promises: (T | PromiseLike)[]): Promise<{ key: string; value: Promise; }>; - public static wrap(value: T | PromiseLike): Promise; public static wrapError(error: Error): Promise; @@ -103,9 +79,10 @@ declare namespace monaco { */ readonly onCancellationRequested: IEvent; } + /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. - * This class is a simple parser which creates the basic component paths + * This class is a simple parser which creates the basic component parts * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation * and encoding. * @@ -116,8 +93,6 @@ declare namespace monaco { * | _____________________|__ * / \ / \ * urn:example:animal:ferret:nose - * - * */ export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; @@ -145,28 +120,80 @@ declare namespace monaco { readonly fragment: string; /** * Returns a string representing the corresponding file system path of this Uri. - * Will handle UNC paths and normalize windows drive letters to lower-case. Also - * uses the platform specific path separator. Will *not* validate the path for - * invalid characters and semantics. Will *not* look at the scheme of this Uri. + * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the + * platform specific path separator. + * + * * Will *not* validate the path for invalid characters and semantics. + * * Will *not* look at the scheme of this Uri. + * * The result shall *not* be used for display purposes but for accessing a file on disk. + * + * + * The *difference* to `Uri#path` is the use of the platform specific separator and the handling + * of UNC paths. See the below sample of a file-uri with an authority (UNC path). + * + * ```ts + const u = Uri.parse('file://server/c$/folder/file.txt') + u.authority === 'server' + u.path === '/shares/c$/file.txt' + u.fsPath === '\\server\c$\folder\file.txt' + ``` + * + * Using `Uri#path` to read a file (using fs-apis) would not be enough because parts of the path, + * namely the server name, would be missing. Therefore `Uri#fsPath` exists - it's sugar to ease working + * with URIs that represent files on disk (`file` scheme). */ readonly fsPath: string; with(change: { scheme?: string; - authority?: string; - path?: string; - query?: string; - fragment?: string; + authority?: string | null; + path?: string | null; + query?: string | null; + fragment?: string | null; }): Uri; + /** + * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, + * `file:///usr/home`, or `scheme:with/path`. + * + * @param value A string which represents an Uri (see `Uri#toString`). + */ static parse(value: string): Uri; + /** + * Creates a new Uri from a file system path, e.g. `c:\my\files`, + * `/usr/home`, or `\\server\share\some\path`. + * + * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument + * as path, not as stringified-uri. E.g. `Uri.file(path)` is **not the same as** + * `Uri.parse('file://' + path)` because the path might contain characters that are + * interpreted (# and ?). See the following sample: + * ```ts + const good = Uri.file('/coding/c#/project1'); + good.scheme === 'file'; + good.path === '/coding/c#/project1'; + good.fragment === ''; + const bad = Uri.parse('file://' + '/coding/c#/project1'); + bad.scheme === 'file'; + bad.path === '/coding/c'; // path is now broken + bad.fragment === '/project1'; + ``` + * + * @param path A file system path (see `Uri#fsPath`) + */ static file(path: string): Uri; static from(components: { - scheme?: string; + scheme: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; /** + * Creates a string presentation for this Uri. It's guaranteed that calling + * `Uri.parse` with the result of this function creates an Uri which is equal + * to this Uri. + * + * * The result shall *not* be used for display purposes but for externalization or transport. + * * The result will be encoded using the percentage encoding and encoding happens mostly + * ignore the scheme-specific encoding rules. * * @param skipEncoding Do not encode the result, default is `false` */ @@ -363,7 +390,6 @@ declare namespace monaco { */ MAX_VALUE = 112 } - export class KeyMod { static readonly CtrlCmd: number; static readonly Shift: number; @@ -444,6 +470,20 @@ declare namespace monaco { */ readonly column: number; constructor(lineNumber: number, column: number); + /** + * Create a new postion from this position. + * + * @param newLineNumber new line number + * @param newColumn new column + */ + with(newLineNumber?: number, newColumn?: number): Position; + /** + * Derive a new position from this position. + * + * @param deltaLineNumber line number delta + * @param deltaColumn column delta + */ + delta(deltaLineNumber?: number, deltaColumn?: number): Position; /** * Test if this position equals other position */ @@ -574,19 +614,19 @@ declare namespace monaco { /** * A intersection of the two ranges. */ - intersectRanges(range: IRange): Range; + intersectRanges(range: IRange): Range | null; /** * A intersection of the two ranges. */ - static intersectRanges(a: IRange, b: IRange): Range; + static intersectRanges(a: IRange, b: IRange): Range | null; /** * Test if this range equals other. */ - equalsRange(other: IRange): boolean; + equalsRange(other: IRange | null): boolean; /** * Test if range `a` equals `b`. */ - static equalsRange(a: IRange, b: IRange): boolean; + static equalsRange(a: IRange | null, b: IRange | null): boolean; /** * Return the end position (which will be after or equal to the start position) */ @@ -619,6 +659,7 @@ declare namespace monaco { /** * Create a `Range` from an `IRange`. */ + static lift(range: undefined | null): null; static lift(range: IRange): Range; /** * Test if `obj` is an `IRange`. @@ -636,7 +677,7 @@ declare namespace monaco { * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the startPosition and then on the endPosition */ - static compareRangesUsingStarts(a: IRange, b: IRange): number; + static compareRangesUsingStarts(a: IRange | null | undefined, b: IRange | null | undefined): number; /** * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the endPosition and then on the startPosition @@ -840,7 +881,7 @@ declare namespace monaco.editor { /** * Get the model that has `uri` if it exists. */ - export function getModel(uri: Uri): ITextModel; + export function getModel(uri: Uri): ITextModel | null; /** * Get all the created models. @@ -895,7 +936,7 @@ declare namespace monaco.editor { export function tokenize(text: string, languageId: string): Token[][]; /** - * Define a new theme or updte an existing theme. + * Define a new theme or update an existing theme. */ export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; @@ -1000,7 +1041,7 @@ declare namespace monaco.editor { contextMenuOrder?: number; /** * Method that will be executed when the action is triggered. - * @param editor The editor instance is passed in as a convinience + * @param editor The editor instance is passed in as a convenience */ run(editor: ICodeEditor): void | Promise; } @@ -1053,13 +1094,13 @@ declare namespace monaco.editor { } export interface IStandaloneCodeEditor extends ICodeEditor { - addCommand(keybinding: number, handler: ICommandHandler, context: string): string; + addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null; createContextKey(key: string, defaultValue: T): IContextKey; addAction(descriptor: IActionDescriptor): IDisposable; } export interface IStandaloneDiffEditor extends IDiffEditor { - addCommand(keybinding: number, handler: ICommandHandler, context: string): string; + addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null; createContextKey(key: string, defaultValue: T): IContextKey; addAction(descriptor: IActionDescriptor): IDisposable; getOriginalEditor(): IStandaloneCodeEditor; @@ -1072,7 +1113,7 @@ declare namespace monaco.editor { export interface IContextKey { set(value: T): void; reset(): void; - get(): T; + get(): T | undefined; } export interface IEditorOverrideServices { @@ -1159,17 +1200,12 @@ declare namespace monaco.editor { * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - color: string | ThemeColor; + color: string | ThemeColor | undefined; /** * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - darkColor: string | ThemeColor; - /** - * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry - */ - hcColor?: string | ThemeColor; + darkColor?: string | ThemeColor; /** * The position in the overview ruler. */ @@ -1188,15 +1224,15 @@ declare namespace monaco.editor { /** * CSS class name describing the decoration. */ - className?: string; + className?: string | null; /** * Message to be rendered when hovering over the glyph margin decoration. */ - glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[]; + glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Array of MarkdownString to render as the decoration message. */ - hoverMessage?: IMarkdownString | IMarkdownString[]; + hoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Should the decoration expand to encompass a whole line. */ @@ -1209,25 +1245,25 @@ declare namespace monaco.editor { /** * If set, render this decoration in the overview ruler. */ - overviewRuler?: IModelDecorationOverviewRulerOptions; + overviewRuler?: IModelDecorationOverviewRulerOptions | null; /** * If set, the decoration will be rendered in the glyph margin with this CSS class name. */ - glyphMarginClassName?: string; + glyphMarginClassName?: string | null; /** * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ - linesDecorationsClassName?: string; + linesDecorationsClassName?: string | null; /** * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. */ - marginClassName?: string; + marginClassName?: string | null; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` * to have a background color decoration. */ - inlineClassName?: string; + inlineClassName?: string | null; /** * If there is an `inlineClassName` which affects letter spacing. */ @@ -1235,11 +1271,11 @@ declare namespace monaco.editor { /** * If set, the decoration will be rendered before the text with this CSS class name. */ - beforeContentClassName?: string; + beforeContentClassName?: string | null; /** * If set, the decoration will be rendered after the text with this CSS class name. */ - afterContentClassName?: string; + afterContentClassName?: string | null; } /** @@ -1265,7 +1301,7 @@ declare namespace monaco.editor { */ readonly id: string; /** - * Identifier for a decoration's owener. + * Identifier for a decoration's owner. */ readonly ownerId: number; /** @@ -1387,7 +1423,7 @@ declare namespace monaco.editor { /** * The text to replace with. This can be null to emulate a simple delete. */ - text: string; + text: string | null; /** * This indicates that this operation has "insert" semantics. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved. @@ -1402,7 +1438,7 @@ declare namespace monaco.editor { /** * A callback that can compute the resulting cursors state after some edit operations have been executed. */ - (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; + (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[] | null; } export class TextModelResolvedOptions { @@ -1422,7 +1458,7 @@ declare namespace monaco.editor { export class FindMatch { _findMatchBrand: void; readonly range: Range; - readonly matches: string[]; + readonly matches: string[] | null; } /** @@ -1536,13 +1572,13 @@ declare namespace monaco.editor { */ validatePosition(position: IPosition): Position; /** - * Advances the given position by the given offest (negative offsets are also accepted) + * Advances the given position by the given offset (negative offsets are also accepted) * and returns it as a new valid position. * * If the offset and position are such that their combination goes beyond the beginning or * end of the model, throws an exception. * - * If the ofsset is such that the new position would be in the middle of a multi-byte + * If the offset is such that the new position would be in the middle of a multi-byte * line terminator, throws an exception. */ modifyPosition(position: IPosition, offset: number): Position; @@ -1608,7 +1644,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the next match is. It is null if no next match has been found. */ - findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Search the model for the previous match. Loops to the end of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. @@ -1619,7 +1655,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the previous match is. It is null if no previous match has been found. */ - findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Get the language associated with this model. */ @@ -1627,37 +1663,17 @@ declare namespace monaco.editor { /** * Get the word under or besides `position`. * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Might be null. */ - getWordAtPosition(position: IPosition): IWordAtPosition; + getWordAtPosition(position: IPosition): IWordAtPosition | null; /** * Get the word under or besides `position` trimmed to `position`.column * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; /** - * Get the language associated with this model. - */ - getModeId(): string; - /** - * Get the word under or besides `position`. - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Might be null. - */ - getWordAtPosition(position: IPosition): IWordAtPosition; - /** - * Get the word under or besides `position` trimmed to `position`.column - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Will never be null. - */ - getWordUntilPosition(position: IPosition): IWordAtPosition; - /** - * Perform a minimum ammount of operations, in order to transform the decorations + * Perform a minimum amount of operations, in order to transform the decorations * identified by `oldDecorations` to the decorations described by `newDecorations` * and returns the new identifiers associated with the resulting decorations. * @@ -1672,13 +1688,13 @@ declare namespace monaco.editor { * @param id The decoration id. * @return The decoration options or null if the decoration was not found. */ - getDecorationOptions(id: string): IModelDecorationOptions; + getDecorationOptions(id: string): IModelDecorationOptions | null; /** * Get the range associated with a decoration. * @param id The decoration id. * @return The decoration range or null if the decoration was not found. */ - getDecorationRange(id: string): Range; + getDecorationRange(id: string): Range | null; /** * Gets all the decorations for the line `lineNumber` as an array. * @param lineNumber The line number @@ -1697,7 +1713,7 @@ declare namespace monaco.editor { */ getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]; /** - * Gets all the deocorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. + * Gets all the decorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. * So for now it returns all the decorations on the same line as `range`. * @param range The range to search in * @param ownerId If set, it will ignore decorations belonging to other owners. @@ -1742,12 +1758,12 @@ declare namespace monaco.editor { /** * Push edit operations, basically editing the model. This is the preferred way * of editing the model. The edit operations will land on the undo stack. - * @param beforeCursorState The cursor state before the edit operaions. This cursor state will be returned when `undo` or `redo` are invoked. + * @param beforeCursorState The cursor state before the edit operations. This cursor state will be returned when `undo` or `redo` are invoked. * @param editOperations The edit operations. * @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed. * @return The cursor state returned by the `cursorStateComputer`. */ - pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[]; + pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[] | null; /** * Change the end of line sequence. This is the preferred way of * changing the eol sequence. This will land on the undo stack. @@ -1811,14 +1827,14 @@ declare namespace monaco.editor { * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addEditOperation(range: Range, text: string): void; + addEditOperation(range: Range, text: string | null): void; /** * Add a new edit operation (a replace operation). * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()` * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addTrackedEditOperation(range: Range, text: string): void; + addTrackedEditOperation(range: Range, text: string | null): void; /** * Track `selection` when applying edit operations. * A best effort will be made to not grow/expand the selection. @@ -1826,7 +1842,7 @@ declare namespace monaco.editor { * @param selection The selection to track. * @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection * should clamp to the previous or the next character. - * @return A unique identifer. + * @return A unique identifier. */ trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string; } @@ -1859,7 +1875,7 @@ declare namespace monaco.editor { getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void; /** * Compute the cursor state after the edit operations were applied. - * @param model The model the commad has executed on. + * @param model The model the command has executed on. * @param helper A helper to get inverse edit operations and to get previously tracked selections. * @return The cursor state after the command executed. */ @@ -1887,11 +1903,11 @@ declare namespace monaco.editor { /** * The `uri` of the previous model or null. */ - readonly oldModelUrl: Uri; + readonly oldModelUrl: Uri | null; /** * The `uri` of the new model or null. */ - readonly newModelUrl: Uri; + readonly newModelUrl: Uri | null; } export interface IDimension { @@ -1923,7 +1939,7 @@ declare namespace monaco.editor { * A line change */ export interface ILineChange extends IChange { - readonly charChanges: ICharChange[]; + readonly charChanges: ICharChange[] | undefined; } export interface INewScrollPosition { @@ -1987,7 +2003,7 @@ declare namespace monaco.editor { */ export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState; - export const enum ScrollType { + export enum ScrollType { Smooth = 0, Immediate = 1 } @@ -2038,7 +2054,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IEditorViewState; + saveViewState(): IEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -2050,7 +2066,7 @@ declare namespace monaco.editor { /** * Returns the primary position of the cursor. */ - getPosition(): Position; + getPosition(): Position | null; /** * Set the primary position of the cursor. This will remove any secondary cursors. * @param position New primary cursor's position @@ -2083,11 +2099,11 @@ declare namespace monaco.editor { /** * Returns the primary selection of the editor. */ - getSelection(): Selection; + getSelection(): Selection | null; /** * Returns all the selections of the editor. */ - getSelections(): Selection[]; + getSelections(): Selection[] | null; /** * Set the primary selection of the editor. This will remove any secondary cursors. * @param selection The new selection @@ -2377,16 +2393,14 @@ declare namespace monaco.editor { arrowSize?: number; /** * Render vertical scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - vertical?: string; + vertical?: 'auto' | 'visible' | 'hidden'; /** * Render horizontal scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - horizontal?: string; + horizontal?: 'auto' | 'visible' | 'hidden'; /** * Cast horizontal and vertical shadows when the content is scrolled. * Defaults to true. @@ -2443,13 +2457,23 @@ declare namespace monaco.editor { autoFindInSelection: boolean; } + /** + * Configuration options for auto closing quotes and brackets + */ + export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'; + + /** + * Configuration options for auto wrapping quotes and brackets + */ + export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never'; + /** * Configuration options for editor minimap */ export interface IEditorMinimapOptions { /** * Enable the rendering of the minimap. - * Defaults to false. + * Defaults to true. */ enabled?: boolean; /** @@ -2506,6 +2530,22 @@ declare namespace monaco.editor { sticky?: boolean; } + /** + * Configuration options for parameter hints + */ + export interface IEditorParameterHintOptions { + /** + * Enable parameter hints. + * Defaults to true. + */ + enabled?: boolean; + /** + * Enable cycling of parameter hints. + * Defaults to false. + */ + cycle?: boolean; + } + export interface ISuggestOptions { /** * Enable graceful matching. Defaults to true. @@ -2515,6 +2555,10 @@ declare namespace monaco.editor { * Prevent quick suggestions when a snippet is active. Defaults to true. */ snippetsPreventQuickSuggestions?: boolean; + /** + * Favours words that appear close to the cursor. + */ + localityBonus?: boolean; } /** @@ -2791,19 +2835,29 @@ declare namespace monaco.editor { */ quickSuggestionsDelay?: number; /** - * Enables parameter hints + * Parameter hint options. */ - parameterHints?: boolean; + parameterHints?: IEditorParameterHintOptions; /** * Render icons in suggestions box. * Defaults to true. */ iconsInSuggestions?: boolean; /** - * Enable auto closing brackets. - * Defaults to true. + * Options for auto closing brackets. + * Defaults to language defined behavior. */ - autoClosingBrackets?: boolean; + autoClosingBrackets?: EditorAutoClosingStrategy; + /** + * Options for auto closing quotes. + * Defaults to language defined behavior. + */ + autoClosingQuotes?: EditorAutoClosingStrategy; + /** + * Options for auto surrounding. + * Defaults to always allowing auto surrounding. + */ + autoSurround?: EditorAutoSurroundStrategy; /** * Enable auto indentation adjustment. * Defaults to false. @@ -2847,6 +2901,10 @@ declare namespace monaco.editor { * Copying without a selection copies the current line. */ emptySelectionClipboard?: boolean; + /** + * Syntax highlighting is copied. + */ + copyWithSyntaxHighlighting?: boolean; /** * Enable word based suggestions. Defaults to 'true' */ @@ -2865,6 +2923,10 @@ declare namespace monaco.editor { * Defaults to the editor line height. */ suggestLineHeight?: number; + /** + * Enable tab completion. + */ + tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets'; /** * Enable selection highlight. * Defaults to true. @@ -3126,6 +3188,12 @@ declare namespace monaco.editor { readonly filterGraceful: boolean; readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + } + + export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; } export interface EditorWrappingInfo { @@ -3140,7 +3208,7 @@ declare namespace monaco.editor { readonly wordWrapBreakObtrusiveCharacters: string; } - export const enum RenderLineNumbersType { + export enum RenderLineNumbersType { Off = 0, On = 1, Relative = 2, @@ -3154,7 +3222,7 @@ declare namespace monaco.editor { readonly rulers: number[]; readonly ariaLabel: string; readonly renderLineNumbers: RenderLineNumbersType; - readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -3192,7 +3260,7 @@ declare namespace monaco.editor { strings: boolean; }; readonly quickSuggestionsDelay: number; - readonly parameterHints: boolean; + readonly parameterHints: InternalParameterHintOptions; readonly iconsInSuggestions: boolean; readonly formatOnType: boolean; readonly formatOnPaste: boolean; @@ -3203,6 +3271,7 @@ declare namespace monaco.editor { readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; + readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; readonly suggest: InternalSuggestOptions; readonly selectionHighlight: boolean; readonly occurrencesHighlight: boolean; @@ -3232,12 +3301,15 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly showUnused: boolean; readonly wordSeparators: string; - readonly autoClosingBrackets: boolean; + readonly autoClosingBrackets: EditorAutoClosingStrategy; + readonly autoClosingQuotes: EditorAutoClosingStrategy; + readonly autoSurround: EditorAutoSurroundStrategy; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; @@ -3371,11 +3443,14 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; readonly autoClosingBrackets: boolean; + readonly autoClosingQuotes: boolean; + readonly autoSurround: boolean; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: boolean; @@ -3428,7 +3503,7 @@ declare namespace monaco.editor { /** * An optional dom node for the view zone that will be placed in the margin area. */ - marginDomNode?: HTMLElement; + marginDomNode?: HTMLElement | null; /** * Callback which gives the relative top of the view zone as it appears (taking scrolling into account). */ @@ -3487,7 +3562,12 @@ declare namespace monaco.editor { * Desired position for the content widget. * `preference` will also affect the placement. */ - position: IPosition; + position: IPosition | null; + /** + * Optionally, a range can be provided to further + * define the position of the content widget. + */ + range?: IRange | null; /** * Placement preference for position, in order of preference. */ @@ -3515,7 +3595,7 @@ declare namespace monaco.editor { * Get the placement of the content widget. * If null is returned, the content widget will be placed off screen. */ - getPosition(): IContentWidgetPosition; + getPosition(): IContentWidgetPosition | null; } /** @@ -3543,7 +3623,7 @@ declare namespace monaco.editor { /** * The position preference for the overlay widget. */ - preference: OverlayWidgetPositionPreference; + preference: OverlayWidgetPositionPreference | null; } /** @@ -3562,7 +3642,7 @@ declare namespace monaco.editor { * Get the placement of the overlay widget. * If null is returned, the overlay widget is responsible to place itself. */ - getPosition(): IOverlayWidgetPosition; + getPosition(): IOverlayWidgetPosition | null; } /** @@ -3634,7 +3714,7 @@ declare namespace monaco.editor { /** * The target element */ - readonly element: Element; + readonly element: Element | null; /** * The target type */ @@ -3642,7 +3722,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor position */ - readonly position: Position; + readonly position: Position | null; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -3650,7 +3730,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor range */ - readonly range: Range; + readonly range: Range | null; /** * Some extra detail. */ @@ -3665,6 +3745,11 @@ declare namespace monaco.editor { readonly target: IMouseTarget; } + export interface IPartialEditorMouseEvent { + readonly event: IMouseEvent; + readonly target: IMouseTarget | null; + } + /** * A rich code editor. */ @@ -3734,6 +3819,14 @@ declare namespace monaco.editor { * @event */ onDidBlurEditorWidget(listener: () => void): IDisposable; + /** + * An event emitted after composition has started. + */ + onCompositionStart(listener: () => void): IDisposable; + /** + * An event emitted after composition has ended. + */ + onCompositionEnd(listener: () => void): IDisposable; /** * An event emitted on a "mouseup". * @event @@ -3758,7 +3851,7 @@ declare namespace monaco.editor { * An event emitted on a "mouseleave". * @event */ - onMouseLeave(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseLeave(listener: (e: IPartialEditorMouseEvent) => void): IDisposable; /** * An event emitted on a "keyup". * @event @@ -3782,7 +3875,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): ICodeEditorViewState; + saveViewState(): ICodeEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -3800,7 +3893,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): ITextModel; + getModel(): ITextModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: ITextModel | null): void; /** * Returns the current editor's configuration */ @@ -3872,15 +3974,15 @@ declare namespace monaco.editor { */ executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursorState?: Selection[]): boolean; /** - * Execute multiple (concommitent) commands on the editor. + * Execute multiple (concomitant) commands on the editor. * @param source The source of the call. * @param command The commands to execute */ - executeCommands(source: string, commands: ICommand[]): void; + executeCommands(source: string, commands: (ICommand | null)[]): void; /** * Get all the decorations on a line (filtering out decorations from other editors). */ - getLineDecorations(lineNumber: number): IModelDecoration[]; + getLineDecorations(lineNumber: number): IModelDecoration[] | null; /** * All decorations added through this call will get the ownerId of this editor. * @see `ITextModel.deltaDecorations` @@ -3906,14 +4008,14 @@ declare namespace monaco.editor { /** * Returns the editor's dom node */ - getDomNode(): HTMLElement; + getDomNode(): HTMLElement | null; /** * Add a content widget. Widgets must have unique ids, otherwise they will be overwritten. */ addContentWidget(widget: IContentWidget): void; /** * Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutContentWidget(widget: IContentWidget): void; /** @@ -3926,7 +4028,7 @@ declare namespace monaco.editor { addOverlayWidget(widget: IOverlayWidget): void; /** * Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutOverlayWidget(widget: IOverlayWidget): void; /** @@ -3953,19 +4055,19 @@ declare namespace monaco.editor { * * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model. */ - getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget; + getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget | null; /** * Get the visible position for `position`. * The result position takes scrolling into account and is relative to the top left corner of the editor. * Explanation 1: the results of this method will change for the same `position` if the user scrolls the editor. * Explanation 2: the results of this method will not change if the container of the editor gets repositioned. - * Warning: the results of this method are innacurate for positions that are outside the current editor viewport. + * Warning: the results of this method are inaccurate for positions that are outside the current editor viewport. */ getScrolledVisiblePosition(position: IPosition): { top: number; left: number; height: number; - }; + } | null; /** * Apply the same font settings as the editor to `target`. */ @@ -3995,7 +4097,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IDiffEditorViewState; + saveViewState(): IDiffEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -4003,7 +4105,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): IDiffEditorModel; + getModel(): IDiffEditorModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: IDiffEditorModel | null): void; /** * Get the `original` editor. */ @@ -4015,17 +4126,17 @@ declare namespace monaco.editor { /** * Get the computed diff information. */ - getLineChanges(): ILineChange[]; + getLineChanges(): ILineChange[] | null; /** * Get information based on computed diff about a line number from the original model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation | null; /** * Get information based on computed diff about a line number from the modified model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation | null; } export class FontInfo extends BareFontInfo { @@ -4034,6 +4145,7 @@ declare namespace monaco.editor { readonly isMonospace: boolean; readonly typicalHalfwidthCharacterWidth: number; readonly typicalFullwidthCharacterWidth: number; + readonly canUseHalfwidthRightwardsArrow: boolean; readonly spaceWidth: number; readonly maxDigitWidth: number; } @@ -4182,7 +4294,7 @@ declare namespace monaco.languages { export function registerRenameProvider(languageId: string, provider: RenameProvider): IDisposable; /** - * Register a signature help provider (used by e.g. paremeter hints). + * Register a signature help provider (used by e.g. parameter hints). */ export function registerSignatureHelpProvider(languageId: string, provider: SignatureHelpProvider): IDisposable; @@ -4289,189 +4401,6 @@ declare namespace monaco.languages { provideCodeActions(model: editor.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (Command | CodeAction)[] | Thenable<(Command | CodeAction)[]>; } - /** - * Completion item kinds. - */ - export enum CompletionItemKind { - Text = 0, - Method = 1, - Function = 2, - Constructor = 3, - Field = 4, - Variable = 5, - Class = 6, - Interface = 7, - Module = 8, - Property = 9, - Unit = 10, - Value = 11, - Enum = 12, - Keyword = 13, - Snippet = 14, - Color = 15, - File = 16, - Reference = 17, - Folder = 18 - } - - /** - * A snippet string is a template which allows to insert text - * and to control the editor cursor when insertion happens. - * - * A snippet can define tab stops and placeholders with `$1`, `$2` - * and `${3:foo}`. `$0` defines the final tab stop, it defaults to - * the end of the snippet. Variables are defined with `$name` and - * `${name:default value}`. The full snippet syntax is documented - * [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets). - */ - export interface SnippetString { - /** - * The snippet string. - */ - value: string; - } - - /** - * A completion item represents a text snippet that is - * proposed to complete text that is being typed. - */ - export interface CompletionItem { - /** - * The label of this completion item. By default - * this is also the text that is inserted when selecting - * this completion. - */ - label: string; - /** - * The kind of this completion item. Based on the kind - * an icon is chosen by the editor. - */ - kind: CompletionItemKind; - /** - * A human-readable string with additional information - * about this item, like type or symbol information. - */ - detail?: string; - /** - * A human-readable string that represents a doc-comment. - */ - documentation?: string | IMarkdownString; - /** - * A command that should be run upon acceptance of this item. - */ - command?: Command; - /** - * A string that should be used when comparing this item - * with other items. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - sortText?: string; - /** - * A string that should be used when filtering a set of - * completion items. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - filterText?: string; - /** - * A string or snippet that should be inserted in a document when selecting - * this completion. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - insertText?: string | SnippetString; - /** - * A range of text that should be replaced by this completion item. - * - * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the - * current position. - * - * *Note:* The range must be a [single line](#Range.isSingleLine) and it must - * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). - */ - range?: Range; - /** - * An optional set of characters that when pressed while this completion is active will accept it first and - * then type that character. *Note* that all commit characters should have `length=1` and that superfluous - * characters will be ignored. - */ - commitCharacters?: string[]; - /** - * @deprecated **Deprecated** in favor of `CompletionItem.insertText` and `CompletionItem.range`. - * - * ~~An [edit](#TextEdit) which is applied to a document when selecting - * this completion. When an edit is provided the value of - * [insertText](#CompletionItem.insertText) is ignored.~~ - * - * ~~The [range](#Range) of the edit must be single-line and on the same - * line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.~~ - */ - textEdit?: editor.ISingleEditOperation; - /** - * An optional array of additional text edits that are applied when - * selecting this completion. Edits must not overlap with the main edit - * nor with themselves. - */ - additionalTextEdits?: editor.ISingleEditOperation[]; - } - - /** - * Represents a collection of [completion items](#CompletionItem) to be presented - * in the editor. - */ - export interface CompletionList { - /** - * This list it not complete. Further typing should result in recomputing - * this list. - */ - isIncomplete?: boolean; - /** - * The completion items. - */ - items: CompletionItem[]; - } - - /** - * Contains additional information about the context in which - * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. - */ - export interface CompletionContext { - /** - * How the completion was triggered. - */ - triggerKind: SuggestTriggerKind; - /** - * Character that triggered the completion item provider. - * - * `undefined` if provider was not triggered by a character. - */ - triggerCharacter?: string; - } - - /** - * The completion item provider interface defines the contract between extensions and - * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). - * - * When computing *complete* completion items is expensive, providers can optionally implement - * the `resolveCompletionItem`-function. In that case it is enough to return completion - * items with a [label](#CompletionItem.label) from the - * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, - * when a completion item is shown in the UI and gains focus this provider is asked to resolve - * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). - */ - export interface CompletionItemProvider { - triggerCharacters?: string[]; - /** - * Provide completion items for the given position and document. - */ - provideCompletionItems(document: editor.ITextModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; - /** - * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) - * or [details](#CompletionItem.detail). - * - * The editor will only resolve a completion item once. - */ - resolveCompletionItem?(item: CompletionItem, token: CancellationToken): CompletionItem | Thenable; - } - /** * Describes how comments for a language work. */ @@ -4479,11 +4408,11 @@ declare namespace monaco.languages { /** * The line comment token, like `// this is a comment` */ - lineComment?: string; + lineComment?: string | null; /** * The block comment character pair, like `/* block comment */` */ - blockComment?: CharacterPair; + blockComment?: CharacterPair | null; } /** @@ -4527,6 +4456,12 @@ declare namespace monaco.languages { * settings will be used. */ surroundingPairs?: IAutoClosingPair[]; + /** + * Defines what characters must be after the cursor for bracket or quote autoclosing to occur when using the \'languageDefined\' autoclosing setting. + * + * This is typically the set of characters which can not start an expression, such as whitespace, closing brackets, non-unary operators, etc. + */ + autoCloseBefore?: string; /** * The language's folding rules. */ @@ -4544,7 +4479,7 @@ declare namespace monaco.languages { */ export interface IndentationRule { /** - * If a line matches this pattern, then all the lines after it should be unindendented once (until another rule matches). + * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches). */ decreaseIndentPattern: RegExp; /** @@ -4577,7 +4512,7 @@ declare namespace monaco.languages { */ export interface FoldingRules { /** - * Used by the indentation based strategy to decide wheter empty lines belong to the previous or the next block. + * Used by the indentation based strategy to decide whether empty lines belong to the previous or the next block. * A language adheres to the off-side rule if blocks in that language are expressed by their indentation. * See [wikipedia](https://en.wikipedia.org/wiki/Off-side_rule) for more information. * If not set, `false` is used and empty lines belong to the previous block. @@ -4601,6 +4536,10 @@ declare namespace monaco.languages { * This rule will only execute if the text after the cursor matches this regular expression. */ afterText?: RegExp; + /** + * This rule will only execute if the text above the this line matches this regular expression. + */ + oneLineAboveText?: RegExp; /** * The action to execute. */ @@ -4696,6 +4635,14 @@ declare namespace monaco.languages { equals(other: IState): boolean; } + /** + * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider), + * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves + * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a + * thenable. + */ + export type ProviderResult = T | undefined | null | Thenable; + /** * A hover represents additional information for a symbol or word. Hovers are * rendered in a tooltip-like widget. @@ -4723,18 +4670,190 @@ declare namespace monaco.languages { * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ - provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): Hover | Thenable; + provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; + } + + 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 CompletionItemInsertTextRule { + /** + * Adjust whitespace/indentation of multiline insert texts to + * match the current line indentation. + */ + KeepWhitespace = 1, + /** + * `insertText` is a snippet. + */ + InsertAsSnippet = 4 + } + + /** + * A completion item represents a text snippet that is + * proposed to complete text that is being typed. + */ + export interface CompletionItem { + /** + * The label of this completion item. By default + * this is also the text that is inserted when selecting + * this completion. + */ + label: string; + /** + * The kind of this completion item. Based on the kind + * an icon is chosen by the editor. + */ + kind: CompletionItemKind; + /** + * A human-readable string with additional information + * about this item, like type or symbol information. + */ + detail?: string; + /** + * A human-readable string that represents a doc-comment. + */ + documentation?: string | IMarkdownString; + /** + * A string that should be used when comparing this item + * with other items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + sortText?: string; + /** + * A string that should be used when filtering a set of + * completion items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + filterText?: string; + /** + * Select this item when showing. *Note* that only one completion item can be selected and + * that the editor decides which item that is. The rule is that the *first* item of those + * that match best is selected. + */ + preselect?: boolean; + /** + * A string or snippet that should be inserted in a document when selecting + * this completion. + * is used. + */ + insertText: string; + /** + * Addition rules (as bitmask) that should be applied when inserting + * this completion. + */ + insertTextRules?: CompletionItemInsertTextRule; + /** + * A range of text that should be replaced by this completion item. + * + * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the + * current position. + * + * *Note:* The range must be a [single line](#Range.isSingleLine) and it must + * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). + */ + range?: IRange; + /** + * An optional set of characters that when pressed while this completion is active will accept it first and + * then type that character. *Note* that all commit characters should have `length=1` and that superfluous + * characters will be ignored. + */ + commitCharacters?: string[]; + /** + * An optional array of additional text edits that are applied when + * selecting this completion. Edits must not overlap with the main edit + * nor with themselves. + */ + additionalTextEdits?: editor.ISingleEditOperation[]; + /** + * A command that should be run upon acceptance of this item. + */ + command?: Command; + } + + export interface CompletionList { + suggestions: CompletionItem[]; + incomplete?: boolean; + dispose?(): void; } /** * How a suggest provider was triggered. */ - export enum SuggestTriggerKind { + export enum CompletionTriggerKind { Invoke = 0, TriggerCharacter = 1, TriggerForIncompleteCompletions = 2 } + /** + * Contains additional information about the context in which + * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. + */ + export interface CompletionContext { + /** + * How the completion was triggered. + */ + triggerKind: CompletionTriggerKind; + /** + * Character that triggered the completion item provider. + * + * `undefined` if provider was not triggered by a character. + */ + triggerCharacter?: string; + } + + /** + * The completion item provider interface defines the contract between extensions and + * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). + * + * When computing *complete* completion items is expensive, providers can optionally implement + * the `resolveCompletionItem`-function. In that case it is enough to return completion + * items with a [label](#CompletionItem.label) from the + * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, + * when a completion item is shown in the UI and gains focus this provider is asked to resolve + * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). + */ + export interface CompletionItemProvider { + triggerCharacters?: string[]; + /** + * Provide completion items for the given position and document. + */ + provideCompletionItems(model: editor.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult; + /** + * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) + * or [details](#CompletionItem.detail). + * + * The editor will only resolve a completion item once. + */ + resolveCompletionItem?(model: editor.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult; + } + export interface CodeAction { title: string; command?: Command; @@ -4752,7 +4871,7 @@ declare namespace monaco.languages { * The label of this signature. Will be shown in * the UI. */ - label: string; + label: string | [number, number]; /** * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. @@ -4802,16 +4921,29 @@ declare namespace monaco.languages { activeParameter: number; } + export enum SignatureHelpTriggerReason { + Invoke = 1, + TriggerCharacter = 2, + ContentChange = 3 + } + + export interface SignatureHelpContext { + readonly triggerReason: SignatureHelpTriggerReason; + readonly triggerCharacter?: string; + readonly isRetrigger: boolean; + } + /** * The signature help provider interface defines the contract between extensions and * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { - signatureHelpTriggerCharacters: string[]; + readonly signatureHelpTriggerCharacters?: ReadonlyArray; + readonly signatureHelpRetriggerCharacters?: ReadonlyArray; /** * Provide help for the signature at the given position and document. */ - provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult; } /** @@ -4857,7 +4989,7 @@ declare namespace monaco.languages { * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ - provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4879,7 +5011,7 @@ declare namespace monaco.languages { /** * Provide a set of project-wide references for the given position and document. */ - provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult; } /** @@ -4920,7 +5052,7 @@ declare namespace monaco.languages { /** * Provide the definition of the symbol at the given position and document. */ - provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4931,7 +5063,7 @@ declare namespace monaco.languages { /** * Provide the implementation of the symbol at the given position and document. */ - provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4942,7 +5074,7 @@ declare namespace monaco.languages { /** * Provide the type definition of the symbol at the given position and document. */ - provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4996,14 +5128,18 @@ declare namespace monaco.languages { /** * Provide symbol information for the given document. */ - provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): DocumentSymbol[] | Thenable; + provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): ProviderResult; } - export interface TextEdit { + export type TextEdit = { range: IRange; text: string; eol?: editor.EndOfLineSequence; - } + } | { + range: undefined; + text: undefined; + eol: editor.EndOfLineSequence; + }; /** * Interface used to format a model @@ -5027,7 +5163,7 @@ declare namespace monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5042,7 +5178,7 @@ declare namespace monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5058,7 +5194,7 @@ declare namespace monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5073,8 +5209,8 @@ declare namespace monaco.languages { * A provider of links. */ export interface LinkProvider { - provideLinks(model: editor.ITextModel, token: CancellationToken): ILink[] | Thenable; - resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable; + provideLinks(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult; } /** @@ -5142,11 +5278,11 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideDocumentColors(model: editor.ITextModel, token: CancellationToken): IColorInformation[] | Thenable; + provideDocumentColors(model: editor.ITextModel, token: CancellationToken): ProviderResult; /** * Provide the string representations for a color. */ - provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult; } export interface FoldingContext { @@ -5159,7 +5295,7 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): FoldingRange[] | Thenable; + provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult; } export interface FoldingRange { @@ -5221,7 +5357,10 @@ declare namespace monaco.languages { } export interface WorkspaceEdit { - edits: Array; + edits?: Array; + } + + export interface Rejection { rejectReason?: string; } @@ -5231,8 +5370,8 @@ declare namespace monaco.languages { } export interface RenameProvider { - provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; - resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): RenameLocation | Thenable; + provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult; + resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } export interface Command { @@ -5250,8 +5389,8 @@ declare namespace monaco.languages { export interface CodeLensProvider { onDidChange?: IEvent; - provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; - resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; + provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ProviderResult; } export interface ILanguageExtensionPoint { @@ -5296,15 +5435,15 @@ declare namespace monaco.languages { tokenPostfix?: string; } - export type IShortMonarchLanguageRule1 = [RegExp, string | IMonarchLanguageAction]; - - export type IShortMonarchLanguageRule2 = [RegExp, string | IMonarchLanguageAction, string]; - /** * A rule is either a regular expression and an action * shorthands: [reg,act] == { regex: reg, action: act} * and : [reg,act,nxt] == { regex: reg, action: act{ next: nxt }} */ + export type IShortMonarchLanguageRule1 = [RegExp, IMonarchLanguageAction]; + + export type IShortMonarchLanguageRule2 = [RegExp, IMonarchLanguageAction, string]; + export interface IExpandedMonarchLanguageRule { /** * match tokens @@ -5327,7 +5466,9 @@ declare namespace monaco.languages { * ... or a case statement with guards... * ... or a basic action with a token value. */ - export interface IMonarchLanguageAction { + export type IShortMonarchLanguageAction = string; + + export interface IExpandedMonarchLanguageAction { /** * array of actions for each parenthesized match group */ @@ -5357,7 +5498,7 @@ declare namespace monaco.languages { */ bracket?: string; /** - * switch to embedded language (useing the mimetype) or get out using "@pop" + * switch to embedded language (using the mimetype) or get out using "@pop" */ nextEmbedded?: string; /** @@ -5366,6 +5507,8 @@ declare namespace monaco.languages { log?: string; } + export type IMonarchLanguageAction = IShortMonarchLanguageAction | IExpandedMonarchLanguageAction | IShortMonarchLanguageAction[] | IExpandedMonarchLanguageAction[]; + /** * This interface can be shortened as an array, ie. ['{','}','delimiter.curly'] */ @@ -5375,7 +5518,7 @@ declare namespace monaco.languages { */ open: string; /** - * closeing bracket + * closing bracket */ close: string; /** @@ -5404,6 +5547,7 @@ declare namespace monaco.worker { } +//dtsv=2 declare namespace monaco.languages.typescript { @@ -5541,7 +5685,7 @@ declare namespace monaco.languages.typescript { * * @param content The file content * @param filePath An optional file path - * @returns A disposabled which will remove the file from the + * @returns A disposable which will remove the file from the * language service upon disposal. */ addExtraLib(content: string, filePath?: string): IDisposable; @@ -5630,7 +5774,7 @@ declare namespace monaco.languages.json { */ readonly validate?: boolean; /** - * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. + * If set, comments are tolerated. If set to false, syntax errors will be emitted for comments. */ readonly allowComments?: boolean; /** @@ -5650,6 +5794,10 @@ declare namespace monaco.languages.json { */ readonly schema?: any; }[]; + /** + * If set, the schema service would load schema content on-demand with 'fetch' if available + */ + readonly enableSchemaRequest? : boolean } export interface LanguageServiceDefaults { @@ -5660,6 +5808,7 @@ declare namespace monaco.languages.json { export var jsonDefaults: LanguageServiceDefaults; } + /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. @@ -5687,7 +5836,7 @@ declare namespace monaco.languages.html { export interface Options { /** - * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. + * If set, comments are tolerated. If set to false, syntax errors will be emitted for comments. */ readonly format?: HTMLFormatConfiguration; /** diff --git a/package-lock.json b/package-lock.json index 2380aef2..0d2760ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2252,39 +2252,39 @@ } }, "monaco-css": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/monaco-css/-/monaco-css-2.2.0.tgz", - "integrity": "sha512-ZvWdQC3wlyuzJNlvWkIehT/xt7TKdJ6v1YPbkfhsq8vMaIQu12MdwYDhQEYGwL0PJd7hpWWFo/e14YjAPKq6NA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/monaco-css/-/monaco-css-2.3.0.tgz", + "integrity": "sha512-LIA9osCeheJgU+b4a6RRWR7dEkSvAR4swPP3Q4jCqWOwo2L/qQCdhq9HjsU6cGH/X8rXWTRmeNNbP0wm3MoeWQ==", "dev": true }, "monaco-editor-core": { - "version": "0.14.6", - "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.14.6.tgz", - "integrity": "sha512-B7ZFmTO/4L+ff07Qmxt2TB0/nux80dVyah5AQaeuWCAD3H5wuaGOszAWBZEU6hEalSYTXv+O9bnTxnjXZG6tuw==", + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.15.0.tgz", + "integrity": "sha512-s1zuo+p6Gl6IC4WJP6HBkr4pWULm+HdFfacB8vOFPQLLi2oJseO20UuSkxYuZTUJQIjvhNrQfLNAmPKLZaf7tg==", "dev": true }, "monaco-html": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/monaco-html/-/monaco-html-2.2.0.tgz", - "integrity": "sha512-/WBelqoegVyZ0ln0CAwZ7F7OmnjntjrZx4j8iTrROF5p2N3ufK4i82xM2lESFaBVjfULjTo5aNLy9U/+fHjphA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/monaco-html/-/monaco-html-2.3.0.tgz", + "integrity": "sha512-sMRDVYqA1XC5LbGIRIr36TnPJ8ue0LOOPQAqnnk62ZG9aLFnoLJ25K8OFBcqi83qtD8vik+T1cnFWVOdtTln+w==", "dev": true }, "monaco-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/monaco-json/-/monaco-json-2.2.0.tgz", - "integrity": "sha512-lY+s0cd9AdBJhXX/bAhnuxmmQ5y1oJts+EtvIPmxiAMU3ysAdp702jkoOxeNAZjPHJVLiTyGaO/pfVYmKbqZtg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/monaco-json/-/monaco-json-2.3.0.tgz", + "integrity": "sha512-UqND3J8D1K8fI2YLWqvvIurOt+QCw7Bdv6hXL0xO/fz0poI02XhGpKRty/O27nHuYAoiMZRj7Zgn5YUypkt2qw==", "dev": true }, "monaco-languages": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-1.5.1.tgz", - "integrity": "sha512-tziKyEYS6hOWjZXpGJOOh00aWRA5tYrY+5/R8XmAoELJnizCmbBfbJjguoJjS0iSFyEemWQywzBdXrpPRYtzUQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/monaco-languages/-/monaco-languages-1.6.0.tgz", + "integrity": "sha512-LBEWj8tngYwsq4kasQr+dIhnO4xUIEN36ns+cRepWAQiXZnzcrZ84gFHXm8f4mR4tssxvHVU5Vw7xMUYro6h3g==", "dev": true }, "monaco-typescript": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/monaco-typescript/-/monaco-typescript-3.2.0.tgz", - "integrity": "sha512-tlzwTbQLIEW1iz9R8hPt/xAAbduR1/2dSnDq89Nk0lVaqjKB4Bz39tHm5E2rE8EjDdvOOO4JipJBmmmQu+reaA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/monaco-typescript/-/monaco-typescript-3.3.0.tgz", + "integrity": "sha512-VxlmeaPa07+rnrQi00INcvlMoC/Y1poACSV0brs9EjKbF1DEdpEu9/NAeJmXXApv56ywXviaqtMkCI8JLvId+g==", "dev": true }, "ms": { diff --git a/package.json b/package.json index 3df82ca7..976c84c9 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,12 @@ "gulp": "^3.9.1", "gulp-typedoc": "^2.2.0", "http-server": "^0.11.1", - "monaco-css": "2.2.0", - "monaco-editor-core": "0.14.6", - "monaco-html": "2.2.0", - "monaco-json": "2.2.0", - "monaco-languages": "1.5.1", - "monaco-typescript": "3.2.0", + "monaco-css": "2.3.0", + "monaco-editor-core": "0.15.0", + "monaco-html": "2.3.0", + "monaco-json": "2.3.0", + "monaco-languages": "1.6.0", + "monaco-typescript": "3.3.0", "rimraf": "^2.6.2", "typedoc": "^0.11.1", "typescript": "^3.0.1", diff --git a/website/playground/monaco.d.ts.txt b/website/playground/monaco.d.ts.txt index 078891c8..439949b1 100644 --- a/website/playground/monaco.d.ts.txt +++ b/website/playground/monaco.d.ts.txt @@ -30,44 +30,26 @@ declare namespace monaco { dispose(): void; } + export enum MarkerTag { - Unnecessary = 1, + Unnecessary = 1 } export enum MarkerSeverity { Hint = 1, Info = 2, Warning = 4, - Error = 8, + Error = 8 } - - - export type TValueCallback = (value: T | PromiseLike) => void; - - export type ProgressCallback = (progress: TProgress) => void; - - - export class Promise { - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason: any) => void, - progress: (progress: TProgress) => void) => void, - oncancel?: () => void); + export class Promise { + constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason: any) => void) => void); public then( onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: any) => TResult2 | PromiseLike) | null, - onprogress?: (progress: TProgress) => void): Promise; + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; - public done( - onfulfilled?: (value: T) => void, - onrejected?: (reason: any) => void, - onprogress?: (progress: TProgress) => void): void; - - public cancel(): void; public static as(value: null): Promise; public static as(value: undefined): Promise; @@ -75,15 +57,9 @@ declare namespace monaco { public static as>(value: SomePromise): SomePromise; public static as(value: T): Promise; - public static is(value: any): value is PromiseLike; - - public static timeout(delay: number): Promise; - public static join(promises: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; public static join(promises: (T | PromiseLike)[]): Promise; - public static any(promises: (T | PromiseLike)[]): Promise<{ key: string; value: Promise; }>; - public static wrap(value: T | PromiseLike): Promise; public static wrapError(error: Error): Promise; @@ -103,9 +79,10 @@ declare namespace monaco { */ readonly onCancellationRequested: IEvent; } + /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. - * This class is a simple parser which creates the basic component paths + * This class is a simple parser which creates the basic component parts * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation * and encoding. * @@ -116,8 +93,6 @@ declare namespace monaco { * | _____________________|__ * / \ / \ * urn:example:animal:ferret:nose - * - * */ export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; @@ -145,28 +120,80 @@ declare namespace monaco { readonly fragment: string; /** * Returns a string representing the corresponding file system path of this Uri. - * Will handle UNC paths and normalize windows drive letters to lower-case. Also - * uses the platform specific path separator. Will *not* validate the path for - * invalid characters and semantics. Will *not* look at the scheme of this Uri. + * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the + * platform specific path separator. + * + * * Will *not* validate the path for invalid characters and semantics. + * * Will *not* look at the scheme of this Uri. + * * The result shall *not* be used for display purposes but for accessing a file on disk. + * + * + * The *difference* to `Uri#path` is the use of the platform specific separator and the handling + * of UNC paths. See the below sample of a file-uri with an authority (UNC path). + * + * ```ts + const u = Uri.parse('file://server/c$/folder/file.txt') + u.authority === 'server' + u.path === '/shares/c$/file.txt' + u.fsPath === '\\server\c$\folder\file.txt' + ``` + * + * Using `Uri#path` to read a file (using fs-apis) would not be enough because parts of the path, + * namely the server name, would be missing. Therefore `Uri#fsPath` exists - it's sugar to ease working + * with URIs that represent files on disk (`file` scheme). */ readonly fsPath: string; with(change: { scheme?: string; - authority?: string; - path?: string; - query?: string; - fragment?: string; + authority?: string | null; + path?: string | null; + query?: string | null; + fragment?: string | null; }): Uri; + /** + * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, + * `file:///usr/home`, or `scheme:with/path`. + * + * @param value A string which represents an Uri (see `Uri#toString`). + */ static parse(value: string): Uri; + /** + * Creates a new Uri from a file system path, e.g. `c:\my\files`, + * `/usr/home`, or `\\server\share\some\path`. + * + * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument + * as path, not as stringified-uri. E.g. `Uri.file(path)` is **not the same as** + * `Uri.parse('file://' + path)` because the path might contain characters that are + * interpreted (# and ?). See the following sample: + * ```ts + const good = Uri.file('/coding/c#/project1'); + good.scheme === 'file'; + good.path === '/coding/c#/project1'; + good.fragment === ''; + const bad = Uri.parse('file://' + '/coding/c#/project1'); + bad.scheme === 'file'; + bad.path === '/coding/c'; // path is now broken + bad.fragment === '/project1'; + ``` + * + * @param path A file system path (see `Uri#fsPath`) + */ static file(path: string): Uri; static from(components: { - scheme?: string; + scheme: string; authority?: string; path?: string; query?: string; fragment?: string; }): Uri; /** + * Creates a string presentation for this Uri. It's guaranteed that calling + * `Uri.parse` with the result of this function creates an Uri which is equal + * to this Uri. + * + * * The result shall *not* be used for display purposes but for externalization or transport. + * * The result will be encoded using the percentage encoding and encoding happens mostly + * ignore the scheme-specific encoding rules. * * @param skipEncoding Do not encode the result, default is `false` */ @@ -363,7 +390,6 @@ declare namespace monaco { */ MAX_VALUE = 112 } - export class KeyMod { static readonly CtrlCmd: number; static readonly Shift: number; @@ -444,6 +470,20 @@ declare namespace monaco { */ readonly column: number; constructor(lineNumber: number, column: number); + /** + * Create a new postion from this position. + * + * @param newLineNumber new line number + * @param newColumn new column + */ + with(newLineNumber?: number, newColumn?: number): Position; + /** + * Derive a new position from this position. + * + * @param deltaLineNumber line number delta + * @param deltaColumn column delta + */ + delta(deltaLineNumber?: number, deltaColumn?: number): Position; /** * Test if this position equals other position */ @@ -574,19 +614,19 @@ declare namespace monaco { /** * A intersection of the two ranges. */ - intersectRanges(range: IRange): Range; + intersectRanges(range: IRange): Range | null; /** * A intersection of the two ranges. */ - static intersectRanges(a: IRange, b: IRange): Range; + static intersectRanges(a: IRange, b: IRange): Range | null; /** * Test if this range equals other. */ - equalsRange(other: IRange): boolean; + equalsRange(other: IRange | null): boolean; /** * Test if range `a` equals `b`. */ - static equalsRange(a: IRange, b: IRange): boolean; + static equalsRange(a: IRange | null, b: IRange | null): boolean; /** * Return the end position (which will be after or equal to the start position) */ @@ -619,6 +659,7 @@ declare namespace monaco { /** * Create a `Range` from an `IRange`. */ + static lift(range: undefined | null): null; static lift(range: IRange): Range; /** * Test if `obj` is an `IRange`. @@ -636,7 +677,7 @@ declare namespace monaco { * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the startPosition and then on the endPosition */ - static compareRangesUsingStarts(a: IRange, b: IRange): number; + static compareRangesUsingStarts(a: IRange | null | undefined, b: IRange | null | undefined): number; /** * A function that compares ranges, useful for sorting ranges * It will first compare ranges on the endPosition and then on the startPosition @@ -840,7 +881,7 @@ declare namespace monaco.editor { /** * Get the model that has `uri` if it exists. */ - export function getModel(uri: Uri): ITextModel; + export function getModel(uri: Uri): ITextModel | null; /** * Get all the created models. @@ -895,7 +936,7 @@ declare namespace monaco.editor { export function tokenize(text: string, languageId: string): Token[][]; /** - * Define a new theme or updte an existing theme. + * Define a new theme or update an existing theme. */ export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void; @@ -1000,7 +1041,7 @@ declare namespace monaco.editor { contextMenuOrder?: number; /** * Method that will be executed when the action is triggered. - * @param editor The editor instance is passed in as a convinience + * @param editor The editor instance is passed in as a convenience */ run(editor: ICodeEditor): void | Promise; } @@ -1053,13 +1094,13 @@ declare namespace monaco.editor { } export interface IStandaloneCodeEditor extends ICodeEditor { - addCommand(keybinding: number, handler: ICommandHandler, context: string): string; + addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null; createContextKey(key: string, defaultValue: T): IContextKey; addAction(descriptor: IActionDescriptor): IDisposable; } export interface IStandaloneDiffEditor extends IDiffEditor { - addCommand(keybinding: number, handler: ICommandHandler, context: string): string; + addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null; createContextKey(key: string, defaultValue: T): IContextKey; addAction(descriptor: IActionDescriptor): IDisposable; getOriginalEditor(): IStandaloneCodeEditor; @@ -1072,7 +1113,7 @@ declare namespace monaco.editor { export interface IContextKey { set(value: T): void; reset(): void; - get(): T; + get(): T | undefined; } export interface IEditorOverrideServices { @@ -1159,17 +1200,12 @@ declare namespace monaco.editor { * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - color: string | ThemeColor; + color: string | ThemeColor | undefined; /** * CSS color to render in the overview ruler. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry */ - darkColor: string | ThemeColor; - /** - * CSS color to render in the overview ruler. - * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry - */ - hcColor?: string | ThemeColor; + darkColor?: string | ThemeColor; /** * The position in the overview ruler. */ @@ -1188,15 +1224,15 @@ declare namespace monaco.editor { /** * CSS class name describing the decoration. */ - className?: string; + className?: string | null; /** * Message to be rendered when hovering over the glyph margin decoration. */ - glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[]; + glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Array of MarkdownString to render as the decoration message. */ - hoverMessage?: IMarkdownString | IMarkdownString[]; + hoverMessage?: IMarkdownString | IMarkdownString[] | null; /** * Should the decoration expand to encompass a whole line. */ @@ -1209,25 +1245,25 @@ declare namespace monaco.editor { /** * If set, render this decoration in the overview ruler. */ - overviewRuler?: IModelDecorationOverviewRulerOptions; + overviewRuler?: IModelDecorationOverviewRulerOptions | null; /** * If set, the decoration will be rendered in the glyph margin with this CSS class name. */ - glyphMarginClassName?: string; + glyphMarginClassName?: string | null; /** * If set, the decoration will be rendered in the lines decorations with this CSS class name. */ - linesDecorationsClassName?: string; + linesDecorationsClassName?: string | null; /** * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name. */ - marginClassName?: string; + marginClassName?: string | null; /** * If set, the decoration will be rendered inline with the text with this CSS class name. * Please use this only for CSS rules that must impact the text. For example, use `className` * to have a background color decoration. */ - inlineClassName?: string; + inlineClassName?: string | null; /** * If there is an `inlineClassName` which affects letter spacing. */ @@ -1235,11 +1271,11 @@ declare namespace monaco.editor { /** * If set, the decoration will be rendered before the text with this CSS class name. */ - beforeContentClassName?: string; + beforeContentClassName?: string | null; /** * If set, the decoration will be rendered after the text with this CSS class name. */ - afterContentClassName?: string; + afterContentClassName?: string | null; } /** @@ -1265,7 +1301,7 @@ declare namespace monaco.editor { */ readonly id: string; /** - * Identifier for a decoration's owener. + * Identifier for a decoration's owner. */ readonly ownerId: number; /** @@ -1387,7 +1423,7 @@ declare namespace monaco.editor { /** * The text to replace with. This can be null to emulate a simple delete. */ - text: string; + text: string | null; /** * This indicates that this operation has "insert" semantics. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved. @@ -1402,7 +1438,7 @@ declare namespace monaco.editor { /** * A callback that can compute the resulting cursors state after some edit operations have been executed. */ - (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; + (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[] | null; } export class TextModelResolvedOptions { @@ -1422,7 +1458,7 @@ declare namespace monaco.editor { export class FindMatch { _findMatchBrand: void; readonly range: Range; - readonly matches: string[]; + readonly matches: string[] | null; } /** @@ -1536,13 +1572,13 @@ declare namespace monaco.editor { */ validatePosition(position: IPosition): Position; /** - * Advances the given position by the given offest (negative offsets are also accepted) + * Advances the given position by the given offset (negative offsets are also accepted) * and returns it as a new valid position. * * If the offset and position are such that their combination goes beyond the beginning or * end of the model, throws an exception. * - * If the ofsset is such that the new position would be in the middle of a multi-byte + * If the offset is such that the new position would be in the middle of a multi-byte * line terminator, throws an exception. */ modifyPosition(position: IPosition, offset: number): Position; @@ -1608,7 +1644,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the next match is. It is null if no next match has been found. */ - findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Search the model for the previous match. Loops to the end of the model if needed. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true. @@ -1619,7 +1655,7 @@ declare namespace monaco.editor { * @param captureMatches The result will contain the captured groups. * @return The range where the previous match is. It is null if no previous match has been found. */ - findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch; + findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null; /** * Get the language associated with this model. */ @@ -1627,37 +1663,17 @@ declare namespace monaco.editor { /** * Get the word under or besides `position`. * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Might be null. */ - getWordAtPosition(position: IPosition): IWordAtPosition; + getWordAtPosition(position: IPosition): IWordAtPosition | null; /** * Get the word under or besides `position` trimmed to `position`.column * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; /** - * Get the language associated with this model. - */ - getModeId(): string; - /** - * Get the word under or besides `position`. - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Might be null. - */ - getWordAtPosition(position: IPosition): IWordAtPosition; - /** - * Get the word under or besides `position` trimmed to `position`.column - * @param position The position to look for a word. - * @param skipSyntaxTokens Ignore syntax tokens, as identified by the mode. - * @return The word under or besides `position`. Will never be null. - */ - getWordUntilPosition(position: IPosition): IWordAtPosition; - /** - * Perform a minimum ammount of operations, in order to transform the decorations + * Perform a minimum amount of operations, in order to transform the decorations * identified by `oldDecorations` to the decorations described by `newDecorations` * and returns the new identifiers associated with the resulting decorations. * @@ -1672,13 +1688,13 @@ declare namespace monaco.editor { * @param id The decoration id. * @return The decoration options or null if the decoration was not found. */ - getDecorationOptions(id: string): IModelDecorationOptions; + getDecorationOptions(id: string): IModelDecorationOptions | null; /** * Get the range associated with a decoration. * @param id The decoration id. * @return The decoration range or null if the decoration was not found. */ - getDecorationRange(id: string): Range; + getDecorationRange(id: string): Range | null; /** * Gets all the decorations for the line `lineNumber` as an array. * @param lineNumber The line number @@ -1697,7 +1713,7 @@ declare namespace monaco.editor { */ getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]; /** - * Gets all the deocorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. + * Gets all the decorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering. * So for now it returns all the decorations on the same line as `range`. * @param range The range to search in * @param ownerId If set, it will ignore decorations belonging to other owners. @@ -1742,12 +1758,12 @@ declare namespace monaco.editor { /** * Push edit operations, basically editing the model. This is the preferred way * of editing the model. The edit operations will land on the undo stack. - * @param beforeCursorState The cursor state before the edit operaions. This cursor state will be returned when `undo` or `redo` are invoked. + * @param beforeCursorState The cursor state before the edit operations. This cursor state will be returned when `undo` or `redo` are invoked. * @param editOperations The edit operations. * @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed. * @return The cursor state returned by the `cursorStateComputer`. */ - pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[]; + pushEditOperations(beforeCursorState: Selection[], editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[] | null; /** * Change the end of line sequence. This is the preferred way of * changing the eol sequence. This will land on the undo stack. @@ -1811,14 +1827,14 @@ declare namespace monaco.editor { * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addEditOperation(range: Range, text: string): void; + addEditOperation(range: Range, text: string | null): void; /** * Add a new edit operation (a replace operation). * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()` * @param range The range to replace (delete). May be empty to represent a simple insert. * @param text The text to replace with. May be null to represent a simple delete. */ - addTrackedEditOperation(range: Range, text: string): void; + addTrackedEditOperation(range: Range, text: string | null): void; /** * Track `selection` when applying edit operations. * A best effort will be made to not grow/expand the selection. @@ -1826,7 +1842,7 @@ declare namespace monaco.editor { * @param selection The selection to track. * @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection * should clamp to the previous or the next character. - * @return A unique identifer. + * @return A unique identifier. */ trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string; } @@ -1859,7 +1875,7 @@ declare namespace monaco.editor { getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void; /** * Compute the cursor state after the edit operations were applied. - * @param model The model the commad has executed on. + * @param model The model the command has executed on. * @param helper A helper to get inverse edit operations and to get previously tracked selections. * @return The cursor state after the command executed. */ @@ -1887,11 +1903,11 @@ declare namespace monaco.editor { /** * The `uri` of the previous model or null. */ - readonly oldModelUrl: Uri; + readonly oldModelUrl: Uri | null; /** * The `uri` of the new model or null. */ - readonly newModelUrl: Uri; + readonly newModelUrl: Uri | null; } export interface IDimension { @@ -1923,7 +1939,7 @@ declare namespace monaco.editor { * A line change */ export interface ILineChange extends IChange { - readonly charChanges: ICharChange[]; + readonly charChanges: ICharChange[] | undefined; } export interface INewScrollPosition { @@ -1987,7 +2003,7 @@ declare namespace monaco.editor { */ export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState; - export const enum ScrollType { + export enum ScrollType { Smooth = 0, Immediate = 1 } @@ -2038,7 +2054,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IEditorViewState; + saveViewState(): IEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -2050,7 +2066,7 @@ declare namespace monaco.editor { /** * Returns the primary position of the cursor. */ - getPosition(): Position; + getPosition(): Position | null; /** * Set the primary position of the cursor. This will remove any secondary cursors. * @param position New primary cursor's position @@ -2083,11 +2099,11 @@ declare namespace monaco.editor { /** * Returns the primary selection of the editor. */ - getSelection(): Selection; + getSelection(): Selection | null; /** * Returns all the selections of the editor. */ - getSelections(): Selection[]; + getSelections(): Selection[] | null; /** * Set the primary selection of the editor. This will remove any secondary cursors. * @param selection The new selection @@ -2377,16 +2393,14 @@ declare namespace monaco.editor { arrowSize?: number; /** * Render vertical scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - vertical?: string; + vertical?: 'auto' | 'visible' | 'hidden'; /** * Render horizontal scrollbar. - * Accepted values: 'auto', 'visible', 'hidden'. * Defaults to 'auto'. */ - horizontal?: string; + horizontal?: 'auto' | 'visible' | 'hidden'; /** * Cast horizontal and vertical shadows when the content is scrolled. * Defaults to true. @@ -2443,13 +2457,23 @@ declare namespace monaco.editor { autoFindInSelection: boolean; } + /** + * Configuration options for auto closing quotes and brackets + */ + export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'; + + /** + * Configuration options for auto wrapping quotes and brackets + */ + export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never'; + /** * Configuration options for editor minimap */ export interface IEditorMinimapOptions { /** * Enable the rendering of the minimap. - * Defaults to false. + * Defaults to true. */ enabled?: boolean; /** @@ -2506,6 +2530,22 @@ declare namespace monaco.editor { sticky?: boolean; } + /** + * Configuration options for parameter hints + */ + export interface IEditorParameterHintOptions { + /** + * Enable parameter hints. + * Defaults to true. + */ + enabled?: boolean; + /** + * Enable cycling of parameter hints. + * Defaults to false. + */ + cycle?: boolean; + } + export interface ISuggestOptions { /** * Enable graceful matching. Defaults to true. @@ -2515,6 +2555,10 @@ declare namespace monaco.editor { * Prevent quick suggestions when a snippet is active. Defaults to true. */ snippetsPreventQuickSuggestions?: boolean; + /** + * Favours words that appear close to the cursor. + */ + localityBonus?: boolean; } /** @@ -2791,19 +2835,29 @@ declare namespace monaco.editor { */ quickSuggestionsDelay?: number; /** - * Enables parameter hints + * Parameter hint options. */ - parameterHints?: boolean; + parameterHints?: IEditorParameterHintOptions; /** * Render icons in suggestions box. * Defaults to true. */ iconsInSuggestions?: boolean; /** - * Enable auto closing brackets. - * Defaults to true. + * Options for auto closing brackets. + * Defaults to language defined behavior. */ - autoClosingBrackets?: boolean; + autoClosingBrackets?: EditorAutoClosingStrategy; + /** + * Options for auto closing quotes. + * Defaults to language defined behavior. + */ + autoClosingQuotes?: EditorAutoClosingStrategy; + /** + * Options for auto surrounding. + * Defaults to always allowing auto surrounding. + */ + autoSurround?: EditorAutoSurroundStrategy; /** * Enable auto indentation adjustment. * Defaults to false. @@ -2847,6 +2901,10 @@ declare namespace monaco.editor { * Copying without a selection copies the current line. */ emptySelectionClipboard?: boolean; + /** + * Syntax highlighting is copied. + */ + copyWithSyntaxHighlighting?: boolean; /** * Enable word based suggestions. Defaults to 'true' */ @@ -2865,6 +2923,10 @@ declare namespace monaco.editor { * Defaults to the editor line height. */ suggestLineHeight?: number; + /** + * Enable tab completion. + */ + tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets'; /** * Enable selection highlight. * Defaults to true. @@ -3126,6 +3188,12 @@ declare namespace monaco.editor { readonly filterGraceful: boolean; readonly snippets: 'top' | 'bottom' | 'inline' | 'none'; readonly snippetsPreventQuickSuggestions: boolean; + readonly localityBonus: boolean; + } + + export interface InternalParameterHintOptions { + readonly enabled: boolean; + readonly cycle: boolean; } export interface EditorWrappingInfo { @@ -3140,7 +3208,7 @@ declare namespace monaco.editor { readonly wordWrapBreakObtrusiveCharacters: string; } - export const enum RenderLineNumbersType { + export enum RenderLineNumbersType { Off = 0, On = 1, Relative = 2, @@ -3154,7 +3222,7 @@ declare namespace monaco.editor { readonly rulers: number[]; readonly ariaLabel: string; readonly renderLineNumbers: RenderLineNumbersType; - readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null; readonly selectOnLineNumbers: boolean; readonly glyphMargin: boolean; readonly revealHorizontalRightPadding: number; @@ -3192,7 +3260,7 @@ declare namespace monaco.editor { strings: boolean; }; readonly quickSuggestionsDelay: number; - readonly parameterHints: boolean; + readonly parameterHints: InternalParameterHintOptions; readonly iconsInSuggestions: boolean; readonly formatOnType: boolean; readonly formatOnPaste: boolean; @@ -3203,6 +3271,7 @@ declare namespace monaco.editor { readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'; readonly suggestFontSize: number; readonly suggestLineHeight: number; + readonly tabCompletion: 'on' | 'off' | 'onlySnippets'; readonly suggest: InternalSuggestOptions; readonly selectionHighlight: boolean; readonly occurrencesHighlight: boolean; @@ -3232,12 +3301,15 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly showUnused: boolean; readonly wordSeparators: string; - readonly autoClosingBrackets: boolean; + readonly autoClosingBrackets: EditorAutoClosingStrategy; + readonly autoClosingQuotes: EditorAutoClosingStrategy; + readonly autoSurround: EditorAutoSurroundStrategy; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: EditorLayoutInfo; readonly fontInfo: FontInfo; readonly viewInfo: InternalEditorViewOptions; @@ -3371,11 +3443,14 @@ declare namespace monaco.editor { readonly multiCursorMergeOverlapping: boolean; readonly wordSeparators: boolean; readonly autoClosingBrackets: boolean; + readonly autoClosingQuotes: boolean; + readonly autoSurround: boolean; readonly autoIndent: boolean; readonly useTabStops: boolean; readonly tabFocusMode: boolean; readonly dragAndDrop: boolean; readonly emptySelectionClipboard: boolean; + readonly copyWithSyntaxHighlighting: boolean; readonly layoutInfo: boolean; readonly fontInfo: boolean; readonly viewInfo: boolean; @@ -3428,7 +3503,7 @@ declare namespace monaco.editor { /** * An optional dom node for the view zone that will be placed in the margin area. */ - marginDomNode?: HTMLElement; + marginDomNode?: HTMLElement | null; /** * Callback which gives the relative top of the view zone as it appears (taking scrolling into account). */ @@ -3487,7 +3562,12 @@ declare namespace monaco.editor { * Desired position for the content widget. * `preference` will also affect the placement. */ - position: IPosition; + position: IPosition | null; + /** + * Optionally, a range can be provided to further + * define the position of the content widget. + */ + range?: IRange | null; /** * Placement preference for position, in order of preference. */ @@ -3515,7 +3595,7 @@ declare namespace monaco.editor { * Get the placement of the content widget. * If null is returned, the content widget will be placed off screen. */ - getPosition(): IContentWidgetPosition; + getPosition(): IContentWidgetPosition | null; } /** @@ -3543,7 +3623,7 @@ declare namespace monaco.editor { /** * The position preference for the overlay widget. */ - preference: OverlayWidgetPositionPreference; + preference: OverlayWidgetPositionPreference | null; } /** @@ -3562,7 +3642,7 @@ declare namespace monaco.editor { * Get the placement of the overlay widget. * If null is returned, the overlay widget is responsible to place itself. */ - getPosition(): IOverlayWidgetPosition; + getPosition(): IOverlayWidgetPosition | null; } /** @@ -3634,7 +3714,7 @@ declare namespace monaco.editor { /** * The target element */ - readonly element: Element; + readonly element: Element | null; /** * The target type */ @@ -3642,7 +3722,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor position */ - readonly position: Position; + readonly position: Position | null; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -3650,7 +3730,7 @@ declare namespace monaco.editor { /** * The 'approximate' editor range */ - readonly range: Range; + readonly range: Range | null; /** * Some extra detail. */ @@ -3665,6 +3745,11 @@ declare namespace monaco.editor { readonly target: IMouseTarget; } + export interface IPartialEditorMouseEvent { + readonly event: IMouseEvent; + readonly target: IMouseTarget | null; + } + /** * A rich code editor. */ @@ -3734,6 +3819,14 @@ declare namespace monaco.editor { * @event */ onDidBlurEditorWidget(listener: () => void): IDisposable; + /** + * An event emitted after composition has started. + */ + onCompositionStart(listener: () => void): IDisposable; + /** + * An event emitted after composition has ended. + */ + onCompositionEnd(listener: () => void): IDisposable; /** * An event emitted on a "mouseup". * @event @@ -3758,7 +3851,7 @@ declare namespace monaco.editor { * An event emitted on a "mouseleave". * @event */ - onMouseLeave(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseLeave(listener: (e: IPartialEditorMouseEvent) => void): IDisposable; /** * An event emitted on a "keyup". * @event @@ -3782,7 +3875,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): ICodeEditorViewState; + saveViewState(): ICodeEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -3800,7 +3893,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): ITextModel; + getModel(): ITextModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: ITextModel | null): void; /** * Returns the current editor's configuration */ @@ -3872,15 +3974,15 @@ declare namespace monaco.editor { */ executeEdits(source: string, edits: IIdentifiedSingleEditOperation[], endCursorState?: Selection[]): boolean; /** - * Execute multiple (concommitent) commands on the editor. + * Execute multiple (concomitant) commands on the editor. * @param source The source of the call. * @param command The commands to execute */ - executeCommands(source: string, commands: ICommand[]): void; + executeCommands(source: string, commands: (ICommand | null)[]): void; /** * Get all the decorations on a line (filtering out decorations from other editors). */ - getLineDecorations(lineNumber: number): IModelDecoration[]; + getLineDecorations(lineNumber: number): IModelDecoration[] | null; /** * All decorations added through this call will get the ownerId of this editor. * @see `ITextModel.deltaDecorations` @@ -3906,14 +4008,14 @@ declare namespace monaco.editor { /** * Returns the editor's dom node */ - getDomNode(): HTMLElement; + getDomNode(): HTMLElement | null; /** * Add a content widget. Widgets must have unique ids, otherwise they will be overwritten. */ addContentWidget(widget: IContentWidget): void; /** * Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutContentWidget(widget: IContentWidget): void; /** @@ -3926,7 +4028,7 @@ declare namespace monaco.editor { addOverlayWidget(widget: IOverlayWidget): void; /** * Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition() - * and update appropiately. + * and update appropriately. */ layoutOverlayWidget(widget: IOverlayWidget): void; /** @@ -3953,19 +4055,19 @@ declare namespace monaco.editor { * * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model. */ - getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget; + getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget | null; /** * Get the visible position for `position`. * The result position takes scrolling into account and is relative to the top left corner of the editor. * Explanation 1: the results of this method will change for the same `position` if the user scrolls the editor. * Explanation 2: the results of this method will not change if the container of the editor gets repositioned. - * Warning: the results of this method are innacurate for positions that are outside the current editor viewport. + * Warning: the results of this method are inaccurate for positions that are outside the current editor viewport. */ getScrolledVisiblePosition(position: IPosition): { top: number; left: number; height: number; - }; + } | null; /** * Apply the same font settings as the editor to `target`. */ @@ -3995,7 +4097,7 @@ declare namespace monaco.editor { /** * Saves current view state of the editor in a serializable object. */ - saveViewState(): IDiffEditorViewState; + saveViewState(): IDiffEditorViewState | null; /** * Restores the view state of the editor from a serializable object generated by `saveViewState`. */ @@ -4003,7 +4105,16 @@ declare namespace monaco.editor { /** * Type the getModel() of IEditor. */ - getModel(): IDiffEditorModel; + getModel(): IDiffEditorModel | null; + /** + * Sets the current model attached to this editor. + * If the previous model was created by the editor via the value key in the options + * literal object, it will be destroyed. Otherwise, if the previous model was set + * via setModel, or the model key in the options literal object, the previous model + * will not be destroyed. + * It is safe to call setModel(null) to simply detach the current model from the editor. + */ + setModel(model: IDiffEditorModel | null): void; /** * Get the `original` editor. */ @@ -4015,17 +4126,17 @@ declare namespace monaco.editor { /** * Get the computed diff information. */ - getLineChanges(): ILineChange[]; + getLineChanges(): ILineChange[] | null; /** * Get information based on computed diff about a line number from the original model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation | null; /** * Get information based on computed diff about a line number from the modified model. * If the diff computation is not finished or the model is missing, will return null. */ - getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation; + getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation | null; } export class FontInfo extends BareFontInfo { @@ -4034,6 +4145,7 @@ declare namespace monaco.editor { readonly isMonospace: boolean; readonly typicalHalfwidthCharacterWidth: number; readonly typicalFullwidthCharacterWidth: number; + readonly canUseHalfwidthRightwardsArrow: boolean; readonly spaceWidth: number; readonly maxDigitWidth: number; } @@ -4182,7 +4294,7 @@ declare namespace monaco.languages { export function registerRenameProvider(languageId: string, provider: RenameProvider): IDisposable; /** - * Register a signature help provider (used by e.g. paremeter hints). + * Register a signature help provider (used by e.g. parameter hints). */ export function registerSignatureHelpProvider(languageId: string, provider: SignatureHelpProvider): IDisposable; @@ -4289,189 +4401,6 @@ declare namespace monaco.languages { provideCodeActions(model: editor.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (Command | CodeAction)[] | Thenable<(Command | CodeAction)[]>; } - /** - * Completion item kinds. - */ - export enum CompletionItemKind { - Text = 0, - Method = 1, - Function = 2, - Constructor = 3, - Field = 4, - Variable = 5, - Class = 6, - Interface = 7, - Module = 8, - Property = 9, - Unit = 10, - Value = 11, - Enum = 12, - Keyword = 13, - Snippet = 14, - Color = 15, - File = 16, - Reference = 17, - Folder = 18 - } - - /** - * A snippet string is a template which allows to insert text - * and to control the editor cursor when insertion happens. - * - * A snippet can define tab stops and placeholders with `$1`, `$2` - * and `${3:foo}`. `$0` defines the final tab stop, it defaults to - * the end of the snippet. Variables are defined with `$name` and - * `${name:default value}`. The full snippet syntax is documented - * [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets). - */ - export interface SnippetString { - /** - * The snippet string. - */ - value: string; - } - - /** - * A completion item represents a text snippet that is - * proposed to complete text that is being typed. - */ - export interface CompletionItem { - /** - * The label of this completion item. By default - * this is also the text that is inserted when selecting - * this completion. - */ - label: string; - /** - * The kind of this completion item. Based on the kind - * an icon is chosen by the editor. - */ - kind: CompletionItemKind; - /** - * A human-readable string with additional information - * about this item, like type or symbol information. - */ - detail?: string; - /** - * A human-readable string that represents a doc-comment. - */ - documentation?: string | IMarkdownString; - /** - * A command that should be run upon acceptance of this item. - */ - command?: Command; - /** - * A string that should be used when comparing this item - * with other items. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - sortText?: string; - /** - * A string that should be used when filtering a set of - * completion items. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - filterText?: string; - /** - * A string or snippet that should be inserted in a document when selecting - * this completion. When `falsy` the [label](#CompletionItem.label) - * is used. - */ - insertText?: string | SnippetString; - /** - * A range of text that should be replaced by this completion item. - * - * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the - * current position. - * - * *Note:* The range must be a [single line](#Range.isSingleLine) and it must - * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). - */ - range?: Range; - /** - * An optional set of characters that when pressed while this completion is active will accept it first and - * then type that character. *Note* that all commit characters should have `length=1` and that superfluous - * characters will be ignored. - */ - commitCharacters?: string[]; - /** - * @deprecated **Deprecated** in favor of `CompletionItem.insertText` and `CompletionItem.range`. - * - * ~~An [edit](#TextEdit) which is applied to a document when selecting - * this completion. When an edit is provided the value of - * [insertText](#CompletionItem.insertText) is ignored.~~ - * - * ~~The [range](#Range) of the edit must be single-line and on the same - * line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.~~ - */ - textEdit?: editor.ISingleEditOperation; - /** - * An optional array of additional text edits that are applied when - * selecting this completion. Edits must not overlap with the main edit - * nor with themselves. - */ - additionalTextEdits?: editor.ISingleEditOperation[]; - } - - /** - * Represents a collection of [completion items](#CompletionItem) to be presented - * in the editor. - */ - export interface CompletionList { - /** - * This list it not complete. Further typing should result in recomputing - * this list. - */ - isIncomplete?: boolean; - /** - * The completion items. - */ - items: CompletionItem[]; - } - - /** - * Contains additional information about the context in which - * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. - */ - export interface CompletionContext { - /** - * How the completion was triggered. - */ - triggerKind: SuggestTriggerKind; - /** - * Character that triggered the completion item provider. - * - * `undefined` if provider was not triggered by a character. - */ - triggerCharacter?: string; - } - - /** - * The completion item provider interface defines the contract between extensions and - * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). - * - * When computing *complete* completion items is expensive, providers can optionally implement - * the `resolveCompletionItem`-function. In that case it is enough to return completion - * items with a [label](#CompletionItem.label) from the - * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, - * when a completion item is shown in the UI and gains focus this provider is asked to resolve - * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). - */ - export interface CompletionItemProvider { - triggerCharacters?: string[]; - /** - * Provide completion items for the given position and document. - */ - provideCompletionItems(document: editor.ITextModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; - /** - * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) - * or [details](#CompletionItem.detail). - * - * The editor will only resolve a completion item once. - */ - resolveCompletionItem?(item: CompletionItem, token: CancellationToken): CompletionItem | Thenable; - } - /** * Describes how comments for a language work. */ @@ -4479,11 +4408,11 @@ declare namespace monaco.languages { /** * The line comment token, like `// this is a comment` */ - lineComment?: string; + lineComment?: string | null; /** * The block comment character pair, like `/* block comment */` */ - blockComment?: CharacterPair; + blockComment?: CharacterPair | null; } /** @@ -4527,6 +4456,12 @@ declare namespace monaco.languages { * settings will be used. */ surroundingPairs?: IAutoClosingPair[]; + /** + * Defines what characters must be after the cursor for bracket or quote autoclosing to occur when using the \'languageDefined\' autoclosing setting. + * + * This is typically the set of characters which can not start an expression, such as whitespace, closing brackets, non-unary operators, etc. + */ + autoCloseBefore?: string; /** * The language's folding rules. */ @@ -4544,7 +4479,7 @@ declare namespace monaco.languages { */ export interface IndentationRule { /** - * If a line matches this pattern, then all the lines after it should be unindendented once (until another rule matches). + * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches). */ decreaseIndentPattern: RegExp; /** @@ -4577,7 +4512,7 @@ declare namespace monaco.languages { */ export interface FoldingRules { /** - * Used by the indentation based strategy to decide wheter empty lines belong to the previous or the next block. + * Used by the indentation based strategy to decide whether empty lines belong to the previous or the next block. * A language adheres to the off-side rule if blocks in that language are expressed by their indentation. * See [wikipedia](https://en.wikipedia.org/wiki/Off-side_rule) for more information. * If not set, `false` is used and empty lines belong to the previous block. @@ -4601,6 +4536,10 @@ declare namespace monaco.languages { * This rule will only execute if the text after the cursor matches this regular expression. */ afterText?: RegExp; + /** + * This rule will only execute if the text above the this line matches this regular expression. + */ + oneLineAboveText?: RegExp; /** * The action to execute. */ @@ -4696,6 +4635,14 @@ declare namespace monaco.languages { equals(other: IState): boolean; } + /** + * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider), + * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves + * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a + * thenable. + */ + export type ProviderResult = T | undefined | null | Thenable; + /** * A hover represents additional information for a symbol or word. Hovers are * rendered in a tooltip-like widget. @@ -4723,18 +4670,190 @@ declare namespace monaco.languages { * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ - provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): Hover | Thenable; + provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; + } + + 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 CompletionItemInsertTextRule { + /** + * Adjust whitespace/indentation of multiline insert texts to + * match the current line indentation. + */ + KeepWhitespace = 1, + /** + * `insertText` is a snippet. + */ + InsertAsSnippet = 4 + } + + /** + * A completion item represents a text snippet that is + * proposed to complete text that is being typed. + */ + export interface CompletionItem { + /** + * The label of this completion item. By default + * this is also the text that is inserted when selecting + * this completion. + */ + label: string; + /** + * The kind of this completion item. Based on the kind + * an icon is chosen by the editor. + */ + kind: CompletionItemKind; + /** + * A human-readable string with additional information + * about this item, like type or symbol information. + */ + detail?: string; + /** + * A human-readable string that represents a doc-comment. + */ + documentation?: string | IMarkdownString; + /** + * A string that should be used when comparing this item + * with other items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + sortText?: string; + /** + * A string that should be used when filtering a set of + * completion items. When `falsy` the [label](#CompletionItem.label) + * is used. + */ + filterText?: string; + /** + * Select this item when showing. *Note* that only one completion item can be selected and + * that the editor decides which item that is. The rule is that the *first* item of those + * that match best is selected. + */ + preselect?: boolean; + /** + * A string or snippet that should be inserted in a document when selecting + * this completion. + * is used. + */ + insertText: string; + /** + * Addition rules (as bitmask) that should be applied when inserting + * this completion. + */ + insertTextRules?: CompletionItemInsertTextRule; + /** + * A range of text that should be replaced by this completion item. + * + * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the + * current position. + * + * *Note:* The range must be a [single line](#Range.isSingleLine) and it must + * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). + */ + range?: IRange; + /** + * An optional set of characters that when pressed while this completion is active will accept it first and + * then type that character. *Note* that all commit characters should have `length=1` and that superfluous + * characters will be ignored. + */ + commitCharacters?: string[]; + /** + * An optional array of additional text edits that are applied when + * selecting this completion. Edits must not overlap with the main edit + * nor with themselves. + */ + additionalTextEdits?: editor.ISingleEditOperation[]; + /** + * A command that should be run upon acceptance of this item. + */ + command?: Command; + } + + export interface CompletionList { + suggestions: CompletionItem[]; + incomplete?: boolean; + dispose?(): void; } /** * How a suggest provider was triggered. */ - export enum SuggestTriggerKind { + export enum CompletionTriggerKind { Invoke = 0, TriggerCharacter = 1, TriggerForIncompleteCompletions = 2 } + /** + * Contains additional information about the context in which + * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. + */ + export interface CompletionContext { + /** + * How the completion was triggered. + */ + triggerKind: CompletionTriggerKind; + /** + * Character that triggered the completion item provider. + * + * `undefined` if provider was not triggered by a character. + */ + triggerCharacter?: string; + } + + /** + * The completion item provider interface defines the contract between extensions and + * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). + * + * When computing *complete* completion items is expensive, providers can optionally implement + * the `resolveCompletionItem`-function. In that case it is enough to return completion + * items with a [label](#CompletionItem.label) from the + * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, + * when a completion item is shown in the UI and gains focus this provider is asked to resolve + * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). + */ + export interface CompletionItemProvider { + triggerCharacters?: string[]; + /** + * Provide completion items for the given position and document. + */ + provideCompletionItems(model: editor.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult; + /** + * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) + * or [details](#CompletionItem.detail). + * + * The editor will only resolve a completion item once. + */ + resolveCompletionItem?(model: editor.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult; + } + export interface CodeAction { title: string; command?: Command; @@ -4752,7 +4871,7 @@ declare namespace monaco.languages { * The label of this signature. Will be shown in * the UI. */ - label: string; + label: string | [number, number]; /** * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. @@ -4802,16 +4921,29 @@ declare namespace monaco.languages { activeParameter: number; } + export enum SignatureHelpTriggerReason { + Invoke = 1, + TriggerCharacter = 2, + ContentChange = 3 + } + + export interface SignatureHelpContext { + readonly triggerReason: SignatureHelpTriggerReason; + readonly triggerCharacter?: string; + readonly isRetrigger: boolean; + } + /** * The signature help provider interface defines the contract between extensions and * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { - signatureHelpTriggerCharacters: string[]; + readonly signatureHelpTriggerCharacters?: ReadonlyArray; + readonly signatureHelpRetriggerCharacters?: ReadonlyArray; /** * Provide help for the signature at the given position and document. */ - provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult; } /** @@ -4857,7 +4989,7 @@ declare namespace monaco.languages { * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ - provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4879,7 +5011,7 @@ declare namespace monaco.languages { /** * Provide a set of project-wide references for the given position and document. */ - provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult; } /** @@ -4920,7 +5052,7 @@ declare namespace monaco.languages { /** * Provide the definition of the symbol at the given position and document. */ - provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4931,7 +5063,7 @@ declare namespace monaco.languages { /** * Provide the implementation of the symbol at the given position and document. */ - provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4942,7 +5074,7 @@ declare namespace monaco.languages { /** * Provide the type definition of the symbol at the given position and document. */ - provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): Definition | DefinitionLink[] | Thenable; + provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } /** @@ -4996,14 +5128,18 @@ declare namespace monaco.languages { /** * Provide symbol information for the given document. */ - provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): DocumentSymbol[] | Thenable; + provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): ProviderResult; } - export interface TextEdit { + export type TextEdit = { range: IRange; text: string; eol?: editor.EndOfLineSequence; - } + } | { + range: undefined; + text: undefined; + eol: editor.EndOfLineSequence; + }; /** * Interface used to format a model @@ -5027,7 +5163,7 @@ declare namespace monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5042,7 +5178,7 @@ declare namespace monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5058,7 +5194,7 @@ declare namespace monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult; } /** @@ -5073,8 +5209,8 @@ declare namespace monaco.languages { * A provider of links. */ export interface LinkProvider { - provideLinks(model: editor.ITextModel, token: CancellationToken): ILink[] | Thenable; - resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable; + provideLinks(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult; } /** @@ -5142,11 +5278,11 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideDocumentColors(model: editor.ITextModel, token: CancellationToken): IColorInformation[] | Thenable; + provideDocumentColors(model: editor.ITextModel, token: CancellationToken): ProviderResult; /** * Provide the string representations for a color. */ - provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult; } export interface FoldingContext { @@ -5159,7 +5295,7 @@ declare namespace monaco.languages { /** * Provides the color ranges for a specific model. */ - provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): FoldingRange[] | Thenable; + provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult; } export interface FoldingRange { @@ -5221,7 +5357,10 @@ declare namespace monaco.languages { } export interface WorkspaceEdit { - edits: Array; + edits?: Array; + } + + export interface Rejection { rejectReason?: string; } @@ -5231,8 +5370,8 @@ declare namespace monaco.languages { } export interface RenameProvider { - provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; - resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): RenameLocation | Thenable; + provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult; + resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult; } export interface Command { @@ -5250,8 +5389,8 @@ declare namespace monaco.languages { export interface CodeLensProvider { onDidChange?: IEvent; - provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; - resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; + provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ProviderResult; + resolveCodeLens?(model: editor.ITextModel, codeLens: ICodeLensSymbol, token: CancellationToken): ProviderResult; } export interface ILanguageExtensionPoint { @@ -5296,15 +5435,15 @@ declare namespace monaco.languages { tokenPostfix?: string; } - export type IShortMonarchLanguageRule1 = [RegExp, string | IMonarchLanguageAction]; - - export type IShortMonarchLanguageRule2 = [RegExp, string | IMonarchLanguageAction, string]; - /** * A rule is either a regular expression and an action * shorthands: [reg,act] == { regex: reg, action: act} * and : [reg,act,nxt] == { regex: reg, action: act{ next: nxt }} */ + export type IShortMonarchLanguageRule1 = [RegExp, IMonarchLanguageAction]; + + export type IShortMonarchLanguageRule2 = [RegExp, IMonarchLanguageAction, string]; + export interface IExpandedMonarchLanguageRule { /** * match tokens @@ -5327,7 +5466,9 @@ declare namespace monaco.languages { * ... or a case statement with guards... * ... or a basic action with a token value. */ - export interface IMonarchLanguageAction { + export type IShortMonarchLanguageAction = string; + + export interface IExpandedMonarchLanguageAction { /** * array of actions for each parenthesized match group */ @@ -5357,7 +5498,7 @@ declare namespace monaco.languages { */ bracket?: string; /** - * switch to embedded language (useing the mimetype) or get out using "@pop" + * switch to embedded language (using the mimetype) or get out using "@pop" */ nextEmbedded?: string; /** @@ -5366,6 +5507,8 @@ declare namespace monaco.languages { log?: string; } + export type IMonarchLanguageAction = IShortMonarchLanguageAction | IExpandedMonarchLanguageAction | IShortMonarchLanguageAction[] | IExpandedMonarchLanguageAction[]; + /** * This interface can be shortened as an array, ie. ['{','}','delimiter.curly'] */ @@ -5375,7 +5518,7 @@ declare namespace monaco.languages { */ open: string; /** - * closeing bracket + * closing bracket */ close: string; /** @@ -5404,6 +5547,7 @@ declare namespace monaco.worker { } +//dtsv=2 declare namespace monaco.languages.typescript { @@ -5541,7 +5685,7 @@ declare namespace monaco.languages.typescript { * * @param content The file content * @param filePath An optional file path - * @returns A disposabled which will remove the file from the + * @returns A disposable which will remove the file from the * language service upon disposal. */ addExtraLib(content: string, filePath?: string): IDisposable; @@ -5630,7 +5774,7 @@ declare namespace monaco.languages.json { */ readonly validate?: boolean; /** - * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. + * If set, comments are tolerated. If set to false, syntax errors will be emitted for comments. */ readonly allowComments?: boolean; /** @@ -5650,6 +5794,10 @@ declare namespace monaco.languages.json { */ readonly schema?: any; }[]; + /** + * If set, the schema service would load schema content on-demand with 'fetch' if available + */ + readonly enableSchemaRequest? : boolean } export interface LanguageServiceDefaults { @@ -5660,6 +5808,7 @@ declare namespace monaco.languages.json { export var jsonDefaults: LanguageServiceDefaults; } + /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. @@ -5687,7 +5836,7 @@ declare namespace monaco.languages.html { export interface Options { /** - * If set, comments are tolerated. If set to false, syntax errors will be emmited for comments. + * If set, comments are tolerated. If set to false, syntax errors will be emitted for comments. */ readonly format?: HTMLFormatConfiguration; /**