mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(tui/composer): restore Option+Enter newline and Cmd+Z undo
This commit is contained in:
@@ -242,6 +242,10 @@ impl TextArea {
|
||||
KeyEvent { code: KeyCode::Char('\u{0006}'), modifiers: KeyModifiers::NONE, .. } /* ^F */ => {
|
||||
self.move_cursor_right();
|
||||
}
|
||||
KeyEvent {
|
||||
code: KeyCode::Char(c),
|
||||
..
|
||||
} if matches!(c, '\n' | '\r') => self.insert_str("\n"),
|
||||
KeyEvent {
|
||||
code: KeyCode::Char(c),
|
||||
// Insert plain characters (and Shift-modified). Do NOT insert when ALT is held,
|
||||
@@ -321,6 +325,13 @@ impl TextArea {
|
||||
} => {
|
||||
self.undo();
|
||||
}
|
||||
KeyEvent {
|
||||
code: KeyCode::Char('z'),
|
||||
modifiers: KeyModifiers::SUPER,
|
||||
..
|
||||
} => {
|
||||
self.undo();
|
||||
}
|
||||
// macOS-like shortcuts (when terminals report the Command key as SUPER):
|
||||
// Cmd+Left -> move to beginning of line
|
||||
// Cmd+Right -> move to end of line
|
||||
@@ -1275,6 +1286,17 @@ mod tests {
|
||||
assert_eq!(t.cursor(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alt_enter_inserts_newline() {
|
||||
let mut t = TextArea::new();
|
||||
t.input(KeyEvent::new(KeyCode::Enter, KeyModifiers::ALT));
|
||||
assert_eq!(t.text(), "\n");
|
||||
|
||||
let mut t = TextArea::new();
|
||||
t.input(KeyEvent::new(KeyCode::Char('\n'), KeyModifiers::ALT));
|
||||
assert_eq!(t.text(), "\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn control_h_backspace() {
|
||||
// Test Ctrl+H as backspace
|
||||
|
||||
Reference in New Issue
Block a user