configureNewlineKeybinding sets up the newline keybinding from the user-configurable EditorNewline binding (ctrl+j by default), layering shift+enter on top whenever the terminal can report it. This keeps the historical defaults intact while letting users replace the ctrl+j fallback that conflicts wi
()
| 653 | // historical defaults intact while letting users replace the ctrl+j fallback |
| 654 | // that conflicts with common editor/terminal shortcuts (see issue #1626). |
| 655 | func (e *editor) configureNewlineKeybinding() { |
| 656 | // Clone so the textarea's keymap never aliases the cached KeyMap slice. |
| 657 | newlineKeys := slices.Clone(core.GetKeys().EditorNewline.Keys()) |
| 658 | if e.keyboardEnhancementsSupported && !slices.Contains(newlineKeys, "shift+enter") { |
| 659 | newlineKeys = append([]string{"shift+enter"}, newlineKeys...) |
| 660 | } |
| 661 | e.textarea.KeyMap.InsertNewline.SetKeys(newlineKeys...) |
| 662 | e.textarea.KeyMap.InsertNewline.SetEnabled(true) |
| 663 | } |
| 664 | |
| 665 | // Update handles messages and updates the component state |
| 666 | func (e *editor) Update(msg tea.Msg) (layout.Model, tea.Cmd) { |