fix resize: accept first diff after reset without base state

This commit is contained in:
realrasengan
2026-03-30 21:24:44 -07:00
parent f70f18fc3f
commit aff8e0572a
+7 -5
View File
@@ -60,11 +60,13 @@ func (st *stateTracker) applyDiff(diff []byte, oldNum, newNum uint64) {
// Need the base state to apply the diff.
base, ok := st.states[oldNum]
if !ok {
return
}
// Restore shadow to base state if needed.
if st.shadowState != oldNum {
// After a resize we have no states. Start fresh with a
// clean emulator so the first post-resize diff works.
st.shadow = vt.NewEmulator(st.cols, st.rows)
st.shadowState = oldNum
base = mosh.SnapshotEmulator(st.shadow, true)
st.states[oldNum] = base
} else if st.shadowState != oldNum {
st.shadow = vt.NewEmulator(st.cols, st.rows)
// Write the base framebuffer as ANSI to restore state.
if base != nil {