diff --git a/package.json b/package.json index 9ff89e5..0ffdb3e 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "commands": [ { "command": "babelAstExplorer.start", - "title": "Open", + "title": "Show AST", "category": "Babel AST Explorer", - "icon": "$(triangle-right)" + "icon": "resources/icons/babel-logo-minimal.svg" }, { "command": "babelAstExplorer.update", @@ -49,11 +49,11 @@ "when": "false" } ], - "view/title": [ + "editor/title": [ { "command": "babelAstExplorer.start", - "when": "view =~ /babelAstExplorer/", - "group": "navigation@2" + "group": "navigation@1", + "when": "editorLangId == 'typescript' || editorLangId == 'typescriptreact' || editorLangId == 'javascript' || editorLangId == 'javascriptreact'" } ] }, diff --git a/src/extension.ts b/src/extension.ts index 865b8ce..d5a893c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,30 +7,21 @@ import guessPlugins from './guessPlugins'; export function activate(context: vscode.ExtensionContext) { let astView: ASTView | undefined; - let optionsView: OptionsView | undefined; const defaultOptions = OPTIONS.map(({ value }) => value); + const optionsView = new OptionsView({ + options: defaultOptions + }); context.subscriptions.push( vscode.commands.registerCommand(COMMANDS.start, () => { const plugins = guessPlugins(vscode.window.activeTextEditor); - if (optionsView) { - optionsView.update({ plugins }) - } else { - optionsView = new OptionsView({ - options: defaultOptions, - plugins, - }); - } + optionsView.update({ plugins }); if (astView) { astView.update({ plugins }); } else { astView = new ASTView( () => { - if (optionsView) { - optionsView.dispose(); - optionsView = undefined; - } - astView = undefined; + optionsView.dispose(); }, { options: defaultOptions, plugins } ); @@ -41,12 +32,9 @@ export function activate(context: vscode.ExtensionContext) { vscode.commands.registerCommand( COMMANDS.update, (options: ASTViewOptions) => { - + optionsView.update(options); if (astView) { - astView.updateOptions(options); - } - if (optionsView) { - optionsView.update(options); + astView.update(options); } } )