From 99bd834f8b4d64171c85779528ccc4e065656ef8 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Thu, 4 Apr 2019 12:23:18 -0700 Subject: [PATCH] VS Code 1.33 Extension API --- types/vscode/index.d.ts | 83 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/types/vscode/index.d.ts b/types/vscode/index.d.ts index c6c1412108..b20877bb5d 100644 --- a/types/vscode/index.d.ts +++ b/types/vscode/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Visual Studio Code 1.32 +// Type definitions for Visual Studio Code 1.33 // Project: https://github.com/microsoft/vscode // Definitions by: Visual Studio Code Team, Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,7 +10,7 @@ *--------------------------------------------------------------------------------------------*/ /** - * Type Definition for Visual Studio Code 1.32 Extension API + * Type Definition for Visual Studio Code 1.33 Extension API * See https://code.visualstudio.com/api for more information */ @@ -1246,11 +1246,16 @@ declare module 'vscode' { * Create an URI from a string, e.g. `http://www.msft.com/some/path`, * `file:///usr/home`, or `scheme:with/path`. * + * *Note* that for a while uris without a `scheme` were accepted. That is not correct + * as all uris should have a scheme. To avoid breakage of existing code the optional + * `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)` + * * @see [Uri.toString](#Uri.toString) * @param value The string value of an Uri. + * @param strict Throw an error when `value` is empty or when no `scheme` can be parsed. * @return A new Uri instance. */ - static parse(value: string): Uri; + static parse(value: string, strict?: boolean): Uri; /** * Create an URI from a file system path. The [scheme](#Uri.scheme) @@ -3712,7 +3717,7 @@ declare module 'vscode' { } /** - * A line based folding range. To be valid, start and end line must a zero or larger and smaller than the number of lines in the document. + * A line based folding range. To be valid, start and end line must be bigger than zero and smaller than the number of lines in the document. * Invalid ranges will be ignored. */ export class FoldingRange { @@ -3790,6 +3795,48 @@ declare module 'vscode' { provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult; } + /** + * A selection range represents a part of a selection hierarchy. A selection range + * may have a parent selection range that contains it. + */ + export class SelectionRange { + + /** + * The [range](#Range) of this selection range. + */ + range: Range; + + /** + * The parent selection range containing this range. + */ + parent?: SelectionRange; + + /** + * Creates a new selection range. + * + * @param range The range of the selection range. + * @param parent The parent of the selection range. + */ + constructor(range: Range, parent?: SelectionRange); + } + + export interface SelectionRangeProvider { + /** + * Provide selection ranges for the given positions. + * + * Selection ranges should be computed individually and independend for each postion. The editor will merge + * and deduplicate ranges but providers must return hierarchies of selection ranges so that a range + * is [contained](#Range.contains) by its parent. + * + * @param document The document in which the command was invoked. + * @param positions The positions at which the command was invoked. + * @param token A cancellation token. + * @return Selection ranges or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + provideSelectionRanges(document: TextDocument, positions: Position[], token: CancellationToken): ProviderResult; + } + /** * A tuple of two characters, like a pair of * opening and closing brackets. @@ -4523,7 +4570,7 @@ declare module 'vscode' { * The priority of this item. Higher value means the item should * be shown more to the left. */ - readonly priority: number; + readonly priority?: number; /** * The text to show for the entry. You can embed icons in the text by leveraging the syntax: @@ -6563,10 +6610,11 @@ declare module 'vscode' { * * @param name Optional human-readable string which will be used to represent the terminal in the UI. * @param shellPath Optional path to a custom shell executable to be used in the terminal. - * @param shellArgs Optional args for the custom shell executable, this does not work on Windows (see #8429) + * @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which + * allows specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6). * @return A new Terminal. */ - export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): Terminal; + export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): Terminal; /** * Creates a [Terminal](#Terminal). The cwd of the terminal will be the workspace directory @@ -6889,9 +6937,10 @@ declare module 'vscode' { shellPath?: string; /** - * Args for the custom shell executable, this does not work on Windows (see #8429) + * Args for the custom shell executable. A string can be used on Windows only which allows + * specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6). */ - shellArgs?: string[]; + shellArgs?: string[] | string; /** * A path or Uri for the current working directory to be used for the terminal. @@ -8100,6 +8149,19 @@ declare module 'vscode' { */ export function registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable; + /** + * Register a selection range provider. + * + * Multiple providers can be registered for a language. In that case providers are asked in + * parallel and the results are merged. A failing provider (rejected promise or exception) will + * not cause a failure of the whole operation. + * + * @param selector A selector that defines the documents this provider is applicable to. + * @param provider A selection range provider. + * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + */ + export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable; + /** * Set a [language configuration](#LanguageConfiguration) for a language. * @@ -8778,9 +8840,10 @@ declare module 'vscode' { * Folder specific variables used in the configuration (e.g. '${workspaceFolder}') are resolved against the given folder. * @param folder The [workspace folder](#WorkspaceFolder) for looking up named configurations and resolving variables or `undefined` for a non-folder setup. * @param nameOrConfiguration Either the name of a debug or compound configuration or a [DebugConfiguration](#DebugConfiguration) object. + * @param parent If specified the newly created debug session is registered as a "child" session of a "parent" debug session. * @return A thenable that resolves when debugging could be successfully started. */ - export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration): Thenable; + export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration, parentSession?: DebugSession): Thenable; /** * Add breakpoints.