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/ghostty/mod.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/ghostty') diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index 17f9af32..2b45e3d8 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -742,9 +742,11 @@ impl Terminal { }) } - pub fn screen_graphemes(&self, x: u16, y: u32) -> Result, Error> { + pub fn screen_cell(&self, x: u16, y: u32) -> Result<(CellWide, Vec), Error> { let grid_ref = self.grid_ref(ghostty_screen_point(x, y))?; - grid_ref_graphemes(&grid_ref) + let wide = grid_ref_wide(&grid_ref)?; + let graphemes = grid_ref_graphemes(&grid_ref)?; + Ok((wide, graphemes)) } fn viewport_graphemes_and_style(&self, x: u16, y: u32) -> Result<(Vec, CellStyle), Error> { @@ -1393,6 +1395,24 @@ fn grid_ref_graphemes(grid_ref: &ffi::GhosttyGridRef) -> Result, Error> Ok(buffer) } +fn grid_ref_wide(grid_ref: &ffi::GhosttyGridRef) -> Result { + let mut raw = ffi::GhosttyCell::default(); + unsafe { + ffi::ghostty_grid_ref_cell(grid_ref, &mut raw).into_result()?; + } + + let mut wide = ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_NARROW; + unsafe { + ffi::ghostty_cell_get( + raw, + ffi::GhosttyCellData_GHOSTTY_CELL_DATA_WIDE, + (&mut wide as *mut ffi::GhosttyCellWide).cast(), + ) + .into_result()?; + } + Ok(CellWide::from_raw(wide)) +} + fn kitty_placement_u32( iterator: ffi::GhosttyKittyGraphicsPlacementIterator, data: ffi::GhosttyKittyGraphicsPlacementData, -- cgit v1.2.3