Skip to content

Commit e02cf4c

Browse files
add view state change handler to update current table view stats and context info (#107 & #108)
1 parent 3b4eeb8 commit e02cf4c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/views/tableView.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,24 @@ export class TableView {
167167
// add it to the tracked table webviews
168168
TableView._views.set(this.viewUri.toString(true), this);
169169

170+
// update tablew view context values on webview state change
171+
this._webviewPanel.onDidChangeViewState(
172+
(viewChangeEvent: WebviewPanelOnDidChangeViewStateEvent) => {
173+
if (this._webviewPanel.active) {
174+
// update table view context values
175+
commands.executeCommand(ViewCommands.setContext, ViewContexts.tableViewVisible, true);
176+
commands.executeCommand(ViewCommands.setContext, ViewContexts.tabularDataUri, documentUri);
177+
statusBar.showFileStats(this._fileInfo);
178+
TableView.currentView = this;
179+
}
180+
else {
181+
// clear and hide current table view stats display
182+
statusBar.hide();
183+
commands.executeCommand(ViewCommands.setContext, ViewContexts.tableViewVisible, false);
184+
TableView.currentView = undefined;
185+
}
186+
});
187+
170188
// dispose table view resources when table view panel is closed by the user or via vscode apis
171189
this._webviewPanel.onDidDispose(this.dispose, this, this._disposables);
172190
}

0 commit comments

Comments
 (0)