Skip to content

Optimize the search logic for launch.json #1252

Description

See https://github.com/microsoft/vscode-java-debug/pull/1234/files#r1010024710.

We have some code to search a launch.json file via await vscode.workspace.findFiles(".vscode/launch.json", "**/node_modules/**");, it can be optimized by specifying the workspace folder and maxResult as 1.

Activity

  1. github-actions commented on Nov 10, 2025

    @github-actions

    Hi Jinbo Wang (@testforstephen), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    Here’s how you can optimize your launch.json lookup:

    • Scope to a single folder and limit results

      import { RelativePattern, workspace, WorkspaceFolder } from 'vscode';
      
      async function findLaunchJson(folder: WorkspaceFolder) {
        // only look under the workspace folder’s .vscode folder, stop after the first match
        const pattern = new RelativePattern(folder, '.vscode/launch.json');
        const results = await workspace.findFiles(pattern, '**/node_modules/**', 1);
        return results[0];
      }
    • If you don’t need a RelativePattern, you can still pass maxResults directly:

      const [file] = await workspace.findFiles(
        '.vscode/launch.json',
        '**/node_modules/**',
        1
      );

    Other references worth checking:

    Low-confidence reference

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions