@@ -16,14 +16,18 @@ import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanc
16
16
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering' ;
17
17
import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment' ;
18
18
import { Terminal as XtermTerminal } from 'xterm-headless' ;
19
- import { SerializeAddon } from 'xterm-addon-serialize' ;
19
+ import type { SerializeAddon as XtermSerializeAddon } from 'xterm-addon-serialize' ;
20
+ import type { Unicode11Addon as XtermUnicode11Addon } from 'xterm-addon-unicode11' ;
20
21
import { IGetTerminalLayoutInfoArgs , IProcessDetails , IPtyHostProcessReplayEvent , ISetTerminalLayoutInfoArgs , ITerminalTabLayoutInfoDto } from 'vs/platform/terminal/common/terminalProcess' ;
21
22
import { ITerminalSerializer , TerminalRecorder } from 'vs/platform/terminal/common/terminalRecorder' ;
22
23
import { getWindowsBuildNumber } from 'vs/platform/terminal/node/terminalEnvironment' ;
23
24
import { TerminalProcess } from 'vs/platform/terminal/node/terminalProcess' ;
24
25
25
26
type WorkspaceId = string ;
26
27
28
+ let SerializeAddon : typeof XtermSerializeAddon ;
29
+ let Unicode11Addon : typeof XtermUnicode11Addon ;
30
+
27
31
export class PtyService extends Disposable implements IPtyService {
28
32
declare readonly _serviceBrand : undefined ;
29
33
@@ -102,6 +106,7 @@ export class PtyService extends Disposable implements IPtyService {
102
106
cwd : string ,
103
107
cols : number ,
104
108
rows : number ,
109
+ unicodeVersion : '6' | '11' ,
105
110
env : IProcessEnvironment ,
106
111
executableEnv : IProcessEnvironment ,
107
112
windowsEnableConpty : boolean ,
@@ -125,7 +130,7 @@ export class PtyService extends Disposable implements IPtyService {
125
130
if ( process . onDidChangeHasChildProcesses ) {
126
131
process . onDidChangeHasChildProcesses ( event => this . _onProcessDidChangeHasChildProcesses . fire ( { id, event } ) ) ;
127
132
}
128
- const persistentProcess = new PersistentTerminalProcess ( id , process , workspaceId , workspaceName , shouldPersist , cols , rows , this . _reconnectConstants , this . _logService , shellLaunchConfig . icon ) ;
133
+ const persistentProcess = new PersistentTerminalProcess ( id , process , workspaceId , workspaceName , shouldPersist , cols , rows , unicodeVersion , this . _reconnectConstants , this . _logService , shellLaunchConfig . icon ) ;
129
134
process . onProcessExit ( ( ) => {
130
135
persistentProcess . dispose ( ) ;
131
136
this . _ptys . delete ( id ) ;
@@ -204,6 +209,9 @@ export class PtyService extends Disposable implements IPtyService {
204
209
async acknowledgeDataEvent ( id : number , charCount : number ) : Promise < void > {
205
210
return this . _throwIfNoPty ( id ) . acknowledgeDataEvent ( charCount ) ;
206
211
}
212
+ async setUnicodeVersion ( id : number , version : '6' | '11' ) : Promise < void > {
213
+ return this . _throwIfNoPty ( id ) . setUnicodeVersion ( version ) ;
214
+ }
207
215
async getLatency ( id : number ) : Promise < number > {
208
216
return 0 ;
209
217
}
@@ -364,6 +372,7 @@ export class PersistentTerminalProcess extends Disposable {
364
372
readonly shouldPersistTerminal : boolean ,
365
373
cols : number ,
366
374
rows : number ,
375
+ unicodeVersion : '6' | '11' ,
367
376
reconnectConstants : IReconnectConstants ,
368
377
private readonly _logService : ILogService ,
369
378
private _icon ?: TerminalIcon ,
@@ -376,7 +385,8 @@ export class PersistentTerminalProcess extends Disposable {
376
385
this . _serializer = new XtermSerializer (
377
386
cols ,
378
387
rows ,
379
- reconnectConstants . scrollback
388
+ reconnectConstants . scrollback ,
389
+ unicodeVersion
380
390
) ;
381
391
} else {
382
392
this . _serializer = new TerminalRecorder ( cols , rows ) ;
@@ -463,6 +473,10 @@ export class PersistentTerminalProcess extends Disposable {
463
473
this . _bufferer . flushBuffer ( this . _persistentProcessId ) ;
464
474
return this . _terminalProcess . resize ( cols , rows ) ;
465
475
}
476
+ setUnicodeVersion ( version : '6' | '11' ) : void {
477
+ this . _serializer . setUnicodeVersion ?.( version ) ;
478
+ // TODO: Pass in unicode version in ctor
479
+ }
466
480
acknowledgeDataEvent ( charCount : number ) : void {
467
481
if ( this . _inReplay ) {
468
482
return ;
@@ -479,8 +493,8 @@ export class PersistentTerminalProcess extends Disposable {
479
493
return this . _terminalProcess . getLatency ( ) ;
480
494
}
481
495
482
- triggerReplay ( ) : void {
483
- const ev = this . _serializer . generateReplayEvent ( ) ;
496
+ async triggerReplay ( ) : Promise < void > {
497
+ const ev = await this . _serializer . generateReplayEvent ( ) ;
484
498
let dataLength = 0 ;
485
499
for ( const e of ev . events ) {
486
500
dataLength += e . data . length ;
@@ -543,8 +557,16 @@ export class PersistentTerminalProcess extends Disposable {
543
557
544
558
class XtermSerializer implements ITerminalSerializer {
545
559
private _xterm : XtermTerminal ;
546
- constructor ( cols : number , rows : number , scrollback : number ) {
560
+ private _unicodeAddon ?: XtermUnicode11Addon ;
561
+
562
+ constructor (
563
+ cols : number ,
564
+ rows : number ,
565
+ scrollback : number ,
566
+ unicodeVersion : '6' | '11'
567
+ ) {
547
568
this . _xterm = new XtermTerminal ( { cols, rows, scrollback } ) ;
569
+ this . setUnicodeVersion ( unicodeVersion ) ;
548
570
}
549
571
550
572
handleData ( data : string ) : void {
@@ -555,8 +577,8 @@ class XtermSerializer implements ITerminalSerializer {
555
577
this . _xterm . resize ( cols , rows ) ;
556
578
}
557
579
558
- generateReplayEvent ( ) : IPtyHostProcessReplayEvent {
559
- const serialize = new SerializeAddon ( ) ;
580
+ async generateReplayEvent ( ) : Promise < IPtyHostProcessReplayEvent > {
581
+ const serialize = new ( await this . _getSerializeConstructor ( ) ) ;
560
582
this . _xterm . loadAddon ( serialize ) ;
561
583
const serialized = serialize . serialize ( this . _xterm . getOption ( 'scrollback' ) ) ;
562
584
return {
@@ -569,6 +591,34 @@ class XtermSerializer implements ITerminalSerializer {
569
591
]
570
592
} ;
571
593
}
594
+
595
+ async setUnicodeVersion ( version : '6' | '11' ) : Promise < void > {
596
+ if ( this . _xterm . unicode . activeVersion === version ) {
597
+ return ;
598
+ }
599
+ if ( version === '11' ) {
600
+ this . _unicodeAddon = new ( await this . _getUnicode11Constructor ( ) ) ;
601
+ this . _xterm . loadAddon ( this . _unicodeAddon ) ;
602
+ } else {
603
+ this . _unicodeAddon ?. dispose ( ) ;
604
+ this . _unicodeAddon = undefined ;
605
+ }
606
+ this . _xterm . unicode . activeVersion = version ;
607
+ }
608
+
609
+ async _getUnicode11Constructor ( ) : Promise < typeof Unicode11Addon > {
610
+ if ( ! Unicode11Addon ) {
611
+ Unicode11Addon = ( await import ( 'xterm-addon-unicode11' ) ) . Unicode11Addon ;
612
+ }
613
+ return Unicode11Addon ;
614
+ }
615
+
616
+ async _getSerializeConstructor ( ) : Promise < typeof SerializeAddon > {
617
+ if ( ! SerializeAddon ) {
618
+ SerializeAddon = ( await import ( 'xterm-addon-serialize' ) ) . SerializeAddon ;
619
+ }
620
+ return SerializeAddon ;
621
+ }
572
622
}
573
623
574
624
function printTime ( ms : number ) : string {
0 commit comments