File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1492,6 +1492,21 @@ it.layer(
14921492 } ) ,
14931493 ) ;
14941494
1495+ it . effect ( "keeps a decoded U+009C inside a stripped OSC query out of history" , ( ) =>
1496+ Effect . gen ( function * ( ) {
1497+ const { manager, ptyAdapter } = yield * createManager ( ) ;
1498+ yield * manager . open ( openInput ( ) ) ;
1499+ const process = ptyAdapter . processes [ 0 ] ! ;
1500+ // libghostty receives UTF-8 (c2 9c), which is OSC payload; only ESC \ ends this string.
1501+ process . emitData ( "A\u001b]11;?\u009cHIDDEN\u001b\\B\n" ) ;
1502+ // A DCS string does end at U+009C there, so the text after it stays visible.
1503+ process . emitData ( "C\u001bP$qm\u009cSHOWN\u001b\\D\n" ) ;
1504+ yield * manager . close ( { threadId : "thread-1" } ) ;
1505+
1506+ expect ( ( yield * manager . open ( openInput ( ) ) ) . history ) . toMatch ( / ^ A B \n C S H O W N \u001b \\ D \n / ) ;
1507+ } ) ,
1508+ ) ;
1509+
14951510 it . effect ( "preserves large chunked OSC 52 and DCS strings across reopen" , ( ) =>
14961511 Effect . gen ( function * ( ) {
14971512 const { manager, ptyAdapter, logsDir } = yield * createManager ( ) ;
Original file line number Diff line number Diff line change @@ -1194,19 +1194,12 @@ function stripStringTerminator(value: string): string {
11941194 return value ;
11951195}
11961196
1197- // BEL ends only OSC; inside DCS, PM and APC it is payload.
1198- function findStringTerminatorIndex (
1199- input : string ,
1200- start : number ,
1201- belTerminates : boolean ,
1202- ) : number | null {
1197+ // BEL ends only OSC; inside DCS, PM and APC it is payload. A decoded U+009C is the
1198+ // reverse: libghostty keeps it inside OSC but ends the other strings there.
1199+ function findStringTerminatorIndex ( input : string , start : number , isOsc : boolean ) : number | null {
12031200 for ( let index = start ; index < input . length ; index += 1 ) {
12041201 const codePoint = input . charCodeAt ( index ) ;
1205- if (
1206- ( belTerminates && codePoint === 0x07 ) ||
1207- codePoint === 0x9c ||
1208- isControlSequenceCancel ( codePoint )
1209- ) {
1202+ if ( ( isOsc ? codePoint === 0x07 : codePoint === 0x9c ) || isControlSequenceCancel ( codePoint ) ) {
12101203 return index + 1 ;
12111204 }
12121205 // Like xterm.js, an ESC that does not start ST ends the string and begins the next sequence.
You can’t perform that action at this time.
0 commit comments