fix: ensure selection background fully covers wide characters (#24)

Rationale:
Previously, the terminal renderer generated background highlight rectangles (`LayoutRect`) with a hardcoded width of 1 cell (`cells: 1`) for every character. For full-width CJK characters (which carry the `Flags::WIDE_CHAR` flag and visually span 2 columns), this caused the selection and custom background colors to render across only half of the character's visual width.

This fix correctly interprets the terminal cell flags during layout generation: if a cell possesses `Flags::WIDE_CHAR`, it generates a background rectangle spanning 2 cells (`cells: 2`). As a result, the highlight now matches the exact bounds that the text occupies in the terminal grid, cleanly fixing the partial highlighting of Chinese text.
This commit is contained in:
TomZz
2026-06-14 23:19:33 +08:00
parent 8ab4b43825
commit 4bb3bee6c8
+1 -1
View File
@@ -352,7 +352,7 @@ impl TerminalElement {
rects.push(LayoutRect {
row: render_cell.row,
col: render_cell.col,
cells: 1,
cells: if cell.flags.contains(Flags::WIDE_CHAR) { 2 } else { 1 },
color: if selected {
cx.theme().selection
} else if cell.flags.contains(Flags::INVERSE) {