Skip to content

Commit

Permalink
Finalize terminal link providers
Browse files Browse the repository at this point in the history
Fixes #91290
  • Loading branch information
Tyriar committed Aug 10, 2020
1 parent dbdb5bd commit 6ad6379
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 59 deletions.
67 changes: 67 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5420,6 +5420,66 @@ declare module 'vscode' {
dispose(): void;
}

/**
* Provides information on a line in a terminal in order to provide links for it.
*/
export interface TerminalLinkContext {
/**
* This is the text from the unwrapped line in the terminal.
*/
line: string;

/**
* The terminal the link belongs to.
*/
terminal: Terminal;
}

/**
* A provider that enables detection and handling of links within terminals.
*/
export interface TerminalLinkProvider<T extends TerminalLink = TerminalLink> {
/**
* Provide terminal links for the given context. Note that this can be called multiple times
* even before previous calls resolve, make sure to not share global objects (eg. `RegExp`)
* that could have problems when asynchronous usage may overlap.
* @param context Information about what links are being provided for.
* @param token A cancellation token.
* @return A list of terminal links for the given line.
*/
provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<T[]>

/**
* Handle an activated terminal link.
* @param link The link to handle.
*/
handleTerminalLink(link: T): ProviderResult<void>;
}

/**
* A link on a terminal line.
*/
export interface TerminalLink {
/**
* The start index of the link on [TerminalLinkContext.line](#TerminalLinkContext.line].
*/
startIndex: number;

/**
* The length of the link on [TerminalLinkContext.line](#TerminalLinkContext.line]
*/
length: number;

/**
* The tooltip text when you hover over this link.
*
* If a tooltip is provided, is will be displayed in a string that includes instructions on
* how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
* depending on OS, user settings, and localization.
*/
tooltip?: string;
}

/**
* In a remote window the extension kind describes if an extension
* runs where the UI (window) runs or if an extension runs remotely.
Expand Down Expand Up @@ -8184,6 +8244,13 @@ declare module 'vscode' {
readonly supportsMultipleEditorsPerDocument?: boolean;
}): Disposable;

/**
* Register provider that enables the detection and handling of links within the terminal.
* @param provider The provider that provides the terminal links.
* @return Disposable that unregisters the provider.
*/
export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;

/**
* The currently active color theme as configured in the settings. The active
* theme can be changed via the `workbench.colorTheme` setting.
Expand Down
58 changes: 0 additions & 58 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,64 +956,6 @@ declare module 'vscode' {

//#endregion

//#region Terminal link provider https://github.com/microsoft/vscode/issues/91606

export namespace window {
export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;
}

export interface TerminalLinkContext {
/**
* This is the text from the unwrapped line in the terminal.
*/
line: string;

/**
* The terminal the link belongs to.
*/
terminal: Terminal;
}

export interface TerminalLinkProvider<T extends TerminalLink = TerminalLink> {
/**
* Provide terminal links for the given context. Note that this can be called multiple times
* even before previous calls resolve, make sure to not share global objects (eg. `RegExp`)
* that could have problems when asynchronous usage may overlap.
* @param context Information about what links are being provided for.
* @param token A cancellation token.
* @return A list of terminal links for the given line.
*/
provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<T[]>

/**
* Handle an activated terminal link.
*/
handleTerminalLink(link: T): ProviderResult<void>;
}

export interface TerminalLink {
/**
* The start index of the link on [TerminalLinkContext.line](#TerminalLinkContext.line].
*/
startIndex: number;

/**
* The length of the link on [TerminalLinkContext.line](#TerminalLinkContext.line]
*/
length: number;

/**
* The tooltip text when you hover over this link.
*
* If a tooltip is provided, is will be displayed in a string that includes instructions on
* how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
* depending on OS, user settings, and localization.
*/
tooltip?: string;
}

//#endregion

//#region @jrieken -> exclusive document filters

export interface DocumentFilter {
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostTerminalService.registerLinkHandler(handler);
},
registerTerminalLinkProvider(handler: vscode.TerminalLinkProvider): vscode.Disposable {
checkProposedApiEnabled(extension);
return extHostTerminalService.registerLinkProvider(handler);
},
registerTreeDataProvider(viewId: string, treeDataProvider: vscode.TreeDataProvider<any>): vscode.Disposable {
Expand Down

0 comments on commit 6ad6379

Please sign in to comment.