Skip to content

Commit b0a25f4

Browse files
committed
feat(cli/chat): use alt + enter for multiline message
1 parent 7a65533 commit b0a25f4

File tree

1 file changed

+10
-14
lines changed
  • crates/rullm-cli/src/commands

1 file changed

+10
-14
lines changed

crates/rullm-cli/src/commands/chat.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,9 @@ impl Completer for SlashCommandCompleter {
200200
/// Add common keybindings used by both emacs and vi modes to eliminate duplication
201201
fn add_common_keybindings(keybindings: &mut reedline::Keybindings) {
202202
keybindings.add_binding(
203-
KeyModifiers::NONE,
204-
KeyCode::Enter,
205-
ReedlineEvent::SubmitOrNewline,
206-
);
207-
keybindings.add_binding(
208-
KeyModifiers::ALT | KeyModifiers::CONTROL,
203+
KeyModifiers::ALT,
209204
KeyCode::Enter,
210-
ReedlineEvent::Submit,
205+
ReedlineEvent::Edit(vec![EditCommand::InsertNewline]),
211206
);
212207
keybindings.add_binding(
213208
KeyModifiers::NONE,
@@ -227,15 +222,13 @@ fn setup_reedline(vim_mode: bool, data_path: &PathBuf) -> Result<Reedline> {
227222
let completion_menu = Box::new(ColumnarMenu::default().with_name("completion_menu"));
228223

229224
// Setup keybindings for multiline and tab completion
230-
let mut keybindings = default_emacs_keybindings();
231-
add_common_keybindings(&mut keybindings);
232-
233225
let edit_mode: Box<dyn reedline::EditMode> = if vim_mode {
234226
let mut vi_insert_keybindings = default_vi_insert_keybindings();
235-
let vi_normal_keybindings = default_vi_normal_keybindings();
227+
let mut vi_normal_keybindings = default_vi_normal_keybindings();
236228

237229
// Add our common keybindings to vi insert mode
238230
add_common_keybindings(&mut vi_insert_keybindings);
231+
add_common_keybindings(&mut vi_normal_keybindings);
239232

240233
// Add useful emacs shortcuts to vi insert mode for hybrid experience
241234
vi_insert_keybindings.add_binding(
@@ -271,7 +264,10 @@ fn setup_reedline(vim_mode: bool, data_path: &PathBuf) -> Result<Reedline> {
271264

272265
Box::new(Vi::new(vi_insert_keybindings, vi_normal_keybindings))
273266
} else {
274-
Box::new(Emacs::new(keybindings))
267+
let mut emacs_keybindings = default_emacs_keybindings();
268+
add_common_keybindings(&mut emacs_keybindings);
269+
270+
Box::new(Emacs::new(emacs_keybindings))
275271
};
276272

277273
let history = Box::new(
@@ -501,15 +497,15 @@ pub async fn run_interactive_chat(
501497
if let Some(last_time) = last_ctrl_c {
502498
// Check if this is a double Ctrl+C within timeout
503499
if now.duration_since(last_time) <= DOUBLE_CTRL_C_TIMEOUT {
504-
println!("\n{}", "Goodbye!".green());
500+
println!("{}", "Goodbye!".green());
505501
break;
506502
}
507503
}
508504

509505
// First Ctrl+C or timeout exceeded - show instruction message
510506
last_ctrl_c = Some(now);
511507
println!(
512-
"\n{}",
508+
"{}",
513509
"(To exit, press Ctrl+C again or Ctrl+D or enter \"/quit\")".dimmed()
514510
);
515511
}

0 commit comments

Comments
 (0)