Skip to content

subTagRegex with an invalid regular expression skips the file during scanning #166

Description

@tkyasu999

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

  1. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions