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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

includeRegExpList ignores capture groups #2998

Open
twiddler opened this issue Jan 2, 2024 · 0 comments
Open

includeRegExpList ignores capture groups #2998

twiddler opened this issue Jan 2, 2024 · 0 comments

Comments

@twiddler
Copy link

twiddler commented Jan 2, 2024

Hey there and thanks for the great extension! 馃憢

I am using this extension with a few simple custom regular expressions in settings.json, e.g. for checking variable names when declaring them for the first time, and those work great and as expected. Today however, I encountered something unexpected when trying to match only the second argument of i18next's t(key, defaultValue) function if it is a string literal:

{
  "cSpell.includeRegExpList": [
    "\\bt\\(\\s*[^,]+\\s*,\\s*'([^']+)'"
  ]
}

Instead of just spellchecking what's inside the capture group ([^']*), the whole regex is used for spellchecking, so t(key, gets spellchecked, too. I expected cSpell to only spellcheck what is matched by a capture group, at least if one is present. As a workaround, I now use a lookbehind and a lookahead:

{
  "cSpell.includeRegExpList": [
    "(?<=\\bt\\(\\s*[^,]+\\s*,\\s*')[^']+(?=')"
  ]
}

I'd appreciate if you'd consider matching only capture groups if present. 馃檹

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

No branches or pull requests

1 participant