Skip to content

Commit

Permalink
add view state change handler to update current table view stats and …
Browse files Browse the repository at this point in the history
…context info (#107 & #108)
  • Loading branch information
RandomFractals committed Feb 9, 2022
1 parent 3b4eeb8 commit e02cf4c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/views/tableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ export class TableView {
// add it to the tracked table webviews
TableView._views.set(this.viewUri.toString(true), this);

// update tablew view context values on webview state change
this._webviewPanel.onDidChangeViewState(
(viewChangeEvent: WebviewPanelOnDidChangeViewStateEvent) => {
if (this._webviewPanel.active) {
// update table view context values
commands.executeCommand(ViewCommands.setContext, ViewContexts.tableViewVisible, true);
commands.executeCommand(ViewCommands.setContext, ViewContexts.tabularDataUri, documentUri);
statusBar.showFileStats(this._fileInfo);
TableView.currentView = this;
}
else {
// clear and hide current table view stats display
statusBar.hide();
commands.executeCommand(ViewCommands.setContext, ViewContexts.tableViewVisible, false);
TableView.currentView = undefined;
}
});

// dispose table view resources when table view panel is closed by the user or via vscode apis
this._webviewPanel.onDidDispose(this.dispose, this, this._disposables);
}
Expand Down

0 comments on commit e02cf4c

Please sign in to comment.