Skip to content

Commit 5289adb

Browse files
committed
Fix: correctly handle closing the webview.
1 parent 85f7b00 commit 5289adb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

extensions/VSCode/src/extension.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ let ignore_text_document_change = false;
8888
// True to ignore the next active editor change event, since a `CurrentFile`
8989
// message from the Client caused this change.
9090
let ignore_active_editor_change = false;
91+
// True to not report the next error.
92+
let quiet_next_error = false;
9193

9294
// ### Message types
9395
//
@@ -267,8 +269,11 @@ export const activate = (context: vscode.ExtensionContext) => {
267269
console.log(
268270
"CodeChat Editor extension: shut down webview."
269271
);
270-
await stop_client();
272+
// Closing the webview abruptly closes the Client,
273+
// which produces an error. Don't report it.
274+
quiet_next_error = true;
271275
webview_panel = undefined;
276+
await stop_client();
272277
});
273278

274279
// Render when the webview panel is shown.
@@ -666,6 +671,10 @@ const stop_client = async () => {
666671

667672
// Provide an error message in the panel if possible.
668673
const show_error = (message: string) => {
674+
if (quiet_next_error) {
675+
quiet_next_error = false;
676+
return;
677+
}
669678
if (webview_panel !== undefined) {
670679
// If the panel was displaying other content, reset it for errors.
671680
if (

0 commit comments

Comments
 (0)