mirror of
https://github.com/openai/codex.git
synced 2026-11-30 00:10:49 +00:00
adding ctrl+f ctrl+b emacs style mapping
This commit is contained in:
@@ -285,6 +285,11 @@ impl TextArea {
|
||||
code: KeyCode::Left,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
..
|
||||
}
|
||||
| KeyEvent {
|
||||
code: KeyCode::Char('b'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
..
|
||||
} => {
|
||||
self.move_cursor_left();
|
||||
}
|
||||
@@ -292,6 +297,11 @@ impl TextArea {
|
||||
code: KeyCode::Right,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
..
|
||||
}
|
||||
| KeyEvent {
|
||||
code: KeyCode::Char('f'),
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
..
|
||||
} => {
|
||||
self.move_cursor_right();
|
||||
}
|
||||
@@ -884,6 +894,34 @@ mod tests {
|
||||
assert_eq!(t.cursor(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_f_and_ctrl_b_move_one_char() {
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::event::KeyEvent;
|
||||
use crossterm::event::KeyModifiers;
|
||||
|
||||
let mut t = ta_with("abc");
|
||||
// Forward moves
|
||||
t.set_cursor(0);
|
||||
t.input(KeyEvent::new(KeyCode::Char('f'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 1);
|
||||
t.input(KeyEvent::new(KeyCode::Char('f'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 2);
|
||||
t.input(KeyEvent::new(KeyCode::Char('f'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 3);
|
||||
|
||||
// Backward moves
|
||||
t.input(KeyEvent::new(KeyCode::Char('b'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 2);
|
||||
t.input(KeyEvent::new(KeyCode::Char('b'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 1);
|
||||
t.input(KeyEvent::new(KeyCode::Char('b'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 0);
|
||||
// Further backward at start stays at 0
|
||||
t.input(KeyEvent::new(KeyCode::Char('b'), KeyModifiers::CONTROL));
|
||||
assert_eq!(t.cursor(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cursor_left_and_right_handle_graphemes() {
|
||||
let mut t = ta_with("a👍b");
|
||||
|
||||
Reference in New Issue
Block a user