Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3311,8 +3311,10 @@ func (a *App) handleInsertMode(msg tea.KeyMsg) tea.Cmd {
return nil
}
}
// Plain Enter sends; Shift+Enter (and Ctrl+J as a fallback for terminals
// Plain Enter sends; modified Enter variants insert a newline.
// Plain Enter sends. Ctrl+Enter also sends when the terminal reports it
// distinctly, which gives IME users a send key that is less likely to be
// consumed as composition commit. Shift/Alt+Enter, backslash+Enter, and
// Ctrl+J insert a newline.
keystroke := msg.Key().Keystroke()
stringForm := msg.String()
isModifiedEnter := stringForm == "shift+enter" || keystroke == "shift+enter" || stringForm == "shift+return" || keystroke == "shift+return" || stringForm == "alt+enter" || keystroke == "alt+enter" || stringForm == "alt+return" || keystroke == "alt+return"
Expand Down
38 changes: 38 additions & 0 deletions internal/ui/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,44 @@ func TestHandleInsertMode_PlainEnterSends(t *testing.T) {
}
}

func TestHandleInsertMode_CtrlEnterSends(t *testing.T) {
app := NewApp()
app.activeChannelID = "C1"
app.focusedPanel = PanelMessages
app.SetMode(ModeInsert)
app.compose.SetValue("hello")

cmd := app.handleInsertMode(tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModCtrl})
if cmd == nil {
t.Fatalf("Ctrl+Enter with text should return a send cmd")
}
msg := cmd()
if _, ok := msg.(SendMessageMsg); !ok {
t.Fatalf("expected SendMessageMsg, got %T", msg)
}
if app.compose.Value() != "" {
t.Fatalf("expected compose to be reset after Ctrl+Enter send, got %q", app.compose.Value())
}
}

func TestHandleInsertMode_ThreadReplyCtrlEnterSends(t *testing.T) {
app := NewApp()
app.activeChannelID = "C1"
app.threadPanel.SetThread(messages.MessageItem{TS: "P1"}, nil, "C1", "P1")
app.threadVisible = true
app.focusedPanel = PanelThread
app.SetMode(ModeInsert)
app.threadCompose.SetValue("reply")

cmd := app.handleInsertMode(tea.KeyPressMsg{Code: tea.KeyEnter, Mod: tea.ModCtrl})
if cmd == nil {
t.Fatalf("Ctrl+Enter with thread text should return a send cmd")
}
if _, ok := cmd().(SendThreadReplyMsg); !ok {
t.Fatalf("expected SendThreadReplyMsg, got %T", cmd())
}
}

func TestHandleInsertMode_ShiftReturnInsertsNewline(t *testing.T) {
app := NewApp()
app.activeChannelID = "C1"
Expand Down
2 changes: 1 addition & 1 deletion wiki/Keybindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| `Enter` | Normal (message) | Open thread |
| `i` / `F2` | Normal | Enter insert mode (`F2` is useful when a CJK IME consumes alphabetic keys for composition) |
| `Esc` | Insert / Command | Return to normal mode |
| `Enter` | Insert | Send message |
| `Enter` / `Ctrl+Enter` | Insert | Send message (`Ctrl+Enter` is useful when IME composition consumes plain Enter) |
| `Shift+Enter` | Insert | Newline |
| `Ctrl+V` | Insert | Smart paste — image / file path / text (use `Ctrl+V`, not the terminal's `Ctrl+Shift+V`) |
| `Ctrl+U` | Insert | Clear compose (text + pending attachments) |
Expand Down