vscode-spell-checker
vscode-spell-checker copied to clipboard
`includeRegExpList` ignores capture groups
Hey there and thanks for the great extension! :wave:
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. :pray: