mirror of
https://github.com/antirez/linenoise.git
synced 2026-02-03 20:31:39 +00:00
Fix VT100 emulator orphaned continuation cell bug
When a regular character (width=1) overwrote a wide character (width=2), the continuation cell at the next position kept its width=0 state. During rendering, this orphaned cell was skipped, causing one visual column to be lost and misaligning the terminal border. Fix: Before placing any character, check if: 1. Current cell is a continuation (width=0) - convert to space 2. Current cell was a wide char (width=2) - clear its continuation This ensures proper column accounting when wide characters are replaced. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -295,6 +295,18 @@ static void emu_put_char(const char *ch, int chlen) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Before overwriting, handle orphaned continuation cells:
|
||||
* 1. If current cell is a continuation (width=0), clear it first
|
||||
* 2. If current cell was a wide char (width=2), clear its continuation */
|
||||
emu_cell_t *cur = &emu_screen[emu_cursor_row][emu_cursor_col];
|
||||
if (cur->width == 0) {
|
||||
/* This was a continuation cell - convert to space. */
|
||||
emu_clear_cell(emu_cursor_row, emu_cursor_col);
|
||||
} else if (cur->width == 2 && emu_cursor_col + 1 < emu_cols) {
|
||||
/* This was a wide char - clear its orphaned continuation. */
|
||||
emu_clear_cell(emu_cursor_row, emu_cursor_col + 1);
|
||||
}
|
||||
|
||||
/* Store the character in the current cell. */
|
||||
memcpy(emu_screen[emu_cursor_row][emu_cursor_col].ch, ch, chlen);
|
||||
emu_screen[emu_cursor_row][emu_cursor_col].ch[chlen] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user