77
88import { Terminal , ITerminalAddon , IBuffer , IBufferCell , IBufferRange } from 'xterm' ;
99import { IColorSet } from 'browser/Types' ;
10- import { IAttributeData , IColor } from 'common/Types' ;
11- import { DEFAULT_ANSI_COLORS } from 'browser/services/ThemeService' ;
10+ import { IAttributeData } from 'common/Types' ;
1211
1312function constrain ( value : number , low : number , high : number ) : number {
1413 return Math . max ( low , Math . min ( value , high ) ) ;
@@ -535,7 +534,7 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
535534
536535 private _htmlContent = '' ;
537536
538- private _ansiColors : Readonly < IColor [ ] > ;
537+ private _colors : IColorSet ;
539538
540539 constructor (
541540 buffer : IBuffer ,
@@ -544,13 +543,8 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
544543 ) {
545544 super ( buffer ) ;
546545
547- // For xterm headless: fallback to ansi colors
548- if ( ( _terminal as any ) . _core . _themeService ) {
549- this . _ansiColors = ( _terminal as any ) . _core . _themeService . colors . ansi ;
550- }
551- else {
552- this . _ansiColors = DEFAULT_ANSI_COLORS ;
553- }
546+ // https://github.com/xtermjs/xterm.js/issues/3601
547+ this . _colors = ( _terminal as any ) . _core . _themeService . colors ;
554548 }
555549
556550 private _padStart ( target : string , targetLength : number , padString : string ) : string {
@@ -606,7 +600,7 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
606600 return rgb . map ( x => this . _padStart ( x . toString ( 16 ) , 2 , '0' ) ) . join ( '' ) ;
607601 }
608602 if ( isFg ? cell . isFgPalette ( ) : cell . isBgPalette ( ) ) {
609- return this . _ansiColors [ color ] . css ;
603+ return this . _colors . ansi [ color ] . css ;
610604 }
611605 return undefined ;
612606 }
0 commit comments