From 3cbe4ec7936745543e16d1ceb37f6db6c38d65ac Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Thu, 4 Jun 2026 00:56:07 +0300 Subject: fix: avoid ghostty utf8 grapheme buffer crash refs #453 --- src/pane/terminal.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/pane') diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index 0a67f11a..88924d36 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -1058,7 +1058,7 @@ impl GhosttyPaneTerminal { Ok(rows) => rows, Err(_) => return, }; - let mut grapheme_bytes = Vec::new(); + let mut grapheme_codepoints = Vec::new(); let mut symbol_scratch = String::new(); let mut y = 0u16; while y < area.height && rows.next() { @@ -1081,7 +1081,7 @@ impl GhosttyPaneTerminal { &cells, basic.wide, hide_kitty_placeholders, - &mut grapheme_bytes, + &mut grapheme_codepoints, &mut symbol_scratch, ) { Ok(symbol) => symbol, @@ -1226,7 +1226,7 @@ fn ghostty_collect_dirty_patch( let Ok(mut rows) = render_state.populate_row_iterator(&mut row_iterator) else { fallback!("populate_rows_error"); }; - let mut grapheme_bytes = Vec::new(); + let mut grapheme_codepoints = Vec::new(); let mut symbol_scratch = String::new(); let mut patch_rows = Vec::new(); let mut y = 0u16; @@ -1264,7 +1264,7 @@ fn ghostty_collect_dirty_patch( &cells, basic.wide, hide_kitty_placeholders, - &mut grapheme_bytes, + &mut grapheme_codepoints, &mut symbol_scratch, ) { Ok(symbol) => symbol.to_owned(), @@ -1539,7 +1539,7 @@ fn ghostty_buffer_symbol_into<'a>( cells: &crate::ghostty::RowCellIter<'_>, wide: crate::ghostty::CellWide, hide_kitty_placeholders: bool, - grapheme_bytes: &mut Vec, + grapheme_codepoints: &mut Vec, symbol_scratch: &'a mut String, ) -> Result<&'a str, crate::ghostty::Error> { symbol_scratch.clear(); @@ -1547,7 +1547,7 @@ fn ghostty_buffer_symbol_into<'a>( crate::ghostty::CellWide::SpacerTail => {} crate::ghostty::CellWide::SpacerHead => symbol_scratch.push(' '), crate::ghostty::CellWide::Narrow | crate::ghostty::CellWide::Wide => { - cells.grapheme_text_into(grapheme_bytes, symbol_scratch)?; + cells.grapheme_text_into(grapheme_codepoints, symbol_scratch)?; let hidden_kitty_placeholder = hide_kitty_placeholders && symbol_scratch.chars().next().map(u32::from) == Some(crate::ghostty::KITTY_UNICODE_PLACEHOLDER); -- cgit v1.2.3