Repository navigation
fix(buffer): keep the wide-cell bookkeeping when a cell is inserted - #236
Open
shounakjoshi88-a11y wants to merge 1 commit into
Open
shounakjoshi88-a11y wants to merge 1 commit into
shounakjoshi88-a11y wants to merge 1 commit into
Conversation
InsertCell moved the cells to the right with a plain copy, so a wide cell was split when the insert landed between its head and its placeholders: the cell kept a tail that was no longer next to it, and the placeholder that moved right belonged to nothing. The cells the insert replaces also kept the content that had just moved right until they were written, and the write treated a wide cell among them as covering the cell that had moved next to it - which cleared the wide character that had just moved there. An insert that lands inside a wide cell now replaces that wide cell with blank cells, the same way writing over one does, and the cells the insert replaces are emptied before they are written. Fixes charmbracelet#235 Signed-off-by: Shounak Joshi <shounakjoshi88@gmail.com>
Author
|
The workflows on this pull request (
The new test fails on the unfixed tree, with the two symptoms from the issue: and passes with the fix. The issue is #235, with the root cause and the two-part fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Buffer.InsertCellleft the buffer in a state where a placeholder belongs to no wide cell, and the rest of the row is shifted one column to the left.The insert moves the cells to the right with a plain copy:
A wide cell is a head plus zero-width placeholders that mark the columns it covers. The copy moves the head and its placeholders apart as soon as the insert lands between them, and the cells that the insert replaces keep their old content until they are written - a wide cell among them then clears the cell that has just moved next to it.
Two cases, both from the same insert:
Root cause
In
InsertCellArea(buffer.go), the shift moves cells without the wide-cell bookkeeping, and the write that follows (SetCell) reads the cells the shift left behind.SetCelltreats the stale cell at the insert position as a wide cell that covers the cell next to it, and clears that one:So the fix is in two parts:
Reproduction
The cell that was at column 4 is now at column 3, and the row is one column short: the terminal keeps whatever was in the last column of the row.
The same insert before a wide cell loses the wide character:
Impact
The buffer's own invariant - a placeholder belongs to the wide cell before it - is broken, and the row is rendered one column short, so the columns after the insert are shifted and the last column of the row keeps stale content on screen.
Buffer.InsertCellis the [ansi.ICH] path, so this is reachable from anything that inserts a cell into a row that holds a wide character.Environment
main@a45b7c8