Merge pull request #2205 from github/koesie10/results-view-typed-commands
Convert results view commands to typed commands
This commit is contained in:
Коммит
b2fceb9b2d
|
@ -53,6 +53,15 @@ export type LocalQueryCommands = {
|
|||
"codeQL.quickQuery": () => Promise<void>;
|
||||
};
|
||||
|
||||
export type ResultsViewCommands = {
|
||||
"codeQLQueryResults.up": () => Promise<void>;
|
||||
"codeQLQueryResults.down": () => Promise<void>;
|
||||
"codeQLQueryResults.left": () => Promise<void>;
|
||||
"codeQLQueryResults.right": () => Promise<void>;
|
||||
"codeQLQueryResults.nextPathStep": () => Promise<void>;
|
||||
"codeQLQueryResults.previousPathStep": () => Promise<void>;
|
||||
};
|
||||
|
||||
// Commands used for the query history panel
|
||||
export type QueryHistoryCommands = {
|
||||
// Commands in the "navigation" group
|
||||
|
@ -196,6 +205,7 @@ export type SummaryLanguageSupportCommands = {
|
|||
};
|
||||
|
||||
export type AllCommands = BaseCommands &
|
||||
ResultsViewCommands &
|
||||
QueryHistoryCommands &
|
||||
LocalDatabasesCommands &
|
||||
VariantAnalysisCommands &
|
||||
|
|
|
@ -826,6 +826,7 @@ async function activateWithInstalledDistribution(
|
|||
|
||||
const allCommands: AllCommands = {
|
||||
...getCommands(cliServer, qs),
|
||||
...localQueryResultsView.getCommands(),
|
||||
...qhm.getCommands(),
|
||||
...variantAnalysisManager.getCommands(),
|
||||
...databaseUI.getCommands(),
|
||||
|
|
|
@ -42,7 +42,6 @@ import {
|
|||
ParsedResultSets,
|
||||
} from "./pure/interface-types";
|
||||
import { Logger } from "./common";
|
||||
import { commandRunner } from "./commandRunner";
|
||||
import {
|
||||
CompletedQueryInfo,
|
||||
interpretResultsSarif,
|
||||
|
@ -72,6 +71,7 @@ import { isCanary, PAGE_SIZE } from "./config";
|
|||
import { HistoryItemLabelProvider } from "./query-history/history-item-label-provider";
|
||||
import { telemetryListener } from "./telemetry";
|
||||
import { redactableError } from "./pure/errors";
|
||||
import { ResultsViewCommands } from "./common/commands";
|
||||
|
||||
/**
|
||||
* interface.ts
|
||||
|
@ -179,21 +179,6 @@ export class ResultsView extends AbstractWebview<
|
|||
this.handleSelectionChange.bind(this),
|
||||
),
|
||||
);
|
||||
const navigationCommands = {
|
||||
"codeQLQueryResults.up": NavigationDirection.up,
|
||||
"codeQLQueryResults.down": NavigationDirection.down,
|
||||
"codeQLQueryResults.left": NavigationDirection.left,
|
||||
"codeQLQueryResults.right": NavigationDirection.right,
|
||||
// For backwards compatibility with keybindings set using an earlier version of the extension.
|
||||
"codeQLQueryResults.nextPathStep": NavigationDirection.down,
|
||||
"codeQLQueryResults.previousPathStep": NavigationDirection.up,
|
||||
};
|
||||
void logger.log("Registering result view navigation commands.");
|
||||
for (const [commandId, direction] of Object.entries(navigationCommands)) {
|
||||
this.push(
|
||||
commandRunner(commandId, this.navigateResultView.bind(this, direction)),
|
||||
);
|
||||
}
|
||||
|
||||
this.push(
|
||||
this.databaseManager.onDidChangeDatabaseItem(({ kind }) => {
|
||||
|
@ -209,6 +194,36 @@ export class ResultsView extends AbstractWebview<
|
|||
);
|
||||
}
|
||||
|
||||
public getCommands(): ResultsViewCommands {
|
||||
return {
|
||||
"codeQLQueryResults.up": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.up,
|
||||
),
|
||||
"codeQLQueryResults.down": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.down,
|
||||
),
|
||||
"codeQLQueryResults.left": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.left,
|
||||
),
|
||||
"codeQLQueryResults.right": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.right,
|
||||
),
|
||||
// For backwards compatibility with keybindings set using an earlier version of the extension.
|
||||
"codeQLQueryResults.nextPathStep": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.down,
|
||||
),
|
||||
"codeQLQueryResults.previousPathStep": this.navigateResultView.bind(
|
||||
this,
|
||||
NavigationDirection.up,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
async navigateResultView(direction: NavigationDirection): Promise<void> {
|
||||
if (!this.panel?.visible) {
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче