Skip to content

Commit b31f156

Browse files
committed
feat(chat): Add Shift+Enter for newlines (#1212)
Add Shift+Enter as an additional keyboard shortcut for inserting newlines in chat prompts, alongside the existing Ctrl+J and Alt+Enter options. This follows common conventions in web interfaces and improves user experience. 🤖 Assisted by [Amazon Q Developer](https://aws.amazon.com/q/developer)
1 parent d1552a6 commit b31f156

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ const ROTATING_TIPS: [&str; 12] = [
220220

221221
const GREETING_BREAK_POINT: usize = 80;
222222

223-
const POPULAR_SHORTCUTS: &str = color_print::cstr! {"<black!><green!>/help</green!> all commands <em>•</em> <green!>ctrl + j</green!> new lines <em>•</em> <green!>ctrl + s</green!> fuzzy search</black!>"};
223+
const POPULAR_SHORTCUTS: &str = color_print::cstr! {"<black!><green!>/help</green!> all commands <em>•</em> <green!>ctrl + j</green!> or <green!>shift + enter</green!> new lines <em>•</em> <green!>ctrl + s</green!> fuzzy search</black!>"};
224224
const SMALL_SCREEN_POPULAR_SHORTCUTS: &str = color_print::cstr! {"<black!><green!>/help</green!> all commands
225-
<green!>ctrl + j</green!> new lines
225+
<green!>ctrl + j</green!> or <green!>shift + enter</green!> new lines
226226
<green!>ctrl + s</green!> fuzzy search
227227
</black!>"};
228228

@@ -272,7 +272,7 @@ const HELP_TEXT: &str = color_print::cstr! {"
272272
273273
<cyan,em>Tips:</cyan,em>
274274
<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
275-
<em>Ctrl(^) + j</em> <black!>Insert new-line to provide multi-line prompt. Alternatively, [Alt(⌥) + Enter(⏎)]</black!>
275+
<em>Ctrl(^) + j</em> <black!>Insert new-line to provide multi-line prompt. Alternatively, [Alt(⌥) + Enter(⏎) or Shift + Enter(⏎)]</black!>
276276
<em>Ctrl(^) + s</em> <black!>Fuzzy search commands and context files. Use Tab to select multiple items.</black!>
277277
<black!>Change the keybind to ctrl+x with: q settings chat.skimCommandKey x (where x is any key)</black!>
278278

crates/chat-cli/src/cli/chat/prompt.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ pub fn rl(
294294
EventHandler::Simple(Cmd::Insert(1, "\n".to_string())),
295295
);
296296

297+
// Add custom keybinding for Shift+Enter to insert a newline
298+
rl.bind_sequence(
299+
KeyEvent(KeyCode::Enter, Modifiers::SHIFT),
300+
EventHandler::Simple(Cmd::Insert(1, "\n".to_string())),
301+
);
302+
297303
// Add custom keybinding for Ctrl+J to insert a newline
298304
rl.bind_sequence(
299305
KeyEvent(KeyCode::Char('j'), Modifiers::CTRL),

0 commit comments

Comments
 (0)