Skip to content

fix typo in glob pattern spec#2132

Merged
dbaeumer merged 1 commit into
microsoft:gh-pagesfrom
brynne8:fix-glob-spec
May 14, 2025
Merged

fix typo in glob pattern spec#2132
dbaeumer merged 1 commit into
microsoft:gh-pagesfrom
brynne8:fix-glob-spec

Conversation

@brynne8

@brynne8 brynne8 commented Apr 27, 2025

Copy link
Copy Markdown
Contributor

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.

@dbaeumer

Copy link
Copy Markdown
Member

Thanks. You are correct '*' should match zero or more.

@vs-code-engineering vs-code-engineering Bot added this to the May 2025 milestone May 13, 2025
@dbaeumer dbaeumer merged commit f20ba07 into microsoft:gh-pages May 14, 2025
2 checks passed
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.

3 participants