secrets manager
git clone https://git.lucas.co/cce-secrets.git
Filter on the TextBox live edit_buffer, not the committed text
While editing, TextBox keeps keystrokes in edit_buffer and only syncs
.text on commit, so the search filter read stale text and never
narrowed the list. Read the live buffer (and clear both on Escape).
Co-Authored-By: Claude Fable 5 <[email protected]>
src/main.rs | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
index 8b7305f..1e103e3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -224,9 +224,19 @@ struct SecretsApp {
}
impl SecretsApp {
+ /// The search box's live content: `edit_buffer` while editing (`text`
+ /// only syncs on commit — TextBox landmine).
+ fn query_text(&self) -> &str {
+ if self.search_box.editing {
+ &self.search_box.edit_buffer
+ } else {
+ &self.search_box.text
+ }
+ }
+
/// Indices into `entries` matching the search box, in display order.
fn filtered(&self) -> Vec<usize> {
- let query = self.search_box.text.to_lowercase();
+ let query = self.query_text().to_lowercase();
(0..self.entries.len())
.filter(|&i| {
if query.is_empty() {
@@ -611,6 +621,7 @@ impl Application for SecretsApp {
if let Key::Named(NamedKey::Escape) = event.logical_key {
if self.search_box.focused(&self.ui_context) {
self.search_box.text.clear();
+ self.search_box.edit_buffer.clear();
self.search_box.unfocus();
self.scroll_y = 0.0;
*needs_rebuild = true;