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

Wierd behavior in tree view with open file scan #536

Open
baincd opened this issue Jul 17, 2021 · 2 comments · May be fixed by #639
Open

Wierd behavior in tree view with open file scan #536

baincd opened this issue Jul 17, 2021 · 2 comments · May be fixed by #639

Comments

@baincd
Copy link
Contributor

baincd commented Jul 17, 2021

Example configuration

    "todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)",
    "todo-tree.general.statusBar": "tags",
    "todo-tree.general.tags": [
        "<<<<<<<"
    ],
    "todo-tree.general.tagGroups": {
        "git-conflict": [ "<<<<<<<" ]
    },
    "todo-tree.highlights.customHighlight": {
        "git-conflict": {
            "icon": "git-pull-request",
            "background": "#FF9900"
        }
    },
    "todo-tree.tree.labelFormat": "${tag}:${line} ${after}" // Add line number to make it easier to determine the tag displayed in the tree view

Steps:

  1. Initial view, with no files open, displays the tags correctly (in the following example there should only be 1 tag)
  2. Clicking on a tag to open the file causes the tag to now be displayed as a parent/child node
  3. With file open do a rescan, and the same tag is displayed twice - once as a parent/child node and once as a regular tag

The issue seems to be a difference in the regex match of open files vs workspace files. In the example above, icons.js line 8 ends with a ; . If I remove the ; from icons.js line 8, OR I remove the ; from the "todo-tree.regex.regex" setting, the issue does not happen (the tag is always displayed correctly like in step 1 above)

@baincd
Copy link
Contributor Author

baincd commented Oct 6, 2021

@Gruntfuggly
I think I may have found a solution to this issue.

I found #507 (comment) which changed the default regex to solve an issue with the regex matching across lines. However, I think there is still a gap, which is causing this issue.

Therefore, I propose the following fix (I included the default regex history as well as a reference)

"((//|#|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])"      // default as of 0.0.213
"(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)"        // 0.0.213 default with Markdown Fix from https://github.com/Gruntfuggly/todo-tree#markdown-support
"(//|#|<!--|;|/\\*|^|^[ \\t]*(-|\\d+.))\\s*($TAGS)"     // default as of 0.0.214
"(//|#|<!--|;|/\\*|^|^[ \\t]*(-|\\d+.))[ \\t]*($TAGS)"  // My proposed fix

I also wonder if my proposed fix might also fix #560, #527, and #511.

Also, I think it would be helpful for users that have customized their regex to have some documentation that the default regex has changed (along with why), and/or a notification that the default regex has changed. Otherwise, users with a customized regex lose out on fixes/tweaks to the default regex. This probably doesn't need to be over-engineered since the default regex shouldn't change too often, but something to help users stay up to date might be nice.

@baincd
Copy link
Contributor Author

baincd commented Oct 7, 2021

I noticed a potential opportunity to fix how the default regex matches markdown lists. The period is unescaped, causing it to be treated as a wildcard.

Also, the markdown list should have a space between the dash or number and text.

Examples:

image

Here is an updated proposed default regex, to fix both the original issue reported here, and to fixup the markdown
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant