Duplicate issues in TODOs view when changing view modes
Recreate
Setup
- Default Todo Tree settings
- open a new workspace in VS Code
Steps
- Create a new file
- Add
[ ] Helloto the file - Save the file as
file1 - Add
Worldto the todo line in the file (so it now says "[ ] Hello World") - DO NOT SAVE - Press the refresh button on the TODOs view
- Toggle either the flat/tree/tags-only button OR group-by-tags button
Both the todo saved in the file ([ ] Hello) and the todo in the editor ([ ] Hello World) are displayed
Click refresh cleans up the duplicate (removing the version saved to disk). But pressing the flat/tree/tags-only or group-by-tags button again reintroduces the extra todo
This issue seems similar to #637. I was able to track down the starting place for this issue (the refresh() function in src/extension.js), but I am unable to find the root cause.
However, I tried applying similar fixes to this issue as was used to fix #637, and they do appear to fix the issue. I haven't considered the performance impact of rebuilding the tree when changing the view mode, so that may need to be taken into consideration.
src/extension.js
@@ -863,12 +863,18 @@ function activate( context )
function refresh()
{
searchResults.markAsNotAdded();
provider.clear( vscode.workspace.workspaceFolders );
provider.rebuild();
- refreshOpenFiles();
- addResultsToTree();
+ // FIX1 - just rebuild the entire tree
+ rebuild();
+
+ // OR FIX2 - call these methods the same was as is done in rebuild(), but without having to do the full rebuild
+ iterateSearchList()
+ .finally( refreshOpenFiles )
+ .then( addResultsToTree );
+
setButtonsAndContext();
}