Skip to content

Commit

Permalink
Merge pull request #126053 from microsoft/tyriar/126040
Browse files Browse the repository at this point in the history
Convert TerminalLink to class, add TerminalProfile validation
  • Loading branch information
Tyriar authored Jun 15, 2021
2 parents 0eda7c6 + 407be8f commit 50652b9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5801,7 +5801,7 @@ declare module 'vscode' {
/**
* A link on a terminal line.
*/
export interface TerminalLink {
export class TerminalLink {
/**
* The start index of the link on {@link TerminalLinkContext.line}.
*/
Expand All @@ -5820,6 +5820,18 @@ declare module 'vscode' {
* depending on OS, user settings, and localization.
*/
tooltip?: string;

/**
* Creates a new terminal link.
* @param startIndex The start index of the link on {@link TerminalLinkContext.line}.
* @param length The length of the link on {@link TerminalLinkContext.line}.
* @param tooltip 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.
*/
constructor(startIndex: number, length: number, tooltip?: string);
}

/**
Expand All @@ -5844,6 +5856,10 @@ declare module 'vscode' {
*/
options: TerminalOptions | ExtensionTerminalOptions;

/**
* Creates a new terminal profile.
* @param options The options that the terminal will launch with.
*/
constructor(options: TerminalOptions | ExtensionTerminalOptions);
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TaskPanelKind: extHostTypes.TaskPanelKind,
TaskRevealKind: extHostTypes.TaskRevealKind,
TaskScope: extHostTypes.TaskScope,
TerminalLink: extHostTypes.TerminalLink,
TerminalProfile: extHostTypes.TerminalProfile,
TextDocumentSaveReason: extHostTypes.TextDocumentSaveReason,
TextEdit: extHostTypes.TextEdit,
Expand Down
21 changes: 21 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1707,10 +1707,31 @@ export enum SourceControlInputBoxValidationType {
Information = 2
}

export class TerminalLink implements vscode.TerminalLink {
constructor(
public startIndex: number,
public length: number,
public tooltip?: string
) {
if (typeof startIndex !== 'number' || startIndex < 0) {
throw illegalArgument('startIndex');
}
if (typeof length !== 'number' || length < 1) {
throw illegalArgument('length');
}
if (tooltip !== undefined && typeof tooltip !== 'string') {
throw illegalArgument('tooltip');
}
}
}

export class TerminalProfile implements vscode.TerminalProfile {
constructor(
public options: vscode.TerminalOptions | vscode.ExtensionTerminalOptions
) {
if (typeof options !== 'object') {
illegalArgument('options');
}
}
}

Expand Down

0 comments on commit 50652b9

Please sign in to comment.