Summary
Setting better-todo-tree.regex.subTagRegex to an invalid regular expression (e.g. missing a closing parenthesis) causes the affected file to be skipped entirely during scanning, so TODO tags in that file are not detected at all.
Steps to Reproduce
- Set the following in
.vscode/settings.json:
{
"better-todo-tree.regex.subTagRegex": "^\\s*#(\\d+"
}
(missing the closing ))
2. Add a comment like // TODO #123 fix this to any file
3. Check the Todo Tree view
Expected Behavior
The TODO tag itself should still be detected and shown in the tree, even if sub-tag extraction is disabled due to the invalid setting.
Actual Behavior
The file is skipped entirely during scanning, along with this message:
Better Todo Tree: skipped 1 workspace file(s) while scanning.
Results may be incomplete. First failure: path:1 during candidate scan
(Invalid regular expression: /^\s*#(\d+/: Unterminated group)
Root Cause (investigated)
In src/utils.js (resolveSubTagRegex()) and src/detection.js (createScanContext()), new RegExp(resourceConfig.subTagRegex, flags)
is not wrapped in try/catch. An invalid regex therefore throws, and the exception propagates up, causing the file's scan to fail entirely.
Environment
- Better Todo Tree version: 1.3.4
- Visual Studio Code version: 1.133
- OS: Windows 11
Additional Context
Would it be okay if I submit a PR that fixes this issue separately?
Summary
Setting
better-todo-tree.regex.subTagRegexto an invalid regular expression (e.g. missing a closing parenthesis) causes the affected file to be skipped entirely during scanning, so TODO tags in that file are not detected at all.Steps to Reproduce
.vscode/settings.json:{ "better-todo-tree.regex.subTagRegex": "^\\s*#(\\d+" }(missing the closing
))2. Add a comment like
// TODO #123 fix thisto any file3. Check the Todo Tree view
Expected Behavior
The
TODOtag itself should still be detected and shown in the tree, even if sub-tag extraction is disabled due to the invalid setting.Actual Behavior
The file is skipped entirely during scanning, along with this message:
Root Cause (investigated)
In
src/utils.js(resolveSubTagRegex()) andsrc/detection.js(createScanContext()),new RegExp(resourceConfig.subTagRegex, flags)is not wrapped in try/catch. An invalid regex therefore throws, and the exception propagates up, causing the file's scan to fail entirely.
Environment
Additional Context
Would it be okay if I submit a PR that fixes this issue separately?