Skip to content

Commit 1c6a621

Browse files
Alex Holmbergclaude
authored andcommitted
feat(agent): enhance input handling with multi-line support and keyboard shortcuts
- Add bracketed paste mode for proper multi-line paste handling - Add multi-line cursor navigation (Up/Down arrows) - Add keyboard shortcuts: - Ctrl+J / Shift+Enter / Alt+Enter: Insert newline - Ctrl+Shift+Backspace: Delete to line start - Ctrl+U: Clear entire input - Ctrl+W / Alt+Backspace: Delete word left - Fix newline rendering in raw mode (\n -> \r\n) - Fix Ctrl+C to properly exit when input is empty - Fix diff confirmation UI terminal state after IDE response 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fa51e07 commit 1c6a621

3 files changed

Lines changed: 311 additions & 30 deletions

File tree

src/agent/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl ChatSession {
424424
}
425425
Ok(trimmed.to_string())
426426
}
427-
InputResult::Cancel => Ok("".to_string()),
427+
InputResult::Cancel => Ok("exit".to_string()), // Ctrl+C exits
428428
InputResult::Exit => Ok("exit".to_string()),
429429
}
430430
}

src/agent/ui/diff.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! in the IDE's native diff viewer for a better experience.
88
99
use colored::Colorize;
10+
use crossterm::{cursor, execute, terminal};
1011
use inquire::ui::{Color, IndexPrefix, RenderConfig, StyleSheet, Styled};
1112
use similar::{ChangeTag, TextDiff};
1213
use std::io::{self, Write};
@@ -368,6 +369,17 @@ pub async fn confirm_file_write_with_ide(
368369
let _ = cancel_tx.send(());
369370
terminal_handle.abort();
370371

372+
// CRITICAL: Reset terminal state since abort() doesn't let inquire cleanup
373+
// This prevents terminal corruption when rendering subsequent diffs
374+
let _ = terminal::disable_raw_mode();
375+
let _ = execute!(
376+
std::io::stdout(),
377+
cursor::Show,
378+
terminal::Clear(terminal::ClearType::FromCursorDown)
379+
);
380+
print!("\r");
381+
let _ = std::io::stdout().flush();
382+
371383
match ide_result {
372384
Ok(DiffResult::Accepted { content: _ }) => {
373385
println!("\n{} Changes accepted in IDE", "✓".green());

0 commit comments

Comments
 (0)