gh-156207: Fix curses Textbox.gather() for double-width characters - #156208
Open
fedonman wants to merge 1 commit into
Open
gh-156207: Fix curses Textbox.gather() for double-width characters#156208fedonman wants to merge 1 commit into
fedonman wants to merge 1 commit into
Conversation
gather() read the window one cell at a time, so the second cell of a double-width character was reported as another copy of it. Read each line with in_wchstr() instead: its count is a cell count, and it skips the continuation cell.
serhiy-storchaka
left a comment
Member
There was a problem hiding this comment.
This all is right, but using the new API allows us to go further. We no longer need move() + _end_of_line(y) to get the count here. We can simply read to the end of line and then strip redundant spaces (except one). Probably we can even use in_wstr().
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.
gather()now reads each line within_wchstr(), whose count is a cell count and which skips a double-width character's continuation cell, instead of reading one cell at a time and reporting that second cell as another copy of the character.This fixes only the
gather()symptom of gh-156207. The insert-mode corruption and thecurses.errorat the last column are untouched: both need_insert_printable_char()to know a character's display width, which is a larger change.The duplication only exists on the main branch, where
gather()started reading cells within_wch(), so there is no NEWS entry.