Skip to content

Commit efcb26b

Browse files
authored
Fix run button visibility logic (#1319)
## Changes - Update custom context for the run button on startup - Update it when the active folder changes
1 parent dadffd7 commit efcb26b

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

packages/databricks-vscode/src/vscode-objs/WorkspaceFolderManager.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
QuickPickItem,
55
QuickPickItemKind,
66
StatusBarAlignment,
7+
TextEditor,
78
WorkspaceFolder,
89
window,
910
workspace,
@@ -34,6 +35,8 @@ export class WorkspaceFolderManager implements Disposable {
3435
this.button.show();
3536
}
3637

38+
this.setIsActiveFileInActiveWorkspace(window.activeTextEditor);
39+
3740
this.disposables.push(
3841
this.button,
3942
workspace.onDidChangeWorkspaceFolders((e) => {
@@ -51,20 +54,27 @@ export class WorkspaceFolderManager implements Disposable {
5154
return;
5255
}
5356
}),
54-
window.onDidChangeActiveTextEditor((e) => {
55-
const isActiveFileInActiveWorkspace =
56-
this.activeWorkspaceFolder !== undefined &&
57-
e !== undefined &&
58-
e.document.uri.fsPath.startsWith(
59-
this.activeWorkspaceFolder?.uri.fsPath
60-
);
61-
customWhenContext.setIsActiveFileInActiveWorkspace(
62-
isActiveFileInActiveWorkspace
63-
);
57+
window.onDidChangeActiveTextEditor((editor) => {
58+
this.setIsActiveFileInActiveWorkspace(editor);
59+
}),
60+
this.onDidChangeActiveWorkspaceFolder(() => {
61+
this.setIsActiveFileInActiveWorkspace(window.activeTextEditor);
6462
})
6563
);
6664
}
6765

66+
private setIsActiveFileInActiveWorkspace(activeEditor?: TextEditor) {
67+
const isActiveFileInActiveWorkspace =
68+
this.activeWorkspaceFolder !== undefined &&
69+
activeEditor !== undefined &&
70+
activeEditor.document.uri.fsPath.startsWith(
71+
this.activeWorkspaceFolder?.uri.fsPath
72+
);
73+
this.customWhenContext.setIsActiveFileInActiveWorkspace(
74+
isActiveFileInActiveWorkspace
75+
);
76+
}
77+
6878
get activeWorkspaceFolder() {
6979
if (this._activeWorkspaceFolder === undefined) {
7080
throw new Error("No active workspace folder");

0 commit comments

Comments
 (0)