From 194dc82c93bd505e344844ec21dd14a5131d9c62 Mon Sep 17 00:00:00 2001 From: pap Date: Sat, 9 Aug 2025 16:42:34 +0100 Subject: [PATCH] remove unecessary changes --- codex-rs/tui/src/bottom_pane/chat_composer.rs | 16 +++--- codex-rs/tui/src/bottom_pane/command_popup.rs | 1 + .../tui/src/bottom_pane/file_search_popup.rs | 50 +------------------ 3 files changed, 12 insertions(+), 55 deletions(-) diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 4798ae2f86..7b38ffb6e6 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -712,19 +712,21 @@ impl ChatComposer { /// Synchronize `self.file_search_popup` with the current text in the textarea. /// Note this is only called when self.active_popup is NOT Command. fn sync_file_search_popup(&mut self) { - // Determine current query (may be empty if user just selected @file and hasn't typed yet). - let query_opt = Self::current_at_token(&self.textarea); - let Some(query) = query_opt else { - // Token removed – end session. - self.active_popup = ActivePopup::None; - self.dismissed_file_popup_token = None; - return; + // Determine if there is an @token underneath the cursor. + let query = match Self::current_at_token(&self.textarea) { + Some(token) => token, + None => { + self.active_popup = ActivePopup::None; + self.dismissed_file_popup_token = None; + return; + } }; // If user dismissed popup for this exact query, don't reopen until text changes. if self.dismissed_file_popup_token.as_ref() == Some(&query) { return; } + if !query.is_empty() { self.app_event_tx .send(AppEvent::StartFileSearch(query.clone())); diff --git a/codex-rs/tui/src/bottom_pane/command_popup.rs b/codex-rs/tui/src/bottom_pane/command_popup.rs index 8f91bfe6d4..b7a203e9fd 100644 --- a/codex-rs/tui/src/bottom_pane/command_popup.rs +++ b/codex-rs/tui/src/bottom_pane/command_popup.rs @@ -38,6 +38,7 @@ impl CommandPopup { // shows the help for `/clear`. let token = stripped.trim_start(); let cmd_token = token.split_whitespace().next().unwrap_or(""); + // Update the filter keeping the original case (commands are all // lower-case for now but this may change in the future). self.command_filter = cmd_token.to_string(); diff --git a/codex-rs/tui/src/bottom_pane/file_search_popup.rs b/codex-rs/tui/src/bottom_pane/file_search_popup.rs index f7ee2f6eeb..a811a22a8c 100644 --- a/codex-rs/tui/src/bottom_pane/file_search_popup.rs +++ b/codex-rs/tui/src/bottom_pane/file_search_popup.rs @@ -2,7 +2,6 @@ use codex_file_search::FileMatch; use ratatui::buffer::Buffer; use ratatui::layout::Rect; use ratatui::widgets::WidgetRef; -use std::fs; use super::popup_consts::MAX_POPUP_ROWS; use super::scroll_state::ScrollState; @@ -26,16 +25,13 @@ pub(crate) struct FileSearchPopup { impl FileSearchPopup { pub(crate) fn new() -> Self { - // If pending_query is empty, pre-populate matches with files in current dir. - let mut popup = Self { + Self { display_query: String::new(), pending_query: String::new(), waiting: true, matches: Vec::new(), state: ScrollState::new(), - }; - popup.populate_current_dir_if_empty_query(); - popup + } } /// Update the query and reset state to *waiting*. @@ -56,12 +52,6 @@ impl FileSearchPopup { self.matches.clear(); self.state.reset(); } - - // If query is empty, show files in current directory. - if query.is_empty() { - self.populate_current_dir_if_empty_query(); - self.waiting = false; - } } /// Put the popup into an "idle" state used for an empty query (just "@"). @@ -120,42 +110,6 @@ impl FileSearchPopup { self.matches.len().clamp(1, MAX_POPUP_ROWS) as u16 } - - /// Populate matches with files in the current directory if the query is empty. - fn populate_current_dir_if_empty_query(&mut self) { - if !self.pending_query.is_empty() { - return; - } - // Only populate if matches is empty (avoid overwriting search results). - if !self.matches.is_empty() { - return; - } - let mut entries: Vec = Vec::new(); - if let Ok(read_dir) = fs::read_dir(".") { - for entry in read_dir.flatten().take(MAX_POPUP_ROWS) { - if let Ok(file_type) = entry.file_type() { - // Skip hidden files (dotfiles) for a cleaner popup. - let file_name = entry.file_name(); - let file_name_str = file_name.to_string_lossy(); - if file_name_str.starts_with('.') { - continue; - } - // Only show files and directories (not symlinks, etc). - if file_type.is_file() || file_type.is_dir() { - entries.push(FileMatch { - path: file_name_str.to_string(), - indices: Some(Vec::new()), // No highlights for empty query. - score: 0, - }); - } - } - } - } - self.matches = entries; - self.state.clamp_selection(self.matches.len()); - self.state - .ensure_visible(self.matches.len(), self.matches.len().min(MAX_POPUP_ROWS)); - } } impl WidgetRef for &FileSearchPopup {