Skip to content

Commit

Permalink
auto-refresh snippets tree view on all snippets viewer tree settings …
Browse files Browse the repository at this point in the history
…changes (#30)

also refine settings descriptions in docs and package.json config
  • Loading branch information
RandomFractals committed Mar 29, 2021
1 parent 75211e6 commit 9f2d882
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Install [Snippets Viewer ⇥](https://marketplace.visualstudio.com/items?itemNam

| Setting | Type | Default Value | Description |
| ------- | ---- | ------------- | ----------- |
| `snippets.viewer.expendSnippetFiles` | boolean | `false` | Expend snippet files in Snippets tree view on snippet language expend. |
| `snippets.viewer.showBuiltinExtensionSnippets` | boolean | `true` | Show built-in language extension snippets. |
| `snippets.viewer.expendSnippetFiles` | boolean | `false` | Expend snippet files on snippet language tree node expend in Snippets tree view.|
| `snippets.viewer.showBuiltInExtensionSnippets` | boolean | `true` | Show built-in language extension snippets in Snippets tree view. |
| `snippets.viewer.skipLanguageSnippets` | string | | Comma delimited list of languages to skip snippets display in Snippets tree view. |

# Dev Build
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"snippets.viewer.showBuiltInExtensionSnippets": {
"type": "boolean",
"default": true,
"description": "Show built-in language extension snippets."
"description": "Show built-in language extension snippets in Snippets tree view."
},
"snippets.viewer.skipLanguageSnippets": {
"type": "string",
Expand All @@ -125,7 +125,7 @@
"snippets.viewer.expendSnippetFiles": {
"type": "boolean",
"default": false,
"description": "Expend snippet files in Snippets tree view on snippet language expend."
"description": "Expend snippet files on snippet language tree node expend in Snippets tree view."
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
ExtensionContext,
commands,
window
window,
workspace
}
from 'vscode';
import {registerCommands} from './commands';
Expand All @@ -21,6 +22,15 @@ export function activate(context: ExtensionContext) {
commands.registerCommand(`snippets.viewer.refreshSnippets`, () => snippetProvider.refresh(true))
);

// check for tree view settings changes
context.subscriptions.push(workspace.onDidChangeConfiguration(config => {
if (config.affectsConfiguration('snippets.viewer.expendSnippetFiles') ||
config.affectsConfiguration('snippets.viewer.showBuiltInExtensionSnippets') ||
config.affectsConfiguration('snippets.viewer.skipLanguageSnippets')) {
snippetProvider.refresh(true);
}
}));

// add other snippet commands
registerCommands(context);
}
Expand Down
4 changes: 3 additions & 1 deletion test/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"snippets.viewer.skipLanguageSnippets": "bat, coffeescript, javascriptreact, typescriptreact, swift, vb"
"editor.tabSize": 2,
"snippets.viewer.skipLanguageSnippets": "bat, c, csharp, cpp, coffeescript, fsharp, javascriptreact, typescriptreact, swift, vb, wat",
"snippets.viewer.expendSnippetFiles": true
}

0 comments on commit 9f2d882

Please sign in to comment.