@@ -57,7 +57,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
5757
5858 protected _inputHandler : InputHandler ;
5959 private _writeBuffer : WriteBuffer ;
60- private _windowsMode : IDisposable | undefined ;
60+ private _windowsWrappingHeuristics : IDisposable | undefined ;
6161
6262 private readonly _onBinary = this . register ( new EventEmitter < string > ( ) ) ;
6363 public readonly onBinary = this . _onBinary . event ;
@@ -131,7 +131,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
131131 this . register ( forwardEvent ( this . coreService . onBinary , this . _onBinary ) ) ;
132132 this . register ( this . coreService . onRequestScrollToBottom ( ( ) => this . scrollToBottom ( ) ) ) ;
133133 this . register ( this . coreService . onUserInput ( ( ) => this . _writeBuffer . handleUserInput ( ) ) ) ;
134- this . register ( this . optionsService . onSpecificOptionChange ( 'windowsMode' , e => this . _handleWindowsModeOptionChange ( e ) ) ) ;
134+ this . register ( this . optionsService . onMultipleOptionChange ( [ 'windowsMode' , 'windowsPty' ] , ( ) => this . _handleWindowsPtyOptionChange ( ) ) ) ;
135135 this . register ( this . _bufferService . onScroll ( event => {
136136 this . _onScroll . fire ( { position : this . _bufferService . buffer . ydisp , source : ScrollSource . TERMINAL } ) ;
137137 this . _inputHandler . markRangeDirty ( this . _bufferService . buffer . scrollTop , this . _bufferService . buffer . scrollBottom ) ;
@@ -146,8 +146,8 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
146146 this . register ( forwardEvent ( this . _writeBuffer . onWriteParsed , this . _onWriteParsed ) ) ;
147147
148148 this . register ( toDisposable ( ( ) => {
149- this . _windowsMode ?. dispose ( ) ;
150- this . _windowsMode = undefined ;
149+ this . _windowsWrappingHeuristics ?. dispose ( ) ;
150+ this . _windowsWrappingHeuristics = undefined ;
151151 } ) ) ;
152152 }
153153
@@ -250,9 +250,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
250250 }
251251
252252 protected _setup ( ) : void {
253- if ( this . optionsService . rawOptions . windowsMode ) {
254- this . _enableWindowsMode ( ) ;
255- }
253+ this . _handleWindowsPtyOptionChange ( ) ;
256254 }
257255
258256 public reset ( ) : void {
@@ -263,30 +261,36 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
263261 this . coreMouseService . reset ( ) ;
264262 }
265263
266- private _handleWindowsModeOptionChange ( value : boolean ) : void {
264+
265+ private _handleWindowsPtyOptionChange ( ) : void {
266+ let value = false ;
267+ const windowsPty = this . optionsService . rawOptions . windowsPty ;
268+ if ( windowsPty && windowsPty . buildNumber !== undefined && windowsPty . buildNumber !== undefined ) {
269+ value = ! ! ( windowsPty . backend === 'conpty' && windowsPty . buildNumber < 21376 ) ;
270+ } else if ( this . optionsService . rawOptions . windowsMode ) {
271+ value = true ;
272+ }
267273 if ( value ) {
268- this . _enableWindowsMode ( ) ;
274+ this . _enableWindowsWrappingHeuristics ( ) ;
269275 } else {
270- this . _windowsMode ?. dispose ( ) ;
271- this . _windowsMode = undefined ;
276+ this . _windowsWrappingHeuristics ?. dispose ( ) ;
277+ this . _windowsWrappingHeuristics = undefined ;
272278 }
273279 }
274280
275- protected _enableWindowsMode ( ) : void {
276- if ( ! this . _windowsMode ) {
281+ protected _enableWindowsWrappingHeuristics ( ) : void {
282+ if ( ! this . _windowsWrappingHeuristics ) {
277283 const disposables : IDisposable [ ] = [ ] ;
278284 disposables . push ( this . onLineFeed ( updateWindowsModeWrappedState . bind ( null , this . _bufferService ) ) ) ;
279285 disposables . push ( this . registerCsiHandler ( { final : 'H' } , ( ) => {
280286 updateWindowsModeWrappedState ( this . _bufferService ) ;
281287 return false ;
282288 } ) ) ;
283- this . _windowsMode = {
284- dispose : ( ) => {
285- for ( const d of disposables ) {
286- d . dispose ( ) ;
287- }
289+ this . _windowsWrappingHeuristics = toDisposable ( ( ) => {
290+ for ( const d of disposables ) {
291+ d . dispose ( ) ;
288292 }
289- } ;
293+ } ) ;
290294 }
291295 }
292296}
0 commit comments