diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-22 14:30:16 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-22 14:30:16 +0300 |
| commit | 4846cb1324a6a9e46bc89250cf8a289b91866a9c (patch) | |
| tree | a083847aa50941799a31493266770ce58f3f4b19 /src/pane/terminal.rs | |
| parent | b76fb4950c30e9bb7836bcd54792066d077a1911 (diff) | |
fix: skip wide spacer cells in pane reads
refs #698
Diffstat (limited to 'src/pane/terminal.rs')
| -rw-r--r-- | src/pane/terminal.rs | 21 |
1 files changed, 20 insertions, 1 deletions
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<String, crate::ghostty::Error> { 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<String, crate::ghostty::Error> { + 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()); @@ -2954,6 +2960,19 @@ mod tests { } #[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); let mut terminal = crate::ghostty::Terminal::new(20, 3, 100).unwrap(); |
