@@ -125,10 +125,6 @@ export class Ansi {
125125 resolvedInnerOptions . overline !== resolvedOuterOptions . overline ;
126126 const reverseChanged =
127127 resolvedInnerOptions . reverse !== resolvedOuterOptions . reverse ;
128- const underlineColorChanged = ! Ansi . isSameColor (
129- resolvedInnerOptions . underlineColor ,
130- resolvedOuterOptions . underlineColor
131- ) ;
132128 const foregroundColorChanged = ! Ansi . isSameColor (
133129 resolvedInnerOptions . foregroundColor ,
134130 resolvedOuterOptions . foregroundColor
@@ -137,14 +133,19 @@ export class Ansi {
137133 resolvedInnerOptions . backgroundColor ,
138134 resolvedOuterOptions . backgroundColor
139135 ) ;
136+ const underlineColorChanged = ! Ansi . isSameColor (
137+ resolvedInnerOptions . underlineColor ,
138+ resolvedOuterOptions . underlineColor
139+ ) ;
140140 const changed =
141141 weightChanged ||
142142 italicChanged ||
143143 underlineChanged ||
144144 blinkChanged ||
145145 strikeChanged ||
146146 foregroundColorChanged ||
147- backgroundColorChanged ;
147+ backgroundColorChanged ||
148+ underlineColorChanged ;
148149 if ( ! changed ) {
149150 return [ "" , "" ] ;
150151 }
@@ -168,21 +169,33 @@ export class Ansi {
168169 strikeChanged && ( resolvedInnerOptions . strike ? 9 : 29 ) ,
169170 overlineChanged && ( resolvedInnerOptions . overline ? 53 : 55 ) ,
170171 reverseChanged && ( resolvedInnerOptions . reverse ? 7 : 27 ) ,
171- ...( underlineColorChanged
172- ? resolvedInnerOptions . underlineColor === null
173- ? [ 59 ]
174- : [ 58 , ...resolvedInnerOptions . underlineColor ]
175- : [ ] ) ,
176172 ...( foregroundColorChanged
177173 ? resolvedInnerOptions . foregroundColor === null
178174 ? [ 39 ]
175+ : resolvedInnerOptions . foregroundColor [ 0 ] === 5 &&
176+ resolvedInnerOptions . foregroundColor [ 1 ] < 8
177+ ? [ 30 + resolvedInnerOptions . foregroundColor [ 1 ] ]
178+ : resolvedInnerOptions . foregroundColor [ 0 ] === 5 &&
179+ resolvedInnerOptions . foregroundColor [ 1 ] < 16
180+ ? [ 82 + resolvedInnerOptions . foregroundColor [ 1 ] ]
179181 : [ 38 , ...resolvedInnerOptions . foregroundColor ]
180182 : [ ] ) ,
181183 ...( backgroundColorChanged
182184 ? resolvedInnerOptions . backgroundColor === null
183185 ? [ 49 ]
186+ : resolvedInnerOptions . backgroundColor [ 0 ] === 5 &&
187+ resolvedInnerOptions . backgroundColor [ 1 ] < 8
188+ ? [ 40 + resolvedInnerOptions . backgroundColor [ 1 ] ]
189+ : resolvedInnerOptions . backgroundColor [ 0 ] === 5 &&
190+ resolvedInnerOptions . backgroundColor [ 1 ] < 16
191+ ? [ 92 + resolvedInnerOptions . backgroundColor [ 1 ] ]
184192 : [ 48 , ...resolvedInnerOptions . backgroundColor ]
185193 : [ ] ) ,
194+ ...( underlineColorChanged
195+ ? resolvedInnerOptions . underlineColor === null
196+ ? [ 59 ]
197+ : [ 58 , ...resolvedInnerOptions . underlineColor ]
198+ : [ ] ) ,
186199 ]
187200 . filter ( ( a ) => a )
188201 . join ( ";" ) } m`,
@@ -202,16 +215,35 @@ export class Ansi {
202215 : 24 ) ,
203216 blinkChanged && ( resolvedOuterOptions . blink ? 5 : 25 ) ,
204217 strikeChanged && ( resolvedOuterOptions . strike ? 9 : 29 ) ,
218+ overlineChanged && ( resolvedOuterOptions . overline ? 53 : 55 ) ,
219+ reverseChanged && ( resolvedOuterOptions . reverse ? 7 : 27 ) ,
205220 ...( foregroundColorChanged
206221 ? resolvedOuterOptions . foregroundColor === null
207222 ? [ 39 ]
223+ : resolvedOuterOptions . foregroundColor [ 0 ] === 5 &&
224+ resolvedOuterOptions . foregroundColor [ 1 ] < 8
225+ ? [ 30 + resolvedOuterOptions . foregroundColor [ 1 ] ]
226+ : resolvedOuterOptions . foregroundColor [ 0 ] === 5 &&
227+ resolvedOuterOptions . foregroundColor [ 1 ] < 16
228+ ? [ 82 + resolvedOuterOptions . foregroundColor [ 1 ] ]
208229 : [ 38 , ...resolvedOuterOptions . foregroundColor ]
209230 : [ ] ) ,
210231 ...( backgroundColorChanged
211232 ? resolvedOuterOptions . backgroundColor === null
212233 ? [ 49 ]
234+ : resolvedOuterOptions . backgroundColor [ 0 ] === 5 &&
235+ resolvedOuterOptions . backgroundColor [ 1 ] < 8
236+ ? [ 40 + resolvedOuterOptions . backgroundColor [ 1 ] ]
237+ : resolvedOuterOptions . backgroundColor [ 0 ] === 5 &&
238+ resolvedOuterOptions . backgroundColor [ 1 ] < 16
239+ ? [ 92 + resolvedOuterOptions . backgroundColor [ 1 ] ]
213240 : [ 48 , ...resolvedOuterOptions . backgroundColor ]
214241 : [ ] ) ,
242+ ...( underlineColorChanged
243+ ? resolvedOuterOptions . underlineColor === null
244+ ? [ 59 ]
245+ : [ 58 , ...resolvedOuterOptions . underlineColor ]
246+ : [ ] ) ,
215247 ]
216248 . filter ( ( a ) => a )
217249 . join ( ";" ) } m`,
0 commit comments