Skip to content

Commit 963351d

Browse files
committed
Fix: handle file not found in VSCode extension
1 parent 89f878d commit 963351d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CodeChat Editor. If not, see
1919
# Changelog
2020

2121
- [Github master](https://github.com/bjones1/CodeChat_Editor):
22+
- Correctly handle file not found in VSCode.
2223
- Correct filename handling on Windows.
2324
- v0.1.7, 2025-Jan-08:
2425
- Fixed hyperlink navigation.

extensions/VSCode/src/extension.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,20 @@ export const activate = (context: vscode.ExtensionContext) => {
433433
const current_file = value as string;
434434
vscode.workspace
435435
.openTextDocument(current_file)
436-
.then((document) => {
437-
ignore_active_editor_change = true;
438-
vscode.window.showTextDocument(
439-
document,
440-
current_editor?.viewColumn
441-
);
442-
send_result(id);
443-
});
436+
.then(
437+
(document) => {
438+
ignore_active_editor_change = true;
439+
vscode.window.showTextDocument(
440+
document,
441+
current_editor?.viewColumn
442+
);
443+
send_result(id);
444+
},
445+
(reason) =>
446+
send_result(id, {
447+
Err: `Error: unable to open file ${current_file}: ${reason}`,
448+
})
449+
);
444450
break;
445451
}
446452

0 commit comments

Comments
 (0)