Skip to content

Commit 2a2cb26

Browse files
Convert extensions/ql-vscode/src/test-ui.ts to call typed commands
1 parent ff418b5 commit 2a2cb26

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

extensions/ql-vscode/src/common/commands.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CommandManager } from "../packages/commands";
2-
import type { Uri, Range } from "vscode";
2+
import type { Uri, Range, TextDocumentShowOptions } from "vscode";
33
import type { AstItem } from "../astViewer";
44
import type { DbTreeViewItem } from "../databases/ui/db-tree-view-item";
55
import type { DatabaseItem } from "../local-databases";
@@ -42,6 +42,12 @@ export type BuiltInVsCodeCommands = {
4242
value: unknown,
4343
) => Promise<void>;
4444
"workbench.action.reloadWindow": () => Promise<void>;
45+
"vscode.diff": (
46+
leftSideResource: Uri,
47+
rightSideResource: Uri,
48+
title?: string,
49+
columnOrOptions?: TextDocumentShowOptions,
50+
) => Promise<void>;
4551
"vscode.openFolder": (uri: Uri) => Promise<void>;
4652
};
4753

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ async function activateWithInstalledDistribution(
851851
);
852852
ctx.subscriptions.push(testAdapterFactory);
853853

854-
const testUIService = new TestUIService(testHub);
854+
const testUIService = new TestUIService(app, testHub);
855855
ctx.subscriptions.push(testUIService);
856856

857857
testUiCommands = testUIService.getCommands();

extensions/ql-vscode/src/test-ui.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { lstat, copy, pathExists, createFile } from "fs-extra";
22
import { basename } from "path";
3-
import { Uri, TextDocumentShowOptions, commands, window } from "vscode";
3+
import { Uri, TextDocumentShowOptions, window } from "vscode";
44
import {
55
TestHub,
66
TestController,
@@ -16,6 +16,7 @@ import { TestTreeNode } from "./test-tree-node";
1616
import { DisposableObject } from "./pure/disposable-object";
1717
import { QLTestAdapter, getExpectedFile, getActualFile } from "./test-adapter";
1818
import { TestUICommands } from "./common/commands";
19+
import { App } from "./common/app";
1920

2021
type VSCodeTestEvent =
2122
| TestRunStartedEvent
@@ -44,7 +45,7 @@ class QLTestListener extends DisposableObject {
4445
export class TestUIService extends DisposableObject implements TestController {
4546
private readonly listeners: Map<TestAdapter, QLTestListener> = new Map();
4647

47-
constructor(private readonly testHub: TestHub) {
48+
constructor(private readonly app: App, private readonly testHub: TestHub) {
4849
super();
4950

5051
testHub.registerTestController(this);
@@ -105,7 +106,7 @@ export class TestUIService extends DisposableObject implements TestController {
105106

106107
if (await pathExists(actualPath)) {
107108
const actualUri = Uri.file(actualPath);
108-
await commands.executeCommand<void>(
109+
await this.app.commands.execute(
109110
"vscode.diff",
110111
expectedUri,
111112
actualUri,

0 commit comments

Comments
 (0)