From 4846cb1324a6a9e46bc89250cf8a289b91866a9c Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 22 Jun 2026 14:30:16 +0300 Subject: fix: skip wide spacer cells in pane reads refs #698 --- src/pane/terminal.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/pane/terminal.rs') diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index a87b9622..ed5d1061 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -1686,7 +1686,10 @@ fn ghostty_screen_row( ) -> Result { let mut line = String::new(); for x in 0..cols { - let graphemes = core.terminal.screen_graphemes(x, y)?; + let (wide, graphemes) = core.terminal.screen_cell(x, y)?; + if wide == crate::ghostty::CellWide::SpacerTail { + continue; + } if graphemes.is_empty() || graphemes.first().copied() == Some(crate::ghostty::KITTY_UNICODE_PLACEHOLDER) { @@ -1715,6 +1718,9 @@ fn ghostty_line_from_cells( fn ghostty_cell_symbol( cells: &crate::ghostty::RowCellIter<'_>, ) -> Result { + if cells.wide()? == crate::ghostty::CellWide::SpacerTail { + return Ok(String::new()); + } let text = cells.grapheme_text()?; if text.chars().next().map(u32::from) == Some(crate::ghostty::KITTY_UNICODE_PLACEHOLDER) { return Ok(" ".to_string()); @@ -2953,6 +2959,19 @@ mod tests { assert_eq!(pane.recent_unwrapped_text(3), "ABCDEFGHIJ"); } + #[test] + fn plain_text_reads_skip_wide_character_spacer_cells() { + let (tx, _rx) = mpsc::channel(4); + let mut terminal = crate::ghostty::Terminal::new(40, 3, 100).unwrap(); + terminal.write("日本語テスト ABC 123".as_bytes()); + let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap(); + + assert_eq!(pane.visible_text(), "日本語テスト ABC 123\n"); + assert_eq!(pane.recent_text(3), "日本語テスト ABC 123\n"); + assert_eq!(pane.recent_unwrapped_text(3), "日本語テスト ABC 123"); + assert_eq!(pane.detection_text(), "日本語テスト ABC 123\n"); + } + #[test] fn visible_ansi_preserves_cell_style_sequences() { let (tx, _rx) = mpsc::channel(4); -- cgit v1.2.3