@@ -483,17 +483,14 @@ export class TerminalInstance implements ITerminalInstance {
483483 this . _xterm . onKey ( e => this . _onKey ( e . key , e . domEvent ) ) ;
484484
485485 this . _processManager . onProcessData ( data => this . _onProcessData ( data ) ) ;
486- this . _xterm . onData ( data => this . _processManager ! . write ( data ) ) ;
486+ this . _xterm . onData ( data => this . _processManager . write ( data ) ) ;
487487 // TODO: How does the cwd work on detached processes?
488488 this . processReady . then ( async ( ) => {
489- this . _linkHandler . processCwd = await this . _processManager ! . getInitialCwd ( ) ;
489+ this . _linkHandler . processCwd = await this . _processManager . getInitialCwd ( ) ;
490490 } ) ;
491491 // Init winpty compat and link handler after process creation as they rely on the
492492 // underlying process OS
493493 this . _processManager . onProcessReady ( ( ) => {
494- if ( ! this . _processManager ) {
495- return ;
496- }
497494 if ( this . _processManager . os === platform . OperatingSystem . Windows ) {
498495 xterm . setOption ( 'windowsMode' , true ) ;
499496 // Force line data to be sent when the cursor is moved, the main purpose for
@@ -808,14 +805,7 @@ export class TerminalInstance implements ITerminalInstance {
808805 this . _pressAnyKeyToCloseListener = undefined ;
809806 }
810807
811- if ( this . _processManager ) {
812- this . _processManager . dispose ( immediate ) ;
813- } else {
814- // In cases where there is no associated process (for example executing an extension callback task)
815- // consumers still expect on onExit event to be fired. An example of this is terminating the extension callback
816- // task.
817- this . _onExit . fire ( 0 ) ;
818- }
808+ this . _processManager . dispose ( immediate ) ;
819809
820810 if ( ! this . _isDisposed ) {
821811 this . _isDisposed = true ;
@@ -882,12 +872,8 @@ export class TerminalInstance implements ITerminalInstance {
882872 text += '\r' ;
883873 }
884874
885- // If the terminal has a process, send it to the process
886- if ( this . _processManager ) {
887- this . _processManager . ptyProcessReady . then ( ( ) => {
888- this . _processManager ! . write ( text ) ;
889- } ) ;
890- }
875+ // Send it to the process
876+ this . _processManager . ptyProcessReady . then ( ( ) => this . _processManager . write ( text ) ) ;
891877 }
892878
893879 public setVisible ( visible : boolean ) : void {
@@ -984,7 +970,7 @@ export class TerminalInstance implements ITerminalInstance {
984970
985971 if ( platform . isWindows ) {
986972 this . _processManager . ptyProcessReady . then ( ( ) => {
987- if ( this . _processManager ! . remoteAuthority ) {
973+ if ( this . _processManager . remoteAuthority ) {
988974 return ;
989975 }
990976 this . _xtermReadyPromise . then ( xterm => {
@@ -998,7 +984,7 @@ export class TerminalInstance implements ITerminalInstance {
998984 // Create the process asynchronously to allow the terminal's container
999985 // to be created so dimensions are accurate
1000986 setTimeout ( ( ) => {
1001- this . _processManager ! . createProcess ( this . _shellLaunchConfig , this . _cols , this . _rows , this . _isScreenReaderOptimized ( ) ) ;
987+ this . _processManager . createProcess ( this . _shellLaunchConfig , this . _cols , this . _rows , this . _isScreenReaderOptimized ( ) ) ;
1002988 } , 0 ) ;
1003989 }
1004990
@@ -1036,7 +1022,7 @@ export class TerminalInstance implements ITerminalInstance {
10361022 exitCodeMessage = nls . localize ( 'terminal.integrated.exitedWithInvalidPathDirectory' , 'The terminal shell path "{0}" is a directory' , this . _shellLaunchConfig . executable ) ;
10371023 } else if ( exitCode === SHELL_CWD_INVALID_EXIT_CODE && this . _shellLaunchConfig . cwd ) {
10381024 exitCodeMessage = nls . localize ( 'terminal.integrated.exitedWithInvalidCWD' , 'The terminal shell CWD "{0}" does not exist' , this . _shellLaunchConfig . cwd . toString ( ) ) ;
1039- } else if ( this . _processManager && this . _processManager . processState === ProcessState . KILLED_DURING_LAUNCH ) {
1025+ } else if ( this . _processManager . processState === ProcessState . KILLED_DURING_LAUNCH ) {
10401026 let args = '' ;
10411027 if ( typeof this . _shellLaunchConfig . args === 'string' ) {
10421028 args = ` ${ this . _shellLaunchConfig . args } ` ;
@@ -1058,11 +1044,11 @@ export class TerminalInstance implements ITerminalInstance {
10581044 }
10591045 }
10601046
1061- this . _logService . debug ( `Terminal process exit (id: ${ this . id } )${ this . _processManager ? ' state ' + this . _processManager . processState : '' } ` ) ;
1047+ this . _logService . debug ( `Terminal process exit (id: ${ this . id } ) state ${ this . _processManager . processState } ` ) ;
10621048
10631049 // Only trigger wait on exit when the exit was *not* triggered by the
10641050 // user (via the `workbench.action.terminal.kill` command).
1065- if ( this . _shellLaunchConfig . waitOnExit && ( ! this . _processManager || this . _processManager . processState !== ProcessState . KILLED_BY_USER ) ) {
1051+ if ( this . _shellLaunchConfig . waitOnExit && this . _processManager . processState !== ProcessState . KILLED_BY_USER ) {
10661052 this . _xtermReadyPromise . then ( xterm => {
10671053 if ( exitCodeMessage ) {
10681054 xterm . writeln ( exitCodeMessage ) ;
@@ -1082,7 +1068,7 @@ export class TerminalInstance implements ITerminalInstance {
10821068 } else {
10831069 this . dispose ( ) ;
10841070 if ( exitCodeMessage ) {
1085- if ( this . _processManager && this . _processManager . processState === ProcessState . KILLED_DURING_LAUNCH ) {
1071+ if ( this . _processManager . processState === ProcessState . KILLED_DURING_LAUNCH ) {
10861072 this . _notificationService . error ( exitCodeMessage ) ;
10871073 } else {
10881074 if ( this . _configHelper . config . showExitAlert ) {
@@ -1118,9 +1104,7 @@ export class TerminalInstance implements ITerminalInstance {
11181104 }
11191105
11201106 // Kill and clear up the process, making the process manager ready for a new process
1121- if ( this . _processManager ) {
1122- this . _processManager . dispose ( ) ;
1123- }
1107+ this . _processManager . dispose ( ) ;
11241108
11251109 if ( this . _xterm ) {
11261110 // Ensure new processes' output starts at start of new line
@@ -1150,11 +1134,7 @@ export class TerminalInstance implements ITerminalInstance {
11501134 this . setTitle ( this . _title , true ) ;
11511135 }
11521136
1153- if ( this . _processManager ) {
1154- // The "!" operator is required here because _processManager is set to undefiend earlier
1155- // and TS does not know that createProcess sets it.
1156- this . _processManager ! . onProcessData ( data => this . _onProcessData ( data ) ) ;
1157- }
1137+ this . _processManager . onProcessData ( data => this . _onProcessData ( data ) ) ;
11581138 }
11591139
11601140 private _onLineFeed ( ) : void {
@@ -1339,9 +1319,7 @@ export class TerminalInstance implements ITerminalInstance {
13391319 }
13401320 }
13411321
1342- if ( this . _processManager ) {
1343- this . _processManager . ptyProcessReady . then ( ( ) => this . _processManager ! . setDimensions ( cols , rows ) ) ;
1344- }
1322+ this . _processManager . ptyProcessReady . then ( ( ) => this . _processManager . setDimensions ( cols , rows ) ) ;
13451323 }
13461324
13471325 public setTitle ( title : string | undefined , eventFromProcess : boolean ) : void {
@@ -1438,16 +1416,10 @@ export class TerminalInstance implements ITerminalInstance {
14381416 }
14391417
14401418 public getInitialCwd ( ) : Promise < string > {
1441- if ( ! this . _processManager ) {
1442- return Promise . resolve ( '' ) ;
1443- }
14441419 return this . _processManager . getInitialCwd ( ) ;
14451420 }
14461421
14471422 public getCwd ( ) : Promise < string > {
1448- if ( ! this . _processManager ) {
1449- return Promise . resolve ( '' ) ;
1450- }
14511423 return this . _processManager . getCwd ( ) ;
14521424 }
14531425}
0 commit comments