@@ -112,6 +112,7 @@ export class TermWrap {
112112 viewportScrollTop : number = 0 ;
113113 recentWrites : { idx : number ; data : string ; ts : number } [ ] = [ ] ;
114114 recentWritesCounter : number = 0 ;
115+ lastClearScrollbackTs : number = 0 ;
115116
116117 constructor (
117118 tabId : string ,
@@ -192,6 +193,14 @@ export class TermWrap {
192193 this . terminal . parser . registerOscHandler ( 16162 , ( data : string ) => {
193194 return handleOsc16162Command ( data , this . blockId , this . loaded , this ) ;
194195 } ) ;
196+ this . toDispose . push (
197+ this . terminal . parser . registerCsiHandler ( { final : "J" } , ( params ) => {
198+ if ( params [ 0 ] === 3 ) {
199+ this . lastClearScrollbackTs = Date . now ( ) ;
200+ }
201+ return false ;
202+ } )
203+ ) ;
195204 this . toDispose . push (
196205 this . terminal . onBell ( ( ) => {
197206 if ( ! this . loaded ) {
@@ -559,6 +568,7 @@ export class TermWrap {
559568 this . fitAddon . fit ( ) ;
560569 if ( oldRows !== this . terminal . rows || oldCols !== this . terminal . cols ) {
561570 const termSize : TermSize = { rows : this . terminal . rows , cols : this . terminal . cols } ;
571+ console . log ( "[termwrap] resize" , `${ oldRows } x${ oldCols } ` , "->" , `${ this . terminal . rows } x${ this . terminal . cols } ` , "atBottom:" , atBottom ) ;
562572 RpcApi . ControllerInputCommand ( TabRpcClient , { blockid : this . blockId , termsize : termSize } ) ;
563573 }
564574 dlog ( "resize" , `${ this . terminal . rows } x${ this . terminal . cols } ` , `${ oldRows } x${ oldCols } ` , this . hasResized ) ;
@@ -568,6 +578,7 @@ export class TermWrap {
568578 }
569579 if ( atBottom ) {
570580 setTimeout ( ( ) => {
581+ console . log ( "[termwrap] resize scroll-to-bottom" ) ;
571582 this . cachedAtBottomForResize = null ;
572583 this . terminal . scrollToBottom ( ) ;
573584 this . setAtBottom ( true ) ;
0 commit comments