File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,15 @@ function startServer() {
182
182
}
183
183
}
184
184
185
- sendPortUpdates ( ) ;
185
+ async function init ( ) {
186
+ if ( process . env [ "XTERM_CONFIRM_BROWSER_EXIT" ] === "true" ) {
187
+ ws . send ( JSON . stringify ( { action : "confirmExit" } ) ) ;
188
+ }
189
+
190
+ sendPortUpdates ( ) ;
191
+ }
192
+
193
+ init ( ) ;
186
194
} ) ;
187
195
188
196
let clientForExternalMessages = null ;
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ export const initiateRemoteCommunicationChannelSocket = async (protocol: string)
66
66
output ( `Port ${ port } has been opened` , { formActions : [ openUrlButton ] , reason : "info" } ) ;
67
67
break ;
68
68
}
69
+ case "confirmExit" : {
70
+ // Ask for confirmation before closing the current terminal session
71
+ window . onbeforeunload = ( e : BeforeUnloadEvent ) => {
72
+ e . preventDefault ( ) ;
73
+ e . returnValue = "Are you sure you want to close the terminal?" ;
74
+ } ;
75
+ }
69
76
default :
70
77
console . debug ( "Unhandled message" , messageData ) ;
71
78
}
You can’t perform that action at this time.
0 commit comments