Skip to content

Fix(terminal-emulator): Trim synthetic wide-char trailing blank on copy (#1397)#5046

Open
Sayeem3051 wants to merge 4 commits intotermux:masterfrom
Sayeem3051:fix/wide-char-copy-trailing-space
Open

Fix(terminal-emulator): Trim synthetic wide-char trailing blank on copy (#1397)#5046
Sayeem3051 wants to merge 4 commits intotermux:masterfrom
Sayeem3051:fix/wide-char-copy-trailing-space

Conversation

@Sayeem3051
Copy link
Copy Markdown

…copy (#1397)

Fixes #1397

When a double-width (CJK) character wraps at the end of a line, the terminal inserts a placeholder space in the last column. This commit adds logic to trim that synthetic trailing blank during copy operations when the preceding copied character is double-width, while preserving legitimate trailing spaces on wrapped lines.

Changes only TerminalBuffer.getSelectedText() - no changes to rendering, storage, or wrapping logic.

…copy (termux#1397)

Fixes termux#1397

When a double-width (CJK) character wraps at the end of a line, the terminal
inserts a placeholder space in the last column. This commit adds logic to
trim that synthetic trailing blank during copy operations when the preceding
copied character is double-width, while preserving legitimate trailing spaces
on wrapped lines.

Changes only TerminalBuffer.getSelectedText() - no changes to rendering,
storage, or wrapping logic.
Revert the previous wrapped-line copy heuristic.

The earlier change trimmed a trailing space when the preceding copied
character had width 2, but that condition is too broad and can remove
legitimate trailing spaces on wrapped lines.

This restores the original wrapped-line behavior in getSelectedText()
until a narrower fix can identify the synthetic wrap placeholder safely.
Remove the remaining wrapped-line trimming heuristic from getSelectedText().

The previous logic still attempted to infer a synthetic trailing blank
from copied text state, which can trim legitimate trailing spaces on
wrapped lines. This restores the original wrapped-line behavior fully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line breaks and copy issues

2 participants