Skip to content

fix typo in glob pattern spec #2132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from

Conversation

brynne8
Copy link

@brynne8 brynne8 commented Apr 27, 2025

I looked into the behavior of * in VS Code’s glob implementation and found that it actually matches zero or more characters in a path segment—not one or more as LSP 3.17 states. Specifically:

  • In the VS Code source (glob.ts), the comment reads “* to match zero or more characters in a path segment.”

  • The “Glob Patterns” documentation on code.visualstudio.com also says “zero or more.”

  • Inspecting the implementation:

    function starsToRegExp(starCount: number, isLastPattern?: boolean): string {
      switch (starCount) {
        case 0:
          return '';
        case 1:
          // 1 star: match any number of characters except path separators (/ and \), non-greedy
          return `${NO_PATH_REGEX}*?`;
        default:
          // handler for **
      }
    }

    In regex syntax, * means “zero or more” of the preceding pattern, and the ? makes it non-greedy.

So it looks like LSP 3.17’s description of * is simply a typo.

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.

None yet

1 participant