From 7b0beed280f09bbd69e010745fd003bd599d3e8c Mon Sep 17 00:00:00 2001 From: altair823 Date: Sun, 3 May 2026 09:23:29 +0000 Subject: [PATCH] review(p9-fb-10-task1): drop unused char_len + harden pop invariant test + doc new() Co-Authored-By: Claude Sonnet 4.6 --- crates/kebab-tui/src/input.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/kebab-tui/src/input.rs b/crates/kebab-tui/src/input.rs index 97bc281..74c95f4 100644 --- a/crates/kebab-tui/src/input.rs +++ b/crates/kebab-tui/src/input.rs @@ -91,6 +91,7 @@ pub struct InputBuffer { } impl InputBuffer { + /// Create an empty buffer. pub fn new() -> Self { Self::default() } @@ -142,12 +143,6 @@ impl InputBuffer { pub fn is_empty(&self) -> bool { self.content.is_empty() } - - /// Length of `content` in chars (NOT display columns). Use - /// `cursor_col()` for column-aware layout. - pub fn char_len(&self) -> usize { - self.content.chars().count() - } } #[cfg(test)] @@ -268,6 +263,8 @@ mod tests { assert_eq!(popped, Some('트')); assert_eq!(b.cursor_col(), 4); assert_eq!(b.as_str(), "러스"); + // Invariant must still hold after pop, not just after push. + assert_eq!(b.cursor_col(), display_width(b.as_str())); b.push_char('a'); assert_eq!(b.cursor_col(), 5); assert_eq!(b.as_str(), "러스a");