diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 03:26:33 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-17 03:26:33 +0300 |
| commit | 8d2af4e046c2a95dfc54aafd6f88da12389d76e8 (patch) | |
| tree | 5643a1ec2f04b150d465817f2896ada4f2fbc46b /src/app | |
| parent | 6f9ac7c108e22510e1b27e3242477fac660fa4cb (diff) | |
perf: adopt libghostty integration improvements
refs #276
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/actions.rs | 9 | ||||
| -rw-r--r-- | src/app/input/copy_mode.rs | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index 68286952..3fedeeb3 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -11,7 +11,6 @@ use crate::layout::{find_in_direction, NavDirection}; use crate::selection::Selection; use crate::terminal::{EffectiveStateChange, TerminalStateMutation}; use crate::workspace::WorkspaceGitStatus; -use unicode_width::UnicodeWidthChar; use super::state::{ text_matches_query, AgentNotificationDelivery, AppState, Mode, NavigatorRow, @@ -2220,7 +2219,7 @@ pub(crate) fn visible_text_cells(text: &str, pane_width: u16) -> Vec<VisibleText pending_wrap = false; } - let width = UnicodeWidthChar::width(ch).unwrap_or(0) as u16; + let width = u16::from(crate::ghostty::unicode_codepoint_width(ch as u32)); cells.push(VisibleTextCell { byte_index, ch, @@ -2252,7 +2251,7 @@ pub(crate) fn logical_cell_for_visible_cell( visible_text_cells(text, pane_width) .into_iter() .find(|cell| { - let width = UnicodeWidthChar::width(cell.ch).unwrap_or(0) as u16; + let width = u16::from(crate::ghostty::unicode_codepoint_width(cell.ch as u32)); cell.screen_row == target_row && if width == 0 { target_col == cell.screen_col @@ -2285,7 +2284,7 @@ fn text_cells(row: &str) -> Vec<TextCell> { let mut next_col = 0u16; row.chars() .map(|ch| { - let width = UnicodeWidthChar::width(ch).unwrap_or(0) as u16; + let width = u16::from(crate::ghostty::unicode_codepoint_width(ch as u32)); let start_col = if width == 0 { next_col.saturating_sub(1) } else { @@ -3190,7 +3189,7 @@ mod tests { let prefix = &row[..byte_idx]; prefix .chars() - .map(|ch| UnicodeWidthChar::width(ch).unwrap_or(0) as u16) + .map(|ch| u16::from(crate::ghostty::unicode_codepoint_width(ch as u32))) .sum() } diff --git a/src/app/input/copy_mode.rs b/src/app/input/copy_mode.rs index f6c322ea..e6c0d074 100644 --- a/src/app/input/copy_mode.rs +++ b/src/app/input/copy_mode.rs @@ -1,5 +1,4 @@ use crossterm::event::{KeyCode, KeyEventKind, KeyModifiers}; -use unicode_width::UnicodeWidthChar; use crate::{ app::{ @@ -941,7 +940,7 @@ fn last_character_col(text: &str) -> Option<u16> { let mut col = 0u16; let mut last_col = None; for ch in text.chars() { - let width = UnicodeWidthChar::width(ch).unwrap_or(1) as u16; + let width = u16::from(crate::ghostty::unicode_codepoint_width(ch as u32)); if width > 0 { last_col = Some(col); col = col.saturating_add(width); @@ -951,7 +950,7 @@ fn last_character_col(text: &str) -> Option<u16> { } fn char_cell_width(ch: char) -> u16 { - UnicodeWidthChar::width(ch).unwrap_or(1).max(1) as u16 + u16::from(crate::ghostty::unicode_codepoint_width(ch as u32)).max(1) } fn copy_mode_page_lines(height: u16, half_page: bool) -> usize { @@ -1703,6 +1702,11 @@ mod tests { submit_copy_search(&mut app, '?', "000000"); assert!(copy_mode_offset_from_bottom(&app, pane_id) > 0); + let copy_mode = app.state.copy_mode.as_ref().expect("copy mode"); + assert_eq!( + copy_mode_viewport_top_row(&app, pane_id) + usize::from(copy_mode.cursor_row), + 0 + ); let runtime = app .state .runtime_for_pane_in_workspace(&app.terminal_runtimes, 0, pane_id) |
