@@ -36,6 +36,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
36
36
private _titleInterval : NodeJS . Timer | null = null ;
37
37
private _writeQueue : string [ ] = [ ] ;
38
38
private _writeTimeout : NodeJS . Timeout | undefined ;
39
+ private _delayedResizer : DelayedResizer | undefined ;
39
40
private readonly _initialCwd : string ;
40
41
private readonly _ptyOptions : pty . IPtyForkOptions | pty . IWindowsPtyForkOptions ;
41
42
@@ -80,6 +81,17 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
80
81
// This option will force conpty to not redraw the whole viewport on launch
81
82
conptyInheritCursor : useConpty && ! ! _shellLaunchConfig . initialText
82
83
} ;
84
+ // Delay resizes to avoid conpty not respecting very early resize calls
85
+ if ( platform . isWindows && useConpty && cols === 0 && rows === 0 && this . _shellLaunchConfig . executable ?. endsWith ( 'Git\\bin\\bash.exe' ) ) {
86
+ this . _delayedResizer = new DelayedResizer ( ) ;
87
+ this . _register ( this . _delayedResizer . onTrigger ( dimensions => {
88
+ this . _delayedResizer ?. dispose ( ) ;
89
+ this . _delayedResizer = undefined ;
90
+ if ( dimensions . cols && dimensions . rows ) {
91
+ this . resize ( dimensions . cols , dimensions . rows ) ;
92
+ }
93
+ } ) ) ;
94
+ }
83
95
}
84
96
85
97
public async start ( ) : Promise < ITerminalLaunchError | undefined > {
@@ -286,6 +298,14 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
286
298
if ( this . _ptyProcess ) {
287
299
cols = Math . max ( cols , 1 ) ;
288
300
rows = Math . max ( rows , 1 ) ;
301
+
302
+ // Delay resize if needed
303
+ if ( this . _delayedResizer ) {
304
+ this . _delayedResizer . cols = cols ;
305
+ this . _delayedResizer . rows = rows ;
306
+ return ;
307
+ }
308
+
289
309
this . _logService . trace ( 'IPty#resize' , cols , rows ) ;
290
310
try {
291
311
this . _ptyProcess . resize ( cols , rows ) ;
@@ -344,3 +364,32 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
344
364
return Promise . resolve ( 0 ) ;
345
365
}
346
366
}
367
+
368
+ /**
369
+ * Tracks the latest resize event to be trigger at a later point.
370
+ */
371
+ class DelayedResizer extends Disposable {
372
+ public rows : number | undefined ;
373
+ public cols : number | undefined ;
374
+ private _timeout : NodeJS . Timeout ;
375
+
376
+ private readonly _onTrigger = this . _register ( new Emitter < { rows ?: number , cols ?: number } > ( ) ) ;
377
+ public get onTrigger ( ) : Event < { rows ?: number , cols ?: number } > { return this . _onTrigger . event ; }
378
+
379
+ constructor ( ) {
380
+ super ( ) ;
381
+ this . _timeout = setTimeout ( ( ) => {
382
+ this . _onTrigger . fire ( { rows : this . rows , cols : this . cols } ) ;
383
+ } , 1000 ) ;
384
+ this . _register ( {
385
+ dispose : ( ) => {
386
+ clearTimeout ( this . _timeout ) ;
387
+ }
388
+ } ) ;
389
+ }
390
+
391
+ dispose ( ) : void {
392
+ super . dispose ( ) ;
393
+ clearTimeout ( this . _timeout ) ;
394
+ }
395
+ }
0 commit comments