-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
266ff5b
commit 2fdae24
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
declare module 'vscode' { | ||
// https://github.com/microsoft/vscode/issues/162950 | ||
|
||
/** | ||
* Registers a provider that enables quick fix actions to be shown based on | ||
* commands and their output | ||
* @param provider The provider that provides the quick fixes. | ||
* @return Disposable that unregisters the provider. | ||
*/ | ||
export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable; | ||
|
||
/** | ||
* A provider for terminal quick fixes. | ||
*/ | ||
export interface TerminalQuickFixProvider { | ||
/** | ||
* Provide terminal quick fixes | ||
* @param options that specify when the fix should apply and the call back to run | ||
* for matches | ||
* @param token A cancellation token. | ||
*/ | ||
provideTerminalQuickFixes(options: TerminalQuickFixOptions[], token: CancellationToken): void; | ||
} | ||
|
||
interface TerminalQuickFixOptions { | ||
commandLineMatcher: string | RegExp; | ||
outputMatcher?: TerminalOutputMatcher; | ||
getQuickFixes: TerminalQuickFixCallback; | ||
exitStatus?: boolean; | ||
} | ||
export type TerminalQuickFixMatchResult = { commandLineMatch: RegExpMatchArray; outputMatch?: RegExpMatchArray | null }; | ||
export type TerminalQuickFixAction = Action | TerminalQuickFixCommandAction | TerminalQuickFixOpenerAction; | ||
export type TerminalQuickFixCallback = (matchResult: TerminalQuickFixMatchResult, command: string) => TerminalQuickFixAction[] | TerminalQuickFixAction | undefined; | ||
|
||
interface Action { | ||
readonly id: string; | ||
label: string; | ||
tooltip: string; | ||
class: string | undefined; | ||
enabled: boolean; | ||
checked?: boolean; | ||
run(event?: unknown): unknown; | ||
} | ||
export interface TerminalQuickFixCommandAction { | ||
type: 'command'; | ||
command: string; | ||
addNewLine: boolean; | ||
} | ||
export interface TerminalQuickFixOpenerAction { | ||
type: 'opener'; | ||
uri: Uri; | ||
} | ||
const enum TerminalOutputMatcherAnchor { | ||
Top = 'top', | ||
Bottom = 'bototm' | ||
} | ||
export interface TerminalOutputMatcher { | ||
/** | ||
* A string or regex to match against the unwrapped line. If this is a regex with the multiline | ||
* flag, it will scan an amount of lines equal to `\n` instances in the regex + 1. | ||
*/ | ||
lineMatcher: string | RegExp; | ||
/** | ||
* Which side of the output to anchor the {@link offset} and {@link length} against. | ||
*/ | ||
anchor: TerminalOutputMatcherAnchor; | ||
/** | ||
* How far from either the top or the bottom of the butter to start matching against. | ||
*/ | ||
offset: number; | ||
/** | ||
* The number of rows to match against, this should be as small as possible for performance | ||
* reasons. | ||
*/ | ||
length: number; | ||
} | ||
} | ||
|