refactor(tui): deduplicate cursor_cell_offset into text_width module

Four view modules (search, command_palette, file_history, trace) each had
their own copy of cursor_cell_offset / text_cell_width for converting a
byte-offset cursor position to a display-column offset. Phase 5 introduced
a proper text_width module with these functions; this commit removes the
duplicates and rewires all call sites to use crate::text_width.

- search.rs: removed local text_cell_width + cursor_cell_offset definitions
- command_palette.rs: removed local cursor_cell_offset definition
- file_history.rs: replaced inline chars().count() cursor calc with import
- trace.rs: replaced inline chars().count() cursor calc with import
This commit is contained in:
teernisse
2026-02-18 23:52:08 -05:00
parent 146eb61623
commit 09ffcfcf0f
4 changed files with 6 additions and 27 deletions

View File

@@ -21,8 +21,9 @@ use ftui::render::cell::{Cell, PackedRgba};
use ftui::render::drawing::Draw;
use ftui::render::frame::Frame;
use crate::state::file_history::{FileHistoryResult, FileHistoryState};
use super::common::truncate_str;
use crate::state::file_history::{FileHistoryResult, FileHistoryState};
use crate::text_width::cursor_cell_offset;
// ---------------------------------------------------------------------------
// Colors (Flexoki palette)
@@ -137,8 +138,7 @@ fn render_path_input(frame: &mut Frame<'_>, state: &FileHistoryState, x: u16, y:
// Cursor indicator.
if state.path_focused {
let cursor_col = state.path_input[..state.path_cursor].chars().count() as u16;
let cursor_x = after_label + cursor_col;
let cursor_x = after_label + cursor_cell_offset(&state.path_input, state.path_cursor);
if cursor_x < max_x {
let cursor_cell = Cell {
fg: PackedRgba::rgb(0x10, 0x0F, 0x0F), // dark bg