This pull request resolves #2429; I was also feeling that this is not great dev experience, so we should fix.
This commit is contained in:
@@ -273,6 +273,7 @@ impl ChatComposer {
|
|||||||
|
|
||||||
if !starts_with_cmd {
|
if !starts_with_cmd {
|
||||||
self.textarea.set_text(&format!("/{} ", cmd.command()));
|
self.textarea.set_text(&format!("/{} ", cmd.command()));
|
||||||
|
self.textarea.set_cursor(self.textarea.text().len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(InputResult::None, true)
|
(InputResult::None, true)
|
||||||
@@ -1071,6 +1072,28 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn slash_tab_completion_moves_cursor_to_end() {
|
||||||
|
use crossterm::event::KeyCode;
|
||||||
|
use crossterm::event::KeyEvent;
|
||||||
|
use crossterm::event::KeyModifiers;
|
||||||
|
|
||||||
|
let (tx, _rx) = std::sync::mpsc::channel();
|
||||||
|
let sender = AppEventSender::new(tx);
|
||||||
|
let mut composer =
|
||||||
|
ChatComposer::new(true, sender, false, "Ask Codex to do anything".to_string());
|
||||||
|
|
||||||
|
for ch in ['/', 'c'] {
|
||||||
|
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
let (_result, _needs_redraw) =
|
||||||
|
composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));
|
||||||
|
|
||||||
|
assert_eq!(composer.textarea.text(), "/compact ");
|
||||||
|
assert_eq!(composer.textarea.cursor(), composer.textarea.text().len());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn slash_mention_dispatches_command_and_inserts_at() {
|
fn slash_mention_dispatches_command_and_inserts_at() {
|
||||||
use crossterm::event::KeyCode;
|
use crossterm::event::KeyCode;
|
||||||
|
|||||||
Reference in New Issue
Block a user