Skip to content

Commit

Permalink
Add TerminalQuickFixProvider API stubbing
Browse files Browse the repository at this point in the history
The commit adds the stubbing for the proposed `TerminalQuickFixProvider`
API which was necessary for the `vscode.npm` builtin to successfully
activate at version `v1.77.0`.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed May 15, 2023
1 parent 15e7cd9 commit 30c9312
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ export function createAPIFactory(
},
get tabGroups(): theia.TabGroups {
return tabsExt.tabGroups;
},
registerTerminalQuickFixProvider(id: string, provider: theia.TerminalQuickFixProvider): theia.Disposable {
return terminalExt.registerTerminalQuickFixProvider(id, provider);
}
};

Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-ext/src/plugin/terminal-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
});
}

/** @stubbed */
registerTerminalQuickFixProvider(id: string, provider: theia.TerminalQuickFixProvider): theia.Disposable {
return Disposable.NULL;
}

protected isExtensionTerminalOptions(options: theia.TerminalOptions | theia.ExtensionTerminalOptions): options is theia.ExtensionTerminalOptions {
return 'pty' in options;
}
Expand Down
40 changes: 40 additions & 0 deletions packages/plugin/src/theia-proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,46 @@ export module '@theia/plugin' {
}

// #endregion

// #region TerminalQuickFixProvider

export namespace window {
/**
* @param provider A terminal quick fix provider
* @return A {@link Disposable} that un-registers the provider when being disposed
*/
export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable;
}

export interface TerminalQuickFixProvider {
/**
* Provides terminal quick fixes
* @param commandMatchResult The command match result for which to provide quick fixes
* @param token A cancellation token indicating the result is no longer needed
* @return Terminal quick fix(es) if any
*/
provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): TerminalQuickFix[] | TerminalQuickFix | undefined;
}

export interface TerminalCommandMatchResult {
commandLine: string;
commandLineMatch: RegExpMatchArray;
outputMatch?: {
regexMatch: RegExpMatchArray;
outputLines?: string[];
};
}

interface TerminalQuickFix {
type: TerminalQuickFixType;
}

enum TerminalQuickFixType {
command = 'command',
opener = 'opener'
}

// #endRegion TerminalQuickFixProvider
}

/**
Expand Down

0 comments on commit 30c9312

Please sign in to comment.