Skip to content

Commit 679b0e9

Browse files
committed
feat: Set onbeforeunload to avoid losing the curr. terminal session with Ctrl+W
Close gitpod-io/gitpod#18416
1 parent 8f10c5f commit 679b0e9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ async function createTerminal(
205205
const debouncedUpdateTerminalSize = debounce(() => updateTerminalSize(term), 200, { trailing: true });
206206
window.onresize = () => debouncedUpdateTerminalSize();
207207

208+
// Ask for confirmation before closing the current terminal session
209+
window.onbeforeunload = (event) => {
210+
event.preventDefault();
211+
event.returnValue = "really?"; // supporting legacy browsers
212+
};
213+
208214
// Register the onclick event for the reconnect button
209215
reconnectButton.onclick = () => terminalSocket.reconnect();
210216

0 commit comments

Comments
 (0)