diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c159ad7..89bcfa2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Monaco Editor Changelog +## [0.32.0] (TBD) + +### Breaking Changes + +- The binary format for `IEncodedLineTokens` has changed to support strikethrough text. + ## [0.31.1] (14.12.2021) - Fixes [a problem with missing colors](https://github.com/microsoft/monaco-editor/issues/2822) diff --git a/package-lock.json b/package-lock.json index ba0ac521..ac330fee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1159,9 +1159,9 @@ } }, "monaco-editor-core": { - "version": "0.31.1", - "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.31.1.tgz", - "integrity": "sha512-JdwqSmTJP10bhb7qc94ehWX0C1D2R2rwCHfm+5Vd2Oh0dwjfeCAWHDelnTZ+BVbGPCb+7ZGHZvG+oYZHdmuemg==", + "version": "0.32.0-dev.20211228", + "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.32.0-dev.20211228.tgz", + "integrity": "sha512-7Cup6hu+EkpjW5Er6nSlSCQEJziJKiddd8vUJ+12Sgloo9KtnirzuoI69KeTYsFRVay8sUgeaZS0Bii0caTqSA==", "dev": true }, "mri": { diff --git a/package.json b/package.json index d667933a..b2ff8076 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "jsdom": "^18.1.0", "jsonc-parser": "^3.0.0", "mocha": "^9.1.3", - "monaco-editor-core": "0.31.1", + "monaco-editor-core": "0.32.0-dev.20211228", "playwright": "^1.16.3", "prettier": "^2.4.1", "pretty-quick": "^3.1.1", diff --git a/src/basic-languages/_.contribution.ts b/src/basic-languages/_.contribution.ts index a65501c3..0a7efdf8 100644 --- a/src/basic-languages/_.contribution.ts +++ b/src/basic-languages/_.contribution.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { languages } from '../fillers/monaco-editor-core'; +import { languages, editor } from '../fillers/monaco-editor-core'; interface ILang extends languages.ILanguageExtensionPoint { loader: () => Promise; @@ -40,10 +40,6 @@ class LazyLanguageLoader { }); } - public whenLoaded(): Promise { - return this._lazyLoadPromise; - } - public load(): Promise { if (!this._loadingTriggered) { this._loadingTriggered = true; @@ -56,8 +52,12 @@ class LazyLanguageLoader { } } -export function loadLanguage(languageId: string): Promise { - return LazyLanguageLoader.getOrCreate(languageId).load(); +export async function loadLanguage(languageId: string): Promise { + await LazyLanguageLoader.getOrCreate(languageId).load(); + + // trigger tokenizer creation by instantiating a model + const model = editor.createModel('', languageId); + model.dispose(); } export function registerLanguage(def: ILang): void { @@ -67,13 +67,14 @@ export function registerLanguage(def: ILang): void { languages.register(def); const lazyLanguageLoader = LazyLanguageLoader.getOrCreate(languageId); - languages.setMonarchTokensProvider( - languageId, - lazyLanguageLoader.whenLoaded().then((mod) => mod.language) - ); - languages.onLanguage(languageId, () => { - lazyLanguageLoader.load().then((mod) => { - languages.setLanguageConfiguration(languageId, mod.conf); - }); + languages.registerTokensProviderFactory(languageId, { + create: async (): Promise => { + const mod = await lazyLanguageLoader.load(); + return mod.language; + } + }); + languages.onLanguage(languageId, async () => { + const mod = await lazyLanguageLoader.load(); + languages.setLanguageConfiguration(languageId, mod.conf); }); } diff --git a/website/playground/monaco.d.ts.txt b/website/playground/monaco.d.ts.txt index b09b1a34..415cd57a 100644 --- a/website/playground/monaco.d.ts.txt +++ b/website/playground/monaco.d.ts.txt @@ -97,25 +97,25 @@ declare namespace monaco { export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; /** - * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'. + * scheme is the 'http' part of 'http://www.example.com/some/path?query#fragment'. * The part before the first colon. */ readonly scheme: string; /** - * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'. + * authority is the 'www.example.com' part of 'http://www.example.com/some/path?query#fragment'. * The part between the first double slashes and the next slash. */ readonly authority: string; /** - * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'. + * path is the '/some/path' part of 'http://www.example.com/some/path?query#fragment'. */ readonly path: string; /** - * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'. + * query is the 'query' part of 'http://www.example.com/some/path?query#fragment'. */ readonly query: string; /** - * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'. + * fragment is the 'fragment' part of 'http://www.example.com/some/path?query#fragment'. */ readonly fragment: string; /** @@ -151,7 +151,7 @@ declare namespace monaco { fragment?: string | null; }): Uri; /** - * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, + * Creates a new Uri from a string, e.g. `http://www.example.com/some/path`, * `file:///usr/home`, or `scheme:with/path`. * * @param value A string which represents an Uri (see `Uri#toString`). @@ -2041,32 +2041,32 @@ declare namespace monaco.editor { * An event emitted when decorations of the model have changed. * @event */ - onDidChangeDecorations(listener: (e: IModelDecorationsChangedEvent) => void): IDisposable; + readonly onDidChangeDecorations: IEvent; /** * An event emitted when the model options have changed. * @event */ - onDidChangeOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; + readonly onDidChangeOptions: IEvent; /** * An event emitted when the language associated with the model has changed. * @event */ - onDidChangeLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; + readonly onDidChangeLanguage: IEvent; /** * An event emitted when the language configuration associated with the model has changed. * @event */ - onDidChangeLanguageConfiguration(listener: (e: IModelLanguageConfigurationChangedEvent) => void): IDisposable; + readonly onDidChangeLanguageConfiguration: IEvent; /** * An event emitted when the model has been attached to the first editor or detached from the last editor. * @event */ - onDidChangeAttached(listener: () => void): IDisposable; + readonly onDidChangeAttached: IEvent; /** * An event emitted right before disposing the model. * @event */ - onWillDispose(listener: () => void): IDisposable; + readonly onWillDispose: IEvent; /** * Destroy this model. */ @@ -3888,10 +3888,12 @@ declare namespace monaco.editor { invisibleCharacters?: boolean; ambiguousCharacters?: boolean; includeComments?: boolean | InUntrustedWorkspace; + includeStrings?: boolean | InUntrustedWorkspace; /** * A map of allowed characters (true: allowed). */ allowedCharacters?: Record; + allowedLocales?: Record; } export interface IInlineSuggestOptions { @@ -4772,140 +4774,140 @@ declare namespace monaco.editor { * An event emitted when the content of the current model has changed. * @event */ - onDidChangeModelContent: IEvent; + readonly onDidChangeModelContent: IEvent; /** * An event emitted when the language of the current model has changed. * @event */ - onDidChangeModelLanguage: IEvent; + readonly onDidChangeModelLanguage: IEvent; /** * An event emitted when the language configuration of the current model has changed. * @event */ - onDidChangeModelLanguageConfiguration: IEvent; + readonly onDidChangeModelLanguageConfiguration: IEvent; /** * An event emitted when the options of the current model has changed. * @event */ - onDidChangeModelOptions: IEvent; + readonly onDidChangeModelOptions: IEvent; /** * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) * @event */ - onDidChangeConfiguration: IEvent; + readonly onDidChangeConfiguration: IEvent; /** * An event emitted when the cursor position has changed. * @event */ - onDidChangeCursorPosition: IEvent; + readonly onDidChangeCursorPosition: IEvent; /** * An event emitted when the cursor selection has changed. * @event */ - onDidChangeCursorSelection: IEvent; + readonly onDidChangeCursorSelection: IEvent; /** * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`). * @event */ - onDidChangeModel: IEvent; + readonly onDidChangeModel: IEvent; /** * An event emitted when the decorations of the current model have changed. * @event */ - onDidChangeModelDecorations: IEvent; + readonly onDidChangeModelDecorations: IEvent; /** * An event emitted when the text inside this editor gained focus (i.e. cursor starts blinking). * @event */ - onDidFocusEditorText(listener: () => void): IDisposable; + readonly onDidFocusEditorText: IEvent; /** * An event emitted when the text inside this editor lost focus (i.e. cursor stops blinking). * @event */ - onDidBlurEditorText(listener: () => void): IDisposable; + readonly onDidBlurEditorText: IEvent; /** * An event emitted when the text inside this editor or an editor widget gained focus. * @event */ - onDidFocusEditorWidget(listener: () => void): IDisposable; + readonly onDidFocusEditorWidget: IEvent; /** * An event emitted when the text inside this editor or an editor widget lost focus. * @event */ - onDidBlurEditorWidget(listener: () => void): IDisposable; + readonly onDidBlurEditorWidget: IEvent; /** * An event emitted after composition has started. */ - onDidCompositionStart(listener: () => void): IDisposable; + readonly onDidCompositionStart: IEvent; /** * An event emitted after composition has ended. */ - onDidCompositionEnd(listener: () => void): IDisposable; + readonly onDidCompositionEnd: IEvent; /** * An event emitted when editing failed because the editor is read-only. * @event */ - onDidAttemptReadOnlyEdit(listener: () => void): IDisposable; + readonly onDidAttemptReadOnlyEdit: IEvent; /** * An event emitted when users paste text in the editor. * @event */ - onDidPaste: IEvent; + readonly onDidPaste: IEvent; /** * An event emitted on a "mouseup". * @event */ - onMouseUp: IEvent; + readonly onMouseUp: IEvent; /** * An event emitted on a "mousedown". * @event */ - onMouseDown: IEvent; + readonly onMouseDown: IEvent; /** * An event emitted on a "contextmenu". * @event */ - onContextMenu: IEvent; + readonly onContextMenu: IEvent; /** * An event emitted on a "mousemove". * @event */ - onMouseMove: IEvent; + readonly onMouseMove: IEvent; /** * An event emitted on a "mouseleave". * @event */ - onMouseLeave: IEvent; + readonly onMouseLeave: IEvent; /** * An event emitted on a "keyup". * @event */ - onKeyUp: IEvent; + readonly onKeyUp: IEvent; /** * An event emitted on a "keydown". * @event */ - onKeyDown: IEvent; + readonly onKeyDown: IEvent; /** * An event emitted when the layout of the editor has changed. * @event */ - onDidLayoutChange: IEvent; + readonly onDidLayoutChange: IEvent; /** * An event emitted when the content width or content height in the editor has changed. * @event */ - onDidContentSizeChange: IEvent; + readonly onDidContentSizeChange: IEvent; /** * An event emitted when the scroll in the editor has changed. * @event */ - onDidScrollChange: IEvent; + readonly onDidScrollChange: IEvent; /** * An event emitted when hidden areas change in the editor (e.g. due to folding). * @event */ - onDidChangeHiddenAreas: IEvent; + readonly onDidChangeHiddenAreas: IEvent; /** * Saves current view state of the editor in a serializable object. */ @@ -4923,7 +4925,7 @@ declare namespace monaco.editor { * @id Unique identifier of the contribution. * @return The contribution or null if contribution not found. */ - getContribution(id: string): T; + getContribution(id: string): T | null; /** * Type the getModel() of IEditor. */ @@ -5154,7 +5156,7 @@ declare namespace monaco.editor { * An event emitted when the diff information computed by this diff editor has been updated. * @event */ - onDidUpdateDiff(listener: () => void): IDisposable; + readonly onDidUpdateDiff: IEvent; /** * Saves current view state of the editor in a serializable object. */ @@ -5297,11 +5299,11 @@ declare namespace monaco.languages { * 3322 2222 2222 1111 1111 1100 0000 0000 * 1098 7654 3210 9876 5432 1098 7654 3210 * - ------------------------------------------- - * bbbb bbbb bfff ffff ffFF FTTT LLLL LLLL + * bbbb bbbb bfff ffff ffFF FFTT LLLL LLLL * - ------------------------------------------- * - L = EncodedLanguageId (8 bits): Use `getEncodedLanguageId` to get the encoded ID of a language. - * - T = StandardTokenType (3 bits): Other = 0, Comment = 1, String = 2, RegEx = 4. - * - F = FontStyle (3 bits): None = 0, Italic = 1, Bold = 2, Underline = 4. + * - T = StandardTokenType (2 bits): Other = 0, Comment = 1, String = 2, RegEx = 3. + * - F = FontStyle (4 bits): None = 0, Italic = 1, Bold = 2, Underline = 4, Strikethrough = 8. * - f = foreground ColorId (9 bits) * - b = background ColorId (9 bits) * - The color value for each colorId is defined in IStandaloneThemeData.customTokenColors: @@ -5316,6 +5318,13 @@ declare namespace monaco.languages { endState: IState; } + /** + * A factory for token providers. + */ + export interface TokensProviderFactory { + create(): ProviderResult; + } + /** * A "manual" provider of tokens. */ @@ -5355,12 +5364,25 @@ declare namespace monaco.languages { export function setColorMap(colorMap: string[] | null): void; /** - * Set the tokens provider for a language (manual implementation). + * Register a tokens provider factory for a language. This tokenizer will be exclusive with a tokenizer + * set using `setTokensProvider` or one created using `setMonarchTokensProvider`, but will work together + * with a tokens provider set using `registerDocumentSemanticTokensProvider` or `registerDocumentRangeSemanticTokensProvider`. + */ + export function registerTokensProviderFactory(languageId: string, factory: TokensProviderFactory): IDisposable; + + /** + * Set the tokens provider for a language (manual implementation). This tokenizer will be exclusive + * with a tokenizer created using `setMonarchTokensProvider`, or with `registerTokensProviderFactory`, + * but will work together with a tokens provider set using `registerDocumentSemanticTokensProvider` + * or `registerDocumentRangeSemanticTokensProvider`. */ export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider | Thenable): IDisposable; /** - * Set the tokens provider for a language (monarch implementation). + * Set the tokens provider for a language (monarch implementation). This tokenizer will be exclusive + * with a tokenizer set using `setTokensProvider`, or with `registerTokensProviderFactory`, but will + * work together with a tokens provider set using `registerDocumentSemanticTokensProvider` or + * `registerDocumentRangeSemanticTokensProvider`. */ export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage | Thenable): IDisposable; @@ -5470,12 +5492,20 @@ declare namespace monaco.languages { export function registerSelectionRangeProvider(languageId: string, provider: SelectionRangeProvider): IDisposable; /** - * Register a document semantic tokens provider + * Register a document semantic tokens provider. A semantic tokens provider will complement and enhance a + * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider` + * or `setTokensProvider`. + * + * For the best user experience, register both a semantic tokens provider and a top-down tokenizer. */ export function registerDocumentSemanticTokensProvider(languageId: string, provider: DocumentSemanticTokensProvider): IDisposable; /** - * Register a document range semantic tokens provider + * Register a document range semantic tokens provider. A semantic tokens provider will complement and enhance a + * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider` + * or `setTokensProvider`. + * + * For the best user experience, register both a semantic tokens provider and a top-down tokenizer. */ export function registerDocumentRangeSemanticTokensProvider(languageId: string, provider: DocumentRangeSemanticTokensProvider): IDisposable; diff --git a/website/typedoc/monaco.d.ts b/website/typedoc/monaco.d.ts index b09b1a34..415cd57a 100644 --- a/website/typedoc/monaco.d.ts +++ b/website/typedoc/monaco.d.ts @@ -97,25 +97,25 @@ declare namespace monaco { export class Uri implements UriComponents { static isUri(thing: any): thing is Uri; /** - * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'. + * scheme is the 'http' part of 'http://www.example.com/some/path?query#fragment'. * The part before the first colon. */ readonly scheme: string; /** - * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'. + * authority is the 'www.example.com' part of 'http://www.example.com/some/path?query#fragment'. * The part between the first double slashes and the next slash. */ readonly authority: string; /** - * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'. + * path is the '/some/path' part of 'http://www.example.com/some/path?query#fragment'. */ readonly path: string; /** - * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'. + * query is the 'query' part of 'http://www.example.com/some/path?query#fragment'. */ readonly query: string; /** - * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'. + * fragment is the 'fragment' part of 'http://www.example.com/some/path?query#fragment'. */ readonly fragment: string; /** @@ -151,7 +151,7 @@ declare namespace monaco { fragment?: string | null; }): Uri; /** - * Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`, + * Creates a new Uri from a string, e.g. `http://www.example.com/some/path`, * `file:///usr/home`, or `scheme:with/path`. * * @param value A string which represents an Uri (see `Uri#toString`). @@ -2041,32 +2041,32 @@ declare namespace monaco.editor { * An event emitted when decorations of the model have changed. * @event */ - onDidChangeDecorations(listener: (e: IModelDecorationsChangedEvent) => void): IDisposable; + readonly onDidChangeDecorations: IEvent; /** * An event emitted when the model options have changed. * @event */ - onDidChangeOptions(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; + readonly onDidChangeOptions: IEvent; /** * An event emitted when the language associated with the model has changed. * @event */ - onDidChangeLanguage(listener: (e: IModelLanguageChangedEvent) => void): IDisposable; + readonly onDidChangeLanguage: IEvent; /** * An event emitted when the language configuration associated with the model has changed. * @event */ - onDidChangeLanguageConfiguration(listener: (e: IModelLanguageConfigurationChangedEvent) => void): IDisposable; + readonly onDidChangeLanguageConfiguration: IEvent; /** * An event emitted when the model has been attached to the first editor or detached from the last editor. * @event */ - onDidChangeAttached(listener: () => void): IDisposable; + readonly onDidChangeAttached: IEvent; /** * An event emitted right before disposing the model. * @event */ - onWillDispose(listener: () => void): IDisposable; + readonly onWillDispose: IEvent; /** * Destroy this model. */ @@ -3888,10 +3888,12 @@ declare namespace monaco.editor { invisibleCharacters?: boolean; ambiguousCharacters?: boolean; includeComments?: boolean | InUntrustedWorkspace; + includeStrings?: boolean | InUntrustedWorkspace; /** * A map of allowed characters (true: allowed). */ allowedCharacters?: Record; + allowedLocales?: Record; } export interface IInlineSuggestOptions { @@ -4772,140 +4774,140 @@ declare namespace monaco.editor { * An event emitted when the content of the current model has changed. * @event */ - onDidChangeModelContent: IEvent; + readonly onDidChangeModelContent: IEvent; /** * An event emitted when the language of the current model has changed. * @event */ - onDidChangeModelLanguage: IEvent; + readonly onDidChangeModelLanguage: IEvent; /** * An event emitted when the language configuration of the current model has changed. * @event */ - onDidChangeModelLanguageConfiguration: IEvent; + readonly onDidChangeModelLanguageConfiguration: IEvent; /** * An event emitted when the options of the current model has changed. * @event */ - onDidChangeModelOptions: IEvent; + readonly onDidChangeModelOptions: IEvent; /** * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`) * @event */ - onDidChangeConfiguration: IEvent; + readonly onDidChangeConfiguration: IEvent; /** * An event emitted when the cursor position has changed. * @event */ - onDidChangeCursorPosition: IEvent; + readonly onDidChangeCursorPosition: IEvent; /** * An event emitted when the cursor selection has changed. * @event */ - onDidChangeCursorSelection: IEvent; + readonly onDidChangeCursorSelection: IEvent; /** * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`). * @event */ - onDidChangeModel: IEvent; + readonly onDidChangeModel: IEvent; /** * An event emitted when the decorations of the current model have changed. * @event */ - onDidChangeModelDecorations: IEvent; + readonly onDidChangeModelDecorations: IEvent; /** * An event emitted when the text inside this editor gained focus (i.e. cursor starts blinking). * @event */ - onDidFocusEditorText(listener: () => void): IDisposable; + readonly onDidFocusEditorText: IEvent; /** * An event emitted when the text inside this editor lost focus (i.e. cursor stops blinking). * @event */ - onDidBlurEditorText(listener: () => void): IDisposable; + readonly onDidBlurEditorText: IEvent; /** * An event emitted when the text inside this editor or an editor widget gained focus. * @event */ - onDidFocusEditorWidget(listener: () => void): IDisposable; + readonly onDidFocusEditorWidget: IEvent; /** * An event emitted when the text inside this editor or an editor widget lost focus. * @event */ - onDidBlurEditorWidget(listener: () => void): IDisposable; + readonly onDidBlurEditorWidget: IEvent; /** * An event emitted after composition has started. */ - onDidCompositionStart(listener: () => void): IDisposable; + readonly onDidCompositionStart: IEvent; /** * An event emitted after composition has ended. */ - onDidCompositionEnd(listener: () => void): IDisposable; + readonly onDidCompositionEnd: IEvent; /** * An event emitted when editing failed because the editor is read-only. * @event */ - onDidAttemptReadOnlyEdit(listener: () => void): IDisposable; + readonly onDidAttemptReadOnlyEdit: IEvent; /** * An event emitted when users paste text in the editor. * @event */ - onDidPaste: IEvent; + readonly onDidPaste: IEvent; /** * An event emitted on a "mouseup". * @event */ - onMouseUp: IEvent; + readonly onMouseUp: IEvent; /** * An event emitted on a "mousedown". * @event */ - onMouseDown: IEvent; + readonly onMouseDown: IEvent; /** * An event emitted on a "contextmenu". * @event */ - onContextMenu: IEvent; + readonly onContextMenu: IEvent; /** * An event emitted on a "mousemove". * @event */ - onMouseMove: IEvent; + readonly onMouseMove: IEvent; /** * An event emitted on a "mouseleave". * @event */ - onMouseLeave: IEvent; + readonly onMouseLeave: IEvent; /** * An event emitted on a "keyup". * @event */ - onKeyUp: IEvent; + readonly onKeyUp: IEvent; /** * An event emitted on a "keydown". * @event */ - onKeyDown: IEvent; + readonly onKeyDown: IEvent; /** * An event emitted when the layout of the editor has changed. * @event */ - onDidLayoutChange: IEvent; + readonly onDidLayoutChange: IEvent; /** * An event emitted when the content width or content height in the editor has changed. * @event */ - onDidContentSizeChange: IEvent; + readonly onDidContentSizeChange: IEvent; /** * An event emitted when the scroll in the editor has changed. * @event */ - onDidScrollChange: IEvent; + readonly onDidScrollChange: IEvent; /** * An event emitted when hidden areas change in the editor (e.g. due to folding). * @event */ - onDidChangeHiddenAreas: IEvent; + readonly onDidChangeHiddenAreas: IEvent; /** * Saves current view state of the editor in a serializable object. */ @@ -4923,7 +4925,7 @@ declare namespace monaco.editor { * @id Unique identifier of the contribution. * @return The contribution or null if contribution not found. */ - getContribution(id: string): T; + getContribution(id: string): T | null; /** * Type the getModel() of IEditor. */ @@ -5154,7 +5156,7 @@ declare namespace monaco.editor { * An event emitted when the diff information computed by this diff editor has been updated. * @event */ - onDidUpdateDiff(listener: () => void): IDisposable; + readonly onDidUpdateDiff: IEvent; /** * Saves current view state of the editor in a serializable object. */ @@ -5297,11 +5299,11 @@ declare namespace monaco.languages { * 3322 2222 2222 1111 1111 1100 0000 0000 * 1098 7654 3210 9876 5432 1098 7654 3210 * - ------------------------------------------- - * bbbb bbbb bfff ffff ffFF FTTT LLLL LLLL + * bbbb bbbb bfff ffff ffFF FFTT LLLL LLLL * - ------------------------------------------- * - L = EncodedLanguageId (8 bits): Use `getEncodedLanguageId` to get the encoded ID of a language. - * - T = StandardTokenType (3 bits): Other = 0, Comment = 1, String = 2, RegEx = 4. - * - F = FontStyle (3 bits): None = 0, Italic = 1, Bold = 2, Underline = 4. + * - T = StandardTokenType (2 bits): Other = 0, Comment = 1, String = 2, RegEx = 3. + * - F = FontStyle (4 bits): None = 0, Italic = 1, Bold = 2, Underline = 4, Strikethrough = 8. * - f = foreground ColorId (9 bits) * - b = background ColorId (9 bits) * - The color value for each colorId is defined in IStandaloneThemeData.customTokenColors: @@ -5316,6 +5318,13 @@ declare namespace monaco.languages { endState: IState; } + /** + * A factory for token providers. + */ + export interface TokensProviderFactory { + create(): ProviderResult; + } + /** * A "manual" provider of tokens. */ @@ -5355,12 +5364,25 @@ declare namespace monaco.languages { export function setColorMap(colorMap: string[] | null): void; /** - * Set the tokens provider for a language (manual implementation). + * Register a tokens provider factory for a language. This tokenizer will be exclusive with a tokenizer + * set using `setTokensProvider` or one created using `setMonarchTokensProvider`, but will work together + * with a tokens provider set using `registerDocumentSemanticTokensProvider` or `registerDocumentRangeSemanticTokensProvider`. + */ + export function registerTokensProviderFactory(languageId: string, factory: TokensProviderFactory): IDisposable; + + /** + * Set the tokens provider for a language (manual implementation). This tokenizer will be exclusive + * with a tokenizer created using `setMonarchTokensProvider`, or with `registerTokensProviderFactory`, + * but will work together with a tokens provider set using `registerDocumentSemanticTokensProvider` + * or `registerDocumentRangeSemanticTokensProvider`. */ export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider | Thenable): IDisposable; /** - * Set the tokens provider for a language (monarch implementation). + * Set the tokens provider for a language (monarch implementation). This tokenizer will be exclusive + * with a tokenizer set using `setTokensProvider`, or with `registerTokensProviderFactory`, but will + * work together with a tokens provider set using `registerDocumentSemanticTokensProvider` or + * `registerDocumentRangeSemanticTokensProvider`. */ export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage | Thenable): IDisposable; @@ -5470,12 +5492,20 @@ declare namespace monaco.languages { export function registerSelectionRangeProvider(languageId: string, provider: SelectionRangeProvider): IDisposable; /** - * Register a document semantic tokens provider + * Register a document semantic tokens provider. A semantic tokens provider will complement and enhance a + * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider` + * or `setTokensProvider`. + * + * For the best user experience, register both a semantic tokens provider and a top-down tokenizer. */ export function registerDocumentSemanticTokensProvider(languageId: string, provider: DocumentSemanticTokensProvider): IDisposable; /** - * Register a document range semantic tokens provider + * Register a document range semantic tokens provider. A semantic tokens provider will complement and enhance a + * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider` + * or `setTokensProvider`. + * + * For the best user experience, register both a semantic tokens provider and a top-down tokenizer. */ export function registerDocumentRangeSemanticTokensProvider(languageId: string, provider: DocumentRangeSemanticTokensProvider): IDisposable;