Skip to content

Commit

Permalink
Avoid focusing on test items on document switch (#3197)
Browse files Browse the repository at this point in the history
### Motivation

VS Code doesn't provide an API for us to know which test item is currently selected in the UI.

This means that, if you have a specific test example selected, it gets unselected when you switch documents due to the callback we added.

### Implementation

It's unfortunate, but I don't think we're able to auto-select the items correctly based on which document is opened.
  • Loading branch information
vinistock committed Feb 14, 2025
1 parent 45ae6f6 commit 0cf2dba
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions vscode/src/testController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,6 @@ export class TestController {
vscode.window.onDidCloseTerminal((terminal: vscode.Terminal): void => {
if (terminal === this.terminal) this.terminal = undefined;
}),
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
const uri = editor?.document.uri;

if (!uri) {
return;
}

const item = await this.getTestItem(uri);

if (!item) {
return;
}

await vscode.commands.executeCommand(
"vscode.revealTestInExplorer",
item,
);
}),
vscode.workspace.onDidSaveTextDocument(async (document) => {
const uri = document.uri;
const item = await this.getParentTestItem(uri);
Expand Down Expand Up @@ -614,12 +596,6 @@ export class TestController {
return pathParts.indexOf("features");
}

// Finds a test item based on its URI taking all possible hierarchies into account
private async getTestItem(uri: vscode.Uri) {
const item = await this.getParentTestItem(uri);
return item?.children.get(uri.toString());
}

private async getParentTestItem(uri: vscode.Uri) {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (!workspaceFolders) {
Expand Down

0 comments on commit 0cf2dba

Please sign in to comment.