Fix DECCOLM mid-chunk data loss and CSI leading zeros truncation

replaceEngine now updates the old parser's screen reference so remaining
bytes in a chunk after DECCOLM are written to the new buffer instead of
the discarded one. Also bumps MAX_PARAM_LEN 10→16 so vttest's 11-digit
leading-zero parameters parse correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jima 2026-03-31 01:06:41 +02:00
parent b2d8354ebf
commit e72c4de55d
2 changed files with 5 additions and 2 deletions

View file

@ -303,6 +303,9 @@ class TerminalService : Service() {
val entry = sessions[sessionId] ?: return
synchronized(entry.parserLock) {
newBuffer.listener = entry.screenBuffer.listener
// Point the currently-executing parser at the new buffer so remaining bytes
// in the current process() call write to the correct (resized) buffer.
entry.parser.screen = newBuffer
entry.screenBuffer = newBuffer
entry.parser = newParser
}

View file

@ -22,7 +22,7 @@ package com.roundingmobile.terminalview.engine
// Ported from: ANSICtrl::_ParseBufferANSI + _ControlCharsC0
// =================================================================================
open class BaseTermParser(val screen: ScreenBuffer) {
open class BaseTermParser(var screen: ScreenBuffer) {
// Parser state machine
protected enum class State {
@ -59,7 +59,7 @@ open class BaseTermParser(val screen: ScreenBuffer) {
companion object {
const val MAX_PARAMS = 20
const val MAX_PARAM_LEN = 10
const val MAX_PARAM_LEN = 16
// CSI flags (from ANSICtrl.cpp #defines)
const val FLAG_DOLLAR = 0x0001