From 4bb3bee6c83a229f9d199b06222ef9514e7ab257 Mon Sep 17 00:00:00 2001 From: TomZz Date: Sun, 14 Jun 2026 23:16:15 +0800 Subject: [PATCH] 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. --- src/terminal/element.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal/element.rs b/src/terminal/element.rs index ecec7e7..e836afd 100644 --- a/src/terminal/element.rs +++ b/src/terminal/element.rs @@ -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) {