Skip to content

Conversation

plemarquand
Copy link
Contributor

@plemarquand plemarquand commented Sep 4, 2025

Description

When we process the ...args passed to the 'run multiple' commands we're only checking if the argument is an object before deeming it a TestItem.

On linux VS Code is passing an event object like { preserveFocus: true }, which is being treated as a TestItem and causing the command to error out.

Tasks

  • Required tests have been written
  • Documentation has been updated
  • Added an entry to CHANGELOG.md if applicable

When we process the `...args` passed to the 'run multiple' commands
we're only checking if the argument is an object before deeming it a
TestItem.

On linux VS Code is passing an event object like `{ preserveFocus: true }`,
which is being treated as a TestItem and causing the command to error
out.
@plemarquand plemarquand force-pushed the fix-run-multiple-linux branch from 48f3c7e to d30e04b Compare September 4, 2025 18:52
Copy link
Member

@matthewbastien matthewbastien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one nitpick.

@@ -127,7 +128,12 @@ export function extractTestItemsAndCount(
result.count = arg ?? undefined;
return result;
} else if (typeof arg === "object") {
result.testItems.push(arg);
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it make sense to also update the function signature to accept ...args: unknown[] just to make it more clear what's going on here? Could even pull out this check into a utility function that we could use later. For example:

function isVSCodeTestItem(obj: unknown): obj is vscode.TestItem {
    return typeof obj === "object"
        && Object.prototype.hasOwnProperty.call(arg, "id")
        && Object.prototype.hasOwnProperty.call(arg, "uri");
}

export function extractTestItemsAndCount(...args: unknown[]): {
    // ...
    if (isVSCodeTestItem(arg)) {
        result.testItems.push(arg);
    }
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants