diff options
| author | Mark Jaquith <mark@jaquith.me> | 2026-09-14 15:47:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-14 21:47:53 +0200 |
| commit | b0f21ed2cb85613050b794bf6c78a7c367a94e0d (patch) | |
| tree | 25c14e09338f5300bedbc8131aa23fab3d37add9 /src/client/shell/copy_mode.rs | |
| parent | d8b36691d10c6055293ad45324b22af8b8f570e5 (diff) | |
feat: add cursor-based editing to text inputs (#3698)
* feat: add cursor-based editing to text inputs
refs #1803
* fix: preserve dialog actions with associated text
refs #1803
* refactor: simplify text editor outcomes and tests
refs #1803
---------
Co-authored-by: JJ Liebig <jonathan.liebig@gmail.com>
Diffstat (limited to 'src/client/shell/copy_mode.rs')
| -rw-r--r-- | src/client/shell/copy_mode.rs | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/client/shell/copy_mode.rs b/src/client/shell/copy_mode.rs index f08c4afb..9750e19e 100644 --- a/src/client/shell/copy_mode.rs +++ b/src/client/shell/copy_mode.rs @@ -279,38 +279,18 @@ impl ClientShellState { } } KeyCode::Enter => { - submit = Some((prompt.query.clone(), prompt.direction)); + submit = Some((prompt.query.to_string(), prompt.direction)); if let Some(copy_mode) = self.copy_mode.as_mut() { copy_mode.search_prompt = None; } } - KeyCode::Backspace => { - if let Some(prompt) = self - .copy_mode - .as_mut() - .and_then(|copy_mode| copy_mode.search_prompt.as_mut()) - { - prompt.query.pop(); - } - } - KeyCode::Char('u') if key.modifiers.contains(KeyModifiers::CONTROL) => { + _ => { if let Some(prompt) = self .copy_mode .as_mut() .and_then(|copy_mode| copy_mode.search_prompt.as_mut()) { - prompt.query.clear(); - } - } - _ => { - if let Some(ch) = crate::copy_mode::copy_mode_command_char(key.clone()) { - if let Some(prompt) = self - .copy_mode - .as_mut() - .and_then(|copy_mode| copy_mode.search_prompt.as_mut()) - { - prompt.query.push(ch); - } + prompt.query.handle_key(key); } } } @@ -322,6 +302,13 @@ impl ClientShellState { } pub(super) fn insert_copy_search_text(&mut self, text: &str) -> bool { + if self.mode != ClientShellMode::Copy + || self.overlay.is_some() + || self.popup_terminal_id.is_some() + || self.popup_pending + { + return false; + } let Some(prompt) = self .copy_mode .as_mut() @@ -329,9 +316,7 @@ impl ClientShellState { else { return false; }; - prompt - .query - .extend(text.chars().filter(|character| !character.is_control())); + prompt.query.insert(text); true } @@ -341,7 +326,7 @@ impl ClientShellState { }; copy_mode.search_prompt = Some(ClientCopySearchPrompt { direction, - query: String::new(), + query: TextEditor::default(), }); } |
