Skip to content

Commit

Permalink
Add "scan open files only"/"scan workspace" toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
Gruntfuggly committed Apr 17, 2019
1 parent 732c127 commit c081139
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 12 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The source code is available on GitHub [here](https://github.com/Gruntfuggly/tod

## Controls

The tree view header contains the following buttons:
The tree view header can contain the following buttons:

<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/collapse.png" height="16px" align="center"> - Collapse all tree nodes<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/expand.png" height="16px" align="center"> - Expand all tree nodes<br>
Expand All @@ -92,7 +92,9 @@ The tree view header contains the following buttons:
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/notag.png" height="16px" align="center"> - Organise the TODOs by file (default)<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/filter.png" height="16px" align="center"> - Only show items in the tree which match the entered filter text<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/clear-filter.png" height="16px" align="center"> - Remove any active filter<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/refresh.png" height="16px" align="center"> - Rebuild the tree
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/refresh.png" height="16px" align="center"> - Rebuild the tree<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/scan-open-files.png" height="16px" align="center"> - Show tags from open files only<br>
<img src="https://raw.githubusercontent.com/Gruntfuggly/todo-tree/master/resources/icons/light/scan-workspace.png" height="16px" align="center"> - Show tags from workspace<br>

## Commands

Expand Down Expand Up @@ -137,6 +139,7 @@ The extension can be customised as follows:
| todo-tree.statusBar | <tt>none</tt> | What to show in the status bar - nothing (<tt>none</tt>), total count (<tt>total</tt>), counts per tag (<tt>tags</tt>) or the counts for the top three tags (<tt>top three</tt>) |
| todo-tree.showCountsInTree | <tt>false</tt> | Set to true to show counts of TODOs in the tree |
| todo-tree.labelFormat | <tt>${tag} ${after}</tt> | Format of the TODO item labels. Available placeholders are <tt>${line}</tt>, <tt>${column}</tt>, <tt>${tag}</tt>, <tt>${before}</tt> (text from before the tag), <tt>${after}</tt> (text from after the tag) and <tt>${filename}</tt>. |
| todo-tree.showScanOpenFilesOrWorkspaceButton | <tt>false</tt> | Show a button on the tree view header to toggle between scanning open files only, or the whole workspace |

<sup>*</sup> Only applies to new workspaces. Once the view has been changed in the workspace, the current state is stored.

Expand Down
15 changes: 15 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ function activate( context )
vscode.commands.executeCommand( 'setContext', 'todo-tree-filtered', context.workspaceState.get( 'filtered', false ) );
vscode.commands.executeCommand( 'setContext', 'todo-tree-collapsible', isCollapsible );

vscode.commands.executeCommand( 'setContext', 'todo-tree-show-scan-open-files-or-workspace-button', c.get( 'showScanOpenFilesOrWorkspaceButton', false ) );
vscode.commands.executeCommand( 'setContext', 'todo-tree-scan-open-files-only', c.get( 'showTagsFromOpenFilesOnly', false ) );

var children = provider.getChildren();
var empty = children.length === 1 && children[ 0 ].empty === true;

Expand Down Expand Up @@ -574,6 +577,16 @@ function activate( context )
} );
}

function scanOpenFilesOnly()
{
vscode.workspace.getConfiguration( 'todo-tree' ).update( 'showTagsFromOpenFilesOnly', true, false );
}

function scanWorkspace()
{
vscode.workspace.getConfiguration( 'todo-tree' ).update( 'showTagsFromOpenFilesOnly', false, false );
}

function register()
{
function migrateSettings()
Expand Down Expand Up @@ -676,6 +689,8 @@ function activate( context )
context.subscriptions.push( vscode.commands.registerCommand( 'todo-tree.addTag', addTag ) );
context.subscriptions.push( vscode.commands.registerCommand( 'todo-tree.removeTag', removeTag ) );
context.subscriptions.push( vscode.commands.registerCommand( 'todo-tree.toggleStatusBar', toggleStatusBar ) );
context.subscriptions.push( vscode.commands.registerCommand( 'todo-tree.scanOpenFilesOnly', scanOpenFilesOnly ) );
context.subscriptions.push( vscode.commands.registerCommand( 'todo-tree.scanWorkspace', scanWorkspace ) );

context.subscriptions.push( vscode.window.onDidChangeActiveTextEditor( function( e )
{
Expand Down
53 changes: 43 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,55 +52,65 @@
},
"menus": {
"view/title": [
{
"command": "todo-tree.scanOpenFilesOnly",
"when": "view =~ /todo-tree/ && todo-tree-scan-open-files-only == false && todo-tree-show-scan-open-files-or-workspace-button == true",
"group": "navigation@1"
},
{
"command": "todo-tree.scanWorkspace",
"when": "view =~ /todo-tree/ && todo-tree-scan-open-files-only == true && todo-tree-show-scan-open-files-or-workspace-button == true",
"group": "navigation@1"
},
{
"command": "todo-tree.expand",
"when": "view =~ /todo-tree/ && todo-tree-expanded == false && todo-tree-collapsible",
"group": "navigation@1"
"group": "navigation@2"
},
{
"command": "todo-tree.collapse",
"when": "view =~ /todo-tree/ && todo-tree-expanded == true && todo-tree-collapsible",
"group": "navigation@1"
"group": "navigation@2"
},
{
"command": "todo-tree.showFlatView",
"when": "view =~ /todo-tree/ && todo-tree-flat == false && todo-tree-tags-only == false",
"group": "navigation@2"
"group": "navigation@3"
},
{
"command": "todo-tree.showTagsOnlyView",
"when": "view =~ /todo-tree/ && todo-tree-flat == true && todo-tree-tags-only == false",
"group": "navigation@2"
"group": "navigation@3"
},
{
"command": "todo-tree.showTreeView",
"when": "view =~ /todo-tree/ && todo-tree-flat == false && todo-tree-tags-only == true",
"group": "navigation@2"
"group": "navigation@3"
},
{
"command": "todo-tree.groupByTag",
"when": "view =~ /todo-tree/ && todo-tree-grouped == false",
"group": "navigation@3"
"group": "navigation@4"
},
{
"command": "todo-tree.ungroupByTag",
"when": "view =~ /todo-tree/ && todo-tree-grouped == true",
"group": "navigation@3"
"group": "navigation@4"
},
{
"command": "todo-tree.filter",
"when": "view =~ /todo-tree/ && todo-tree-filtered == false",
"group": "navigation@4"
"group": "navigation@5"
},
{
"command": "todo-tree.filterClear",
"when": "view =~ /todo-tree/ && todo-tree-filtered == true",
"group": "navigation@4"
"group": "navigation@5"
},
{
"command": "todo-tree.refresh",
"when": "view =~ /todo-tree/",
"group": "navigation@5"
"group": "navigation@6"
}
]
},
Expand Down Expand Up @@ -195,6 +205,24 @@
"light": "resources/icons/light/notag.svg"
}
},
{
"command": "todo-tree.scanOpenFilesOnly",
"title": "Scan Open Files Only",
"category": "Todo Tree",
"icon": {
"dark": "resources/icons/dark/scan-open-files.svg",
"light": "resources/icons/light/scan-open-files.svg"
}
},
{
"command": "todo-tree.scanWorkspace",
"title": "Scan Workspace",
"category": "Todo Tree",
"icon": {
"dark": "resources/icons/dark/scan-workspace.svg",
"light": "resources/icons/light/scan-workspace.svg"
}
},
{
"command": "todo-tree.addTag",
"title": "Add Tag",
Expand Down Expand Up @@ -374,6 +402,11 @@
"type": "boolean",
"default": false,
"markdownDescription": "When opening new workspaces, show only tag elements in tree"
},
"todo-tree.showScanOpenFilesOrWorkspaceButton": {
"type": "boolean",
"default":false,
"markdownDescription":"Show a button on the tree view header to toggle between scanning open files only, or the whole workspace"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions resources/icons/dark/scan-open-files.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/dark/scan-workspace.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions resources/icons/light/scan-open-files.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/icons/light/scan-workspace.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c081139

Please sign in to comment.