File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,12 @@ export const STYLES = [
7878 ...BACKGROUND_COLOR_LIST ,
7979] as const
8080export type Style = ( typeof STYLES ) [ number ]
81- export const STYLE = {
81+ export const STYLE = Object . fromEntries (
82+ STYLES . map ( ( style ) => [ style , style ] ) ,
83+ ) as {
84+ [ K in Style ] : K
85+ }
86+ const STYLE_CODE = {
8287 RESET : 0 ,
8388 BOLD : 1 ,
8489 DIM : 2 ,
@@ -132,7 +137,7 @@ export function ansiCode(
132137 | { type : 'text' | 'background' ; rgb : RGB } ,
133138) : string {
134139 if ( data . type === 'style' ) {
135- return `\x1b[${ STYLE [ data . style ] } m`
140+ return `\x1b[${ STYLE_CODE [ data . style ] } m`
136141 }
137142
138143 if ( some ( data . rgb , ( v ) => v > 255 || v < 0 ) ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 type Modifier ,
1111 ansiCode ,
1212 moveCursor ,
13+ STYLE ,
1314} from './ansi'
1415
1516export const BLANK_GRAPHEME = ' ' as $GraphemeString
@@ -108,7 +109,7 @@ function graphemeDiffCommands(
108109 }
109110
110111 return [
111- ...ansiCode ( { type : 'style' , style : ' RESET' } ) ,
112+ ...ansiCode ( { type : 'style' , style : STYLE . RESET } ) ,
112113 ...graphemeCommands ( newGrapheme ) ,
113114 ]
114115}
@@ -148,10 +149,8 @@ export function diffImageCommands(
148149 for ( const [ c , newGrapheme ] of newRow . entries ( ) ) {
149150 const prevFrameGrapheme = oldRow [ c ]
150151 if (
151- isEqual (
152- { textStyles : [ ] , ...newGrapheme } ,
153- { textStyles : [ ] , ...prevFrameGrapheme } ,
154- )
152+ newGrapheme . grapheme === prevFrameGrapheme . grapheme &&
153+ equalStyles ( newGrapheme , prevFrameGrapheme )
155154 ) {
156155 skipped = true
157156 continue
You can’t perform that action at this time.
0 commit comments