Skip to content
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

Token output missing in picomatch.parse from logical or with empty element #125

Closed
connor4312 opened this issue Dec 12, 2023 · 0 comments · Fixed by #126
Closed

Token output missing in picomatch.parse from logical or with empty element #125

connor4312 opened this issue Dec 12, 2023 · 0 comments · Fixed by #126

Comments

@connor4312
Copy link
Contributor

  1. Run require('picomatch').parse('foo.(c|m|)js')
  2. Observer the following, where the output for the text token of c|m| is actually |m|
{
  input: 'foo.(c|m|)js',
  index: 11,
  start: 0,
  dot: false,
  consumed: 'foo.(c|m|)js',
  output: 'foo\\.(c|m|)js', // < the output is what we would expect
  prefix: '',
  backtrack: false,
  negated: false,
  brackets: 0,
  braces: 0,
  parens: 0,
  quotes: 0,
  globstar: false,
  tokens: [
    { type: 'bos', value: '', output: '' },
    { type: 'text', value: 'foo.', prev: [Object], output: '.' },
    { type: 'paren', value: '(', prev: [Object] },
    { type: 'text', value: 'c|m|', prev: [Object], output: '|m|' }, // 'c' is missing from the output in this token
    { type: 'paren', value: ')', output: ')', prev: [Object] },
    { type: 'text', value: 'js', prev: [Object] }
  ],
  peek: [Function (anonymous)],
  advance: [Function (anonymous)]
}

If the logical expression is modified to remove the empty element, for example making it c|m|x, the the problem disappears.

connor4312 added a commit to connor4312/picomatch that referenced this issue Dec 12, 2023
Previously sibling `text` tokens would exclude the `output` from the
first token, resulting in the referenced issues. I think this should
be a fairly safe change.

Fixes micromatch#125
Fixes micromatch#100
connor4312 added a commit to connor4312/picomatch that referenced this issue Dec 13, 2023
Previously sibling `text` tokens would exclude the `output` from the
first token, resulting in the referenced issues. I think this should
be a fairly safe change.

Fixes micromatch#125
Fixes micromatch#100
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Dec 13, 2023
Fixes microsoft/vscode#200665

Requires use of my picomatch fork due to micromatch/picomatch#125.
We could alternatively use brace expansion until that's fixed, but that's much less
efficient that using a logical or.
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Dec 13, 2023
Fixes microsoft/vscode#200665

Requires use of my picomatch fork due to micromatch/picomatch#125.
We could alternatively use brace expansion until that's fixed, but that's much less
efficient that using a logical or.
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 a pull request may close this issue.

1 participant