@@ -316,7 +316,7 @@ export default class ANSIParser {
316
316
let status = "handled" ;
317
317
318
318
let params : number [ ] = Array . isArray ( rawParams ) ? rawParams : [ ] ;
319
- const param : number | undefined = params [ 0 ] ;
319
+ const param : number = params [ 0 ] || 0 ;
320
320
321
321
switch ( flag ) {
322
322
case "A" :
@@ -361,7 +361,6 @@ export default class ANSIParser {
361
361
this . buffer . clear ( ) ;
362
362
break ;
363
363
case CSI . erase . toEnd :
364
- case undefined :
365
364
short = "Erase Display Below (ED)." ;
366
365
367
366
this . buffer . clearToEnd ( ) ;
@@ -384,7 +383,6 @@ export default class ANSIParser {
384
383
this . buffer . clearRow ( ) ;
385
384
break ;
386
385
case CSI . erase . toEnd :
387
- case undefined :
388
386
short = "Erase Line to Right (DECSEL)." ;
389
387
this . buffer . clearRowToEnd ( ) ;
390
388
break ;
@@ -438,9 +436,8 @@ export default class ANSIParser {
438
436
break ;
439
437
}
440
438
441
- while ( params . length ) {
442
- const sgr = params . shift ( ) ;
443
-
439
+ while ( params . length !== 0 ) {
440
+ const sgr = params . shift ( ) ! ;
444
441
const attributeToSet = SGR [ sgr ] ;
445
442
446
443
if ( ! attributeToSet ) {
@@ -449,7 +446,12 @@ export default class ANSIParser {
449
446
const next = params . shift ( ) ;
450
447
if ( next === 5 ) {
451
448
const color = params . shift ( ) ;
452
- this . buffer . setAttributes ( { [ < string > attributeToSet ] : colorIndex [ color ] } ) ;
449
+
450
+ if ( color ) {
451
+ this . buffer . setAttributes ( { [ < string > attributeToSet ] : colorIndex [ color ] } ) ;
452
+ } else {
453
+ error ( "sgr" , sgr , next , params ) ;
454
+ }
453
455
} else {
454
456
error ( "sgr" , sgr , next , params ) ;
455
457
}
0 commit comments