File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
addons/xterm-addon-serialize/src Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,35 @@ describe('SerializeAddon', () => {
270270 await writeSync ( page , lines . join ( '\\r\\n' ) ) ;
271271 assert . equal ( await page . evaluate ( `serializeAddon.serialize();` ) , expected . join ( '\r\n' ) ) ;
272272 } ) ;
273+
274+ it ( 'serialize CJK correctly' , async ( ) => {
275+ const lines = [
276+ '中文中文' ,
277+ '12中文' ,
278+ '中文12' ,
279+ '1中文中文中' // this line is going to be wrapped at last character because it has line length of 11 (1+2*5)
280+ ] ;
281+ const expected = [
282+ '中文中文' ,
283+ '12中文' ,
284+ '中文12' ,
285+ '1中文中文' ,
286+ '中'
287+ ] ;
288+ await writeSync ( page , lines . join ( '\\r\\n' ) ) ;
289+ assert . equal ( await page . evaluate ( `serializeAddon.serialize();` ) , expected . join ( '\r\n' ) ) ;
290+ } ) ;
291+
292+ it ( 'serialize CJK Mixed with tab correctly' , async ( ) => {
293+ const lines = [
294+ '中文\t12' // CJK mixed with tab
295+ ] ;
296+ const expected = [
297+ '中文\x1b[4C12'
298+ ] ;
299+ await writeSync ( page , lines . join ( '\\r\\n' ) ) ;
300+ assert . equal ( await page . evaluate ( `serializeAddon.serialize();` ) , expected . join ( '\r\n' ) ) ;
301+ } ) ;
273302} ) ;
274303
275304function newArray < T > ( initial : T | ( ( index : number ) => T ) , count : number ) : T [ ] {
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ class StringSerializeHandler extends BaseSerializeHandler {
138138 // Count number of null cells encountered after the last non-null cell and move the cursor
139139 // if a non-null cell is found (eg. \t or cursor move)
140140 if ( cell . getChars ( ) === '' ) {
141- this . _nullCellCount ++ ;
141+ this . _nullCellCount += cell . getWidth ( ) ;
142142 } else if ( this . _nullCellCount > 0 ) {
143143 this . _currentRow += `\x1b[${ this . _nullCellCount } C` ;
144144 this . _nullCellCount = 0 ;
You can’t perform that action at this time.
0 commit comments