@@ -732,80 +732,78 @@ describe('Terminal', () => {
732732 } ) ;
733733
734734 describe ( 'unicode - surrogates' , ( ) => {
735- it ( '2 characters per cell' , async function ( ) : Promise < void > {
736- this . timeout ( 10000 ) ; // This is needed because istanbul patches code and slows it down
737- const high = String . fromCharCode ( 0xD800 ) ;
738- const cell = new CellData ( ) ;
739- for ( let i = 0xDC00 ; i <= 0xDCFF ; ++ i ) {
740- await term . writeP ( high + String . fromCharCode ( i ) ) ;
741- const tchar = term . buffer . lines . get ( 0 ) ! . loadCell ( 0 , cell ) ;
742- assert . equal ( tchar . getChars ( ) , high + String . fromCharCode ( i ) ) ;
743- assert . equal ( tchar . getChars ( ) . length , 2 ) ;
744- assert . equal ( tchar . getWidth ( ) , 1 ) ;
745- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
746- term . reset ( ) ;
747- }
748- } ) ;
749- it ( '2 characters at last cell' , async ( ) => {
750- const high = String . fromCharCode ( 0xD800 ) ;
751- const cell = new CellData ( ) ;
752- for ( let i = 0xDC00 ; i <= 0xDCFF ; ++ i ) {
753- term . buffer . x = term . cols - 1 ;
754- await term . writeP ( high + String . fromCharCode ( i ) ) ;
755- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . buffer . x - 1 , cell ) . getChars ( ) , high + String . fromCharCode ( i ) ) ;
756- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . buffer . x - 1 , cell ) . getChars ( ) . length , 2 ) ;
757- assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) , '' ) ;
758- term . reset ( ) ;
759- }
760- } ) ;
761- it ( '2 characters per cell over line end with autowrap' , async function ( ) : Promise < void > {
762- this . timeout ( 10000 ) ;
763- const high = String . fromCharCode ( 0xD800 ) ;
764- const cell = new CellData ( ) ;
765- for ( let i = 0xDC00 ; i <= 0xDCFF ; ++ i ) {
766- term . buffer . x = term . cols - 1 ;
767-
768- await term . writeP ( 'a' + high + String . fromCharCode ( i ) ) ;
769- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) , 'a' ) ;
770- assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) , high + String . fromCharCode ( i ) ) ;
771- assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) . length , 2 ) ;
772- assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
773- term . reset ( ) ;
774- }
775- } ) ;
776- it ( '2 characters per cell over line end without autowrap' , async function ( ) : Promise < void > {
777- this . timeout ( 10000 ) ;
778- const high = String . fromCharCode ( 0xD800 ) ;
779- const cell = new CellData ( ) ;
780- for ( let i = 0xDC00 ; i <= 0xDCFF ; ++ i ) {
735+ for ( let i = 0xDC00 ; i <= 0xDCF0 ; i += 0x10 ) {
736+ const range = `0x${ i . toString ( 16 ) . toUpperCase ( ) } -0x${ ( i + 0xF ) . toString ( 16 ) . toUpperCase ( ) } ` ;
737+ it ( `${ range } : 2 characters per cell` , async function ( ) : Promise < void > {
738+ const high = String . fromCharCode ( 0xD800 ) ;
739+ const cell = new CellData ( ) ;
740+ for ( let j = i ; j <= i + 0xF ; j ++ ) {
741+ await term . writeP ( high + String . fromCharCode ( j ) ) ;
742+ const tchar = term . buffer . lines . get ( 0 ) ! . loadCell ( 0 , cell ) ;
743+ assert . equal ( tchar . getChars ( ) , high + String . fromCharCode ( j ) ) ;
744+ assert . equal ( tchar . getChars ( ) . length , 2 ) ;
745+ assert . equal ( tchar . getWidth ( ) , 1 ) ;
746+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
747+ term . reset ( ) ;
748+ }
749+ } ) ;
750+ it ( `${ range } : 2 characters at last cell` , async ( ) => {
751+ const high = String . fromCharCode ( 0xD800 ) ;
752+ const cell = new CellData ( ) ;
781753 term . buffer . x = term . cols - 1 ;
782- await term . writeP ( '\x1b[?7l' ) ; // Disable wraparound mode
783- const width = wcwidth ( ( 0xD800 - 0xD800 ) * 0x400 + i - 0xDC00 + 0x10000 ) ;
784- if ( width !== 1 ) {
785- continue ;
754+ for ( let j = i ; j <= i + 0xF ; j ++ ) {
755+ await term . writeP ( high + String . fromCharCode ( j ) ) ;
756+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . buffer . x - 1 , cell ) . getChars ( ) , high + String . fromCharCode ( j ) ) ;
757+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . buffer . x - 1 , cell ) . getChars ( ) . length , 2 ) ;
758+ assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) , '' ) ;
759+ term . reset ( ) ;
786760 }
787- await term . writeP ( 'a' + high + String . fromCharCode ( i ) ) ;
788- // auto wraparound mode should cut off the rest of the line
789- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) , high + String . fromCharCode ( i ) ) ;
790- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) . length , 2 ) ;
791- assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
792- term . reset ( ) ;
793- }
794- } ) ;
795- it ( 'splitted surrogates' , async function ( ) : Promise < void > {
796- this . timeout ( 10000 ) ;
797- const high = String . fromCharCode ( 0xD800 ) ;
798- const cell = new CellData ( ) ;
799- for ( let i = 0xDC00 ; i <= 0xDCFF ; ++ i ) {
800- await term . writeP ( high + String . fromCharCode ( i ) ) ;
801- const tchar = term . buffer . lines . get ( 0 ) ! . loadCell ( 0 , cell ) ;
802- assert . equal ( tchar . getChars ( ) , high + String . fromCharCode ( i ) ) ;
803- assert . equal ( tchar . getChars ( ) . length , 2 ) ;
804- assert . equal ( tchar . getWidth ( ) , 1 ) ;
805- assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
806- term . reset ( ) ;
807- }
808- } ) ;
761+ } ) ;
762+ it ( `${ range } : 2 characters per cell over line end with autowrap` , async function ( ) : Promise < void > {
763+ const high = String . fromCharCode ( 0xD800 ) ;
764+ const cell = new CellData ( ) ;
765+ for ( let j = i ; j <= i + 0xF ; j ++ ) {
766+ term . buffer . x = term . cols - 1 ;
767+ await term . writeP ( 'a' + high + String . fromCharCode ( j ) ) ;
768+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) , 'a' ) ;
769+ assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) , high + String . fromCharCode ( j ) ) ;
770+ assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 0 , cell ) . getChars ( ) . length , 2 ) ;
771+ assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
772+ term . reset ( ) ;
773+ }
774+ } ) ;
775+ it ( `${ range } : 2 characters per cell over line end without autowrap` , async function ( ) : Promise < void > {
776+ const high = String . fromCharCode ( 0xD800 ) ;
777+ const cell = new CellData ( ) ;
778+ for ( let j = i ; j <= i + 0xF ; j ++ ) {
779+ term . buffer . x = term . cols - 1 ;
780+ await term . writeP ( '\x1b[?7l' ) ; // Disable wraparound mode
781+ const width = wcwidth ( ( 0xD800 - 0xD800 ) * 0x400 + j - 0xDC00 + 0x10000 ) ;
782+ if ( width !== 1 ) {
783+ continue ;
784+ }
785+ await term . writeP ( 'a' + high + String . fromCharCode ( j ) ) ;
786+ // auto wraparound mode should cut off the rest of the line
787+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) , high + String . fromCharCode ( j ) ) ;
788+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( term . cols - 1 , cell ) . getChars ( ) . length , 2 ) ;
789+ assert . equal ( term . buffer . lines . get ( 1 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
790+ term . reset ( ) ;
791+ }
792+ } ) ;
793+ it ( `${ range } : splitted surrogates` , async function ( ) : Promise < void > {
794+ const high = String . fromCharCode ( 0xD800 ) ;
795+ const cell = new CellData ( ) ;
796+ for ( let j = i ; j <= i + 0xF ; j ++ ) {
797+ await term . writeP ( high + String . fromCharCode ( j ) ) ;
798+ const tchar = term . buffer . lines . get ( 0 ) ! . loadCell ( 0 , cell ) ;
799+ assert . equal ( tchar . getChars ( ) , high + String . fromCharCode ( j ) ) ;
800+ assert . equal ( tchar . getChars ( ) . length , 2 ) ;
801+ assert . equal ( tchar . getWidth ( ) , 1 ) ;
802+ assert . equal ( term . buffer . lines . get ( 0 ) ! . loadCell ( 1 , cell ) . getChars ( ) , '' ) ;
803+ term . reset ( ) ;
804+ }
805+ } ) ;
806+ }
809807 } ) ;
810808
811809 describe ( 'unicode - combining characters' , ( ) => {
0 commit comments