Skip to content

Commit

Permalink
fix(ansi): just reset the params counter when we enter Utf8State
Browse files Browse the repository at this point in the history
We don't need to clear everything in the Parser on Utf8State, just reset
the counter, we know how many UTF-8 bytes through the first incoming
byte and we use that to decode the rune.
  • Loading branch information
aymanbagabas committed Aug 5, 2024
1 parent fe2aaae commit 3505586
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ansi/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action {
if p.State == parser.EscapeState {
p.performAction(d, parser.ClearAction, state, b)
}
if state == parser.Utf8State {
// Clear the parser state if we're transitioning to the Utf8State.
p.performAction(d, parser.ClearAction, state, b)
}
if action == parser.PutAction &&
p.State == parser.DcsEntryState && state == parser.DcsStringState {
// XXX: This is a special case where we need to start collecting
Expand Down Expand Up @@ -233,6 +229,8 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action

case parser.CollectAction:
if state == parser.Utf8State {
// Reset the UTF-8 counter
p.ParamsLen = 0
p.collectRune(b)
} else {
// Collect intermediate bytes
Expand Down

0 comments on commit 3505586

Please sign in to comment.