Todo-tree: File removed from the list once opened

Created on 24 Jul 2020  路  18Comments  路  Source: Gruntfuggly/todo-tree

As soon as you open a file listed in the TODOS, it gets removed from the list, even if you don't change it. The file only shows up again if you refresh the list.

I'm not really sure if this is a bug, enhancement or default behaviour. However, when it comes to UX, I think would be helpful if the file stays on the list until the TODO is removed.

enhancement

Most helpful comment

No problem

All 18 comments

That sounds like a bug. The file should stay in the list. Can you give me your todo-tree settings so I can investigate? It sounds like the file is being found when searching using ripgrep, but when the file is opened it can't find any TODO's so it removes it.

Could you also turn on the debug log (todo-tree.general.debug), refresh the tree and then post the contents of the todo-tree output panel?

Sure.

Todo-tree settings:

// An array of workspace names to exclude as roots in the tree (wildcards can be used).
"todo-tree.filtering.excludedWorkspaces": [],

// Globs for use in limiting search results by exclusion (applied after **includeGlobs**), e.g. `["**/*.txt"]` to ignore all .txt files
"todo-tree.filtering.excludeGlobs": [],

// If true, any subfolders containing a .git file will be ignored when searching.
"todo-tree.filtering.ignoreGitSubmodules": false,

// An array of workspace names to include as roots in the tree (wildcards can be used). An empty array includes all workspace folders.
"todo-tree.filtering.includedWorkspaces": [],

// Globs for use in limiting search results by inclusion, e.g. `["**/unit-tests/*.js"]` to only show .js files in unit-tests subfolders
"todo-tree.filtering.includeGlobs": [],

// Include hidden files (starting with a .)
"todo-tree.filtering.includeHiddenFiles": false,

// By default the globs are passed into ripgrep to narrow the search. Set this to false to apply the globs *after* the search (pre 0.0.132 behaviour).
"todo-tree.filtering.passGlobsToRipgrep": true,

// Add VSCode's `files.exclude` and/or `search.exclude` list to the ignored paths.
//  - none: Don't used any built in excludes
//  - file excludes: Use the Files:Exclude setting
//  - search excludes: Use the Search:Exclude setting
//  - file and search excludes: Use the Files:Exclude and the Search:Exclude setting
"todo-tree.filtering.useBuiltInExcludes": "none",

// Create a debug channel in the Output view
"todo-tree.general.debug": false,

// Set to true to enable automatic updates when files in the workspace are created, changed or deleted
"todo-tree.general.enableFileWatcher": false,

// Path to use when exporting the tree. Environment variables will be expanded, e.g `${HOME}` and the path is passed through strftime (see <https://github.com/samsonjs/strftime>). Set the extension to `.json` to export as a JSON record.
"todo-tree.general.exportPath": "~/todo-tree-%Y%m%d-%H%M.txt",

// Glob for use with the file watcher. Change this if the default setting causes performance issues.
"todo-tree.general.fileWatcherGlob": "**/*",

// Sets where the cursor is positioned when revealing a todo
//  - start of todo: Moves the cursor to the beginning of the todo
//  - end of todo: Moves the cursor to the end of the todo
//  - highlight todo: Selects the todo text
//  - start of line: Moves the cursor to the start of the line
//  - highlight line: Selects the whole line
"todo-tree.general.revealBehaviour": "start of todo",

// Folder in which to run the search (defaults to the workspace folder)
"todo-tree.general.rootFolder": "",

// What to show in the status bar - nothing, total count, counts per tag, top three counts per tag or count of tags in the current file
//  - none: Only show the scanning status in the status bar
//  - total: Show the total count of tags in the status bar
//  - tags: Show a breakdown of the count of each tag in the status bar
//  - top three: Show the count of the top three tags in the status bar
//  - current file: Show the count of tags in the current file in the status bar
"todo-tree.general.statusBar": "none",

// What to do when the status bar is clicked
//  - cycle: Toggle between showing total count and the top three tag counts
//  - reveal: Reveal the tree view
"todo-tree.general.statusBarClickBehaviour": "reveal",

// Allows similar tags to be grouped under the same type, e.g. `{ "FIX": ["FIXME","FIXIT"] }`. *Note: All tags must also be in the `todo-tree.general.tags` tag list. If a tag group is defined, custom highlights apply to the group, not the tags within the group.*
"todo-tree.general.tagGroups": {},

// List of tags. *Note, if one tag starts with another tag, the longer tag should be specified first to prevent the shorter tag being matched.*
"todo-tree.general.tags": [
    "BUG",
    "HACK",
    "FIXME",
    "TODO",
    "XXX"
],

// Custom configuration for highlighting, [Read more...](https://github.com/Gruntfuggly/todo-tree#highlighting)
"todo-tree.highlights.customHighlight": {
    "BUG": {
        "icon": "bug"
    },
    "FIXME": {
        "icon": "flame"
    }
},

// Default configuration for highlighting. [Read more...](https://github.com/Gruntfuggly/todo-tree#highlighting)
"todo-tree.highlights.defaultHighlight": {},

// Set to false to disable highlighting
"todo-tree.highlights.enabled": true,

// Delay before highlighting tags within files (milliseconds)
"todo-tree.highlights.highlightDelay": 500,

// Editor schemes to show highlights in. To show highlights in settings files, for instance, add 'vscode-userdata' or for output windows, use 'output'.
"todo-tree.highlights.schemes": [
    "file",
    "untitled"
],

// Regular expression for matching TODOs. *Note: $TAGS will be replaced by the tag list.*
"todo-tree.regex.regex": "((//|#|<!--|;|/\\*|^)\\s*($TAGS)|^\\s*- \\[ \\])",

// Use a case sensitive regular expression
"todo-tree.regex.regexCaseSensitive": true,

// Location of your version of ripgrep
"todo-tree.ripgrep.ripgrep": "",

// Additional arguments to pass to ripgrep (Use with caution!)
"todo-tree.ripgrep.ripgrepArgs": "--max-columns=1000 --no-config ",

// Size of the buffer to use for retrieving output from ripgrep (kilobytes)
"todo-tree.ripgrep.ripgrepMaxBuffer": 200,

// Refresh the tree when files are opened or saved
"todo-tree.tree.autoRefresh": true,

// Show a button in the tree view title bar to expand or collapse the whole tree
"todo-tree.tree.buttons.expand": true,

// Show a button in the tree view title bar to create a file showing the tree content
"todo-tree.tree.buttons.export": false,

// Show a button in the tree view title bar allowing the tree to be filtered by entering some text
"todo-tree.tree.buttons.filter": true,

// Show a button in the tree view title bar to enable grouping items by tag
"todo-tree.tree.buttons.groupByTag": true,

// Show a refresh button in the tree view title bar
"todo-tree.tree.buttons.refresh": true,

// Show a button in the tree view title bar to reveal the current item (only when track file is not enabled)
"todo-tree.tree.buttons.reveal": true,

// Show a button in the tree view title bar to change the Scan Mode setting
"todo-tree.tree.buttons.scanMode": false,

// Show a button in the tree view title bar to change the view style (tree, flat or tags only)
"todo-tree.tree.buttons.viewStyle": true,

// Prevent the tree from showing compact folders
"todo-tree.tree.disableCompactFolders": false,

// When opening new workspaces, show the tree initially fully expanded
"todo-tree.tree.expanded": false,

// Set to true if you want the view filtering to be case sensitive
"todo-tree.tree.filterCaseSensitive": false,

// When opening new workspaces, show the tree initially as flat list of files
"todo-tree.tree.flat": false,

// When opening new workspaces, show the tree initially grouped by tag
"todo-tree.tree.grouped": false,

// Save some space by hiding the item icons when grouped by tag
"todo-tree.tree.hideIconsWhenGroupedByTag": false,

// Normally, the tree is removed from the explorer view if nothing is found. Set this to false to keep the view present.
"todo-tree.tree.hideTreeWhenEmpty": true,

// Format for tree items
"todo-tree.tree.labelFormat": "${tag} ${after}",

// Normally the tree is built as soon as the window is opened. If you have a large code base and want to manually start the scan, set this to false.
"todo-tree.tree.scanAtStartup": true,

// Set this to change which files are scanned
//  - workspace: Scan the whole workspace (or workspaces)
//  - open files: Scan open files only
//  - current file: Scan the current file only
"todo-tree.tree.scanMode": "workspace",

// Show badges and SCM state in the tree view
"todo-tree.tree.showBadges": true,

// Show counts of TODOs in the tree
"todo-tree.tree.showCountsInTree": false,

// Show the tree in the explorer view
"todo-tree.tree.showInExplorer": true,

// Show a button on the tree view header to change between scanning the current file, open files, or the whole workspace.
"todo-tree.tree.showScanModeButton": false,

// This setting is no longer used, please use "todo-tree.tree.scanMode" instead.
// 
"todo-tree.tree.showScanOpenFilesOrWorkspaceButton": false,

// This setting is no longer used, please use "todo-tree.tree.scanMode" instead.
// 
"todo-tree.tree.showTagsFromOpenFilesOnly": false,

// Sort items in the tags only view alphabetically instead of by file and line number
"todo-tree.tree.sortTagsOnlyViewAlphabetically": false,

// When opening new workspaces, show only tag elements in tree
"todo-tree.tree.tagsOnly": false,

// Tree item tooltip format
"todo-tree.tree.tooltipFormat": "${filepath}, line ${line}",

// Track the current file in the tree view
"todo-tree.tree.trackFile": true,

Debug log:

Searching /Users/user/dev/repo...
Command: /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/node_modules.asar.unpacked/vscode-ripgrep/bin/rg --no-messages --vimgrep -H --column --line-number --color never --max-columns=1000 --no-config  -e "(?:(?://|#|<!--|;|/\\*\\*?|\\*)\\s*(XXX|TODO|HACK|FIXME|BUG)|^\\s*- \\[ \\])" "/Users/user/dev/repo"
/Users/user/dev/repo/src/actions/launcherActions.js:34:9:        // TODO remove ids when api is ready

/Users/user/dev/repo/src/reducers/utils.js:19:1:// TODO: I'm not sure if this works, so please test before using this blindly

/Users/user/dev/repo/src/components/component/file1.js:269:7:      // TODO remove once comment/post/article inputs are in react

/Users/user/dev/repo/src/components/component/file2.js:11:2: * TODO:

/Users/user/dev/repo/src/components/component/file3.js:12:2: * TODO:

/Users/user/dev/repo/src/components/component/file4.js:25:3:  // TODO enable sort when API returns consistent results

/Users/user/dev/repo/src/components/component/file5.js:68:9:        // TODO remove once notifications are moved to react

/Users/user/dev/repo/src/components/component/file6.js:234:14:            {/*TODO Change to link when navigation response is available*/}

/Users/user/dev/repo/src/services/features/customPlugins/image.js:1006:9:        // TODO: This should be done correctly in image service

 Match (File): {"file":"/Users/user/dev/repo/src/actions/launcherActions.js","line":"34","column":"9","match":"        // TODO remove ids when api is ready"}
 Match (File): {"file":"/Users/user/dev/repo/src/reducers/utils.js","line":"19","column":"1","match":"// TODO: I'm not sure if this works, so please test before using this blindly"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file1.js","line":"269","column":"7","match":"      // TODO remove once comment/post/article inputs are in react"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file2.js","line":"11","column":"2","match":" * TODO:"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file3.js","line":"12","column":"2","match":" * TODO:"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file4.js","line":"25","column":"3","match":"  // TODO enable sort when API returns consistent results"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file5.js","line":"68","column":"9","match":"        // TODO remove once notifications are moved to react"}
 Match (File): {"file":"/Users/user/dev/repo/src/components/component/file6.js","line":"234","column":"14","match":"            {/*TODO Change to link when navigation response is available*/}"}
 Match (File): {"file":"/Users/user/dev/repo/src/services/features/customPlugins/image.js","line":"1006","column":"9","match":"        // TODO: This should be done correctly in image service"}
Found 9 items

I hope it helps and let me know if you need anything else.

It looks like you haven't changed any of the settings - is that correct?

Which is the file that disappears?

No really, I just changed the Regex for multi-line.

All of them. Once you open any file, it disappears from the list.

Can you post your setting of the regex - the one you've posted is the default.

I'm using this one: (?:(?://|#|<!--|;|/\\*\\*?|\\*)\\s*($TAGS)|^\\s*- \\[ \\]) (I got it here #255)

OK - I'll see if I can reproduce it.

I can't reproduce this. Could you open the developer tools (Help->Toggle Developer Tools) and see if there is anything in there? There might be an error generated when selecting the file.

I've made a small video reproducing the issue with the Developer Tools opened:
Screen Recording 2020-07-28 at 14.41.23.mov.zip

To be honest, I'm now at a total loss.

You could try: Todo-Tree: Reset Cache

if that doesn't work, can you reset the settings back to the default and see if that does anything?

I just installed this and I am seeing the exact same behavior. I will try resetting the cache. The only changes I made were:

    "todo-tree.regex.regex": "(//|#|<!--|;|/?\\\\*|^)\\\\s*($TAGS)",
    "todo-tree.general.tags": [
        "@TODO",
        "@FIXME",
        "@FIX",
        "FIXME",
        "FIX",
        "TODO",
    ],
    "todo-tree.regex.regexCaseSensitive": false,
    "todo-tree.filtering.excludeGlobs": [
        "**/vendor/**",
        "**/node_modules/**",
        "**/dist/**",
        "**/bower_components/**",
        "**/build/**",
        "**/.vscode/**",
        "**/.github/**",
        "**/_output/**",
        "**/*.min.*",
        "**/*.map"
    ]

I can reproduce it now with your settings - it seems to be something to do with the regex.

OK, @gubler in your case it's because you've got too many \'s in the regex. I'm guessing you've taken one of the settings from the wiki, where the slashes are escaped as they are intended to be entered into the settings.json file, not directly into the GUI. I think I'll need to add a more obvious warning.

Try setting it to "(//|#|<!--|;|/?\\*|^)\\s*($TAGS)" or "(//|#|<!--|;|/?\*|^)\s*($TAGS)" if you're the GUI and see if it works.

And @MADPT it's the same in your case. If you want to use this (?:(?://|#|<!--|;|/\\*\\*?|\\*)\\s*($TAGS)|^\\s*- \\[ \\]) you need to remove the double \'s, so it should be (?:(?://|#|<!--|;|/\*\*?|\*)\s*($TAGS)|^\s*- \[ \]) when you paste it into the settings GUI.

It's a bit horrible that it finds the TODOs when searching with ripgrep, but doesn't when it is searching the file. The trouble is that it is perfectly feasible that the regex could contain double backslashes.

I'll have a think and try to work out a way to warn the user.

Removing the extra backslashes worked for me.

Thank you very much for figuring out the problem so fast.

Fixing the regex fixed the issue. Thank you for your support @Gruntfuggly

No problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  7Comments

WORMSS picture WORMSS  路  6Comments

rickstaa picture rickstaa  路  5Comments

nickPietrass picture nickPietrass  路  9Comments

luqiudi picture luqiudi  路  9Comments