@@ -151,15 +151,6 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
151151 const instanceOnDidFocusListener = instance . onDidFocus ( ( ) => this . _terminalEditorFocusContextKey . set ( true ) ) ;
152152 const instanceOnDidBlurListener = instance . onDidBlur ( ( ) => this . _terminalEditorFocusContextKey . reset ( ) ) ;
153153
154- this . _register ( toDisposable ( ( ) => {
155- if ( ! this . _isDetached && ! this . _isShuttingDown ) {
156- // Will be ignored if triggered by onExit or onDisposed terminal events
157- // as disposed was already called
158- instance . dispose ( TerminalExitReason . User ) ;
159- }
160- dispose ( [ instanceOnDidFocusListener , instanceOnDidBlurListener ] ) ;
161- } ) ) ;
162-
163154 const disposeListeners = [
164155 instance . onExit ( ( e ) => {
165156 if ( ! instance . waitOnExit ) {
@@ -174,9 +165,19 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
174165 instance . statusList . onDidChangePrimaryStatus ( ( ) => this . _onDidChangeLabel . fire ( ) )
175166 ] ;
176167
168+ this . _register ( toDisposable ( ( ) => {
169+ if ( ! this . _isDetached && ! this . _isShuttingDown ) {
170+ // Will be ignored if triggered by onExit or onDisposed terminal events
171+ // as disposed was already called
172+ instance . dispose ( TerminalExitReason . User ) ;
173+ }
174+ dispose ( disposeListeners ) ;
175+ dispose ( [ instanceOnDidFocusListener , instanceOnDidBlurListener ] ) ;
176+ } ) ) ;
177+
177178 // Don't dispose editor when instance is torn down on shutdown to avoid extra work and so
178179 // the editor/tabs don't disappear
179- this . _lifecycleService . onWillShutdown ( ( e : WillShutdownEvent ) => {
180+ this . _register ( this . _lifecycleService . onWillShutdown ( ( e : WillShutdownEvent ) => {
180181 this . _isShuttingDown = true ;
181182 dispose ( disposeListeners ) ;
182183
@@ -187,7 +188,7 @@ export class TerminalEditorInput extends EditorInput implements IEditorCloseHand
187188 } else {
188189 instance . dispose ( TerminalExitReason . Shutdown ) ;
189190 }
190- } ) ;
191+ } ) ) ;
191192 }
192193
193194 override getName ( ) {
0 commit comments