@@ -7,6 +7,8 @@ import EditorFile from "lib/editorFile";
77import TerminalComponent from "./terminal" ;
88import "@xterm/xterm/css/xterm.css" ;
99import toast from "components/toast" ;
10+ import confirm from "dialogs/confirm" ;
11+ import appSettings from "lib/settings" ;
1012import helpers from "utils/helpers" ;
1113
1214const TERMINAL_SESSION_STORAGE_KEY = "acodeTerminalSessions" ;
@@ -413,6 +415,22 @@ class TerminalManager {
413415 this . closeTerminal ( terminalId ) ;
414416 } ;
415417
418+ terminalFile . _skipTerminalCloseConfirm = false ;
419+ const originalRemove = terminalFile . remove . bind ( terminalFile ) ;
420+ terminalFile . remove = async ( force = false ) => {
421+ if (
422+ ! terminalFile . _skipTerminalCloseConfirm &&
423+ this . shouldConfirmTerminalClose ( )
424+ ) {
425+ const message = `${ strings [ "close" ] } ${ strings [ "terminal" ] } ?` ;
426+ const shouldClose = await confirm ( strings [ "confirm" ] , message ) ;
427+ if ( ! shouldClose ) return ;
428+ }
429+
430+ terminalFile . _skipTerminalCloseConfirm = false ;
431+ return originalRemove ( force ) ;
432+ } ;
433+
416434 // Enhanced resize handling with debouncing
417435 let resizeTimeout = null ;
418436 const RESIZE_DEBOUNCE = 200 ;
@@ -519,6 +537,7 @@ class TerminalManager {
519537 }
520538
521539 this . closeTerminal ( terminalId ) ;
540+ terminalFile . _skipTerminalCloseConfirm = true ;
522541 terminalFile . remove ( true ) ;
523542 toast ( message ) ;
524543 } ;
@@ -731,6 +750,14 @@ class TerminalManager {
731750 }
732751 } ) ;
733752 }
753+
754+ shouldConfirmTerminalClose ( ) {
755+ const settings = appSettings ?. value ?. terminalSettings ;
756+ if ( settings && settings . confirmTabClose === false ) {
757+ return false ;
758+ }
759+ return true ;
760+ }
734761}
735762
736763// Create singleton instance
0 commit comments