@@ -4,7 +4,7 @@ import { Parser } from './parser';
44import { Tree } from './types/tree' ;
55
66let tree : Parser | undefined = undefined ;
7- let panel : vscode . WebviewPanel | undefined = undefined
7+ let panel : vscode . WebviewPanel | undefined = undefined ;
88
99// This method is called when your extension is activated
1010// Your extension is activated the very first time the command is executed
@@ -14,34 +14,28 @@ function activate(context: vscode.ExtensionContext) {
1414 let columnToShowIn : vscode . ViewColumn | undefined = vscode . window . activeTextEditor
1515 ? vscode . window . activeTextEditor . viewColumn
1616 : undefined ;
17-
1817
1918 // Command that allows for User to select the root file of their React application.
2019 const pickFile : vscode . Disposable = vscode . commands . registerCommand ( 'myExtension.pickFile' , async ( ) => {
21-
2220 // Check if there is an existing webview panel, if so display it.
23- if ( panel ) {
24- panel . reveal ( columnToShowIn )
21+ if ( panel ) {
22+ panel . reveal ( columnToShowIn ) ;
2523 }
2624
27-
2825 // Opens window for the User to select the root file of React application
2926 const fileArray : vscode . Uri [ ] = await vscode . window . showOpenDialog ( { canSelectFolders : false , canSelectFiles : true , canSelectMany : false } ) ;
30-
3127
3228 // Throw error message if no file was selected
3329 if ( ! fileArray || fileArray . length === 0 ) {
3430 vscode . window . showErrorMessage ( 'No file selected' ) ;
3531 return ;
3632 }
37-
3833
3934 // Create Tree to be inserted into returned HTML
4035 tree = new Parser ( fileArray [ 0 ] . path ) ;
4136 tree . parse ( ) ;
4237 const data : Tree = tree . getTree ( ) ;
4338
44-
4539 // Check if panel currently has a webview, if it does dispose of it and create another with updated root file selected.
4640 // Otherwise create a new webview to display root file selected.
4741 if ( ! panel ) {
@@ -54,23 +48,19 @@ function activate(context: vscode.ExtensionContext) {
5448 // Listens for when webview is closed and disposes of webview resources
5549 panel . onDidDispose (
5650 ( ) => {
57- console . log ( "Before: " , panel )
58- panel . dispose ( )
51+ panel . dispose ( ) ;
5952 panel = undefined ;
6053 columnToShowIn = undefined ;
61- console . log ( "After: " , panel )
6254 } ,
6355 null ,
6456 context . subscriptions
65- ) ;
57+ ) ;
6658 } ) ;
6759
68-
6960 // Command to show panel if it is hidden
7061 const showPanel : vscode . Disposable = vscode . commands . registerCommand ( 'myExtension.showPanel' , ( ) => {
71- panel . reveal ( columnToShowIn )
72- } ) ;
73-
62+ panel . reveal ( columnToShowIn ) ;
63+ } ) ;
7464
7565 context . subscriptions . push ( pickFile , showPanel ) ;
7666}
0 commit comments