Skip to content

Commit

Permalink
Fix: only show Current File for file scheme editors (#255)
Browse files Browse the repository at this point in the history
Prevents invalid file paths from appearing in the Current File button when
clicking on non-file editors like Output panel or Terminal. Now checks
editor's URI scheme to ensure it's a valid file before updating the active
file path.

Co-authored-by: cwilliams <[email protected]>
  • Loading branch information
charlwillia6 and cwilliams authored Jan 31, 2025
1 parent b5e5732 commit 47242a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extensions/vscode/src/ideProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class VsCodeIde implements IDE {

onDidChangeActiveTextEditor(callback: (filepath: string) => void): void {
vscode.window.onDidChangeActiveTextEditor((editor) => {
if (editor) {
if (editor?.document.uri.scheme === 'file') {
callback(editor.document.uri.fsPath);
}
});
Expand Down
3 changes: 2 additions & 1 deletion gui/src/redux/slices/uiStateSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const uiStateSlice = createSlice({
state.displayBottomMessageOnBottom = action.payload;
},
setActiveFilePath: (state, action: PayloadAction<UiState["activeFilePath"]>) => {
state.activeFilePath = action.payload ?? "";
// Only set non-empty strings as active file paths
state.activeFilePath = action.payload && action.payload.length > 0 ? action.payload : undefined;
},
},
});
Expand Down

0 comments on commit 47242a3

Please sign in to comment.