MCPcopy
hub / github.com/docker/docker-agent / configureNewlineKeybinding

Method configureNewlineKeybinding

pkg/tui/components/editor/editor.go:655–663  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

653// historical defaults intact while letting users replace the ctrl+j fallback
654// that conflicts with common editor/terminal shortcuts (see issue #1626).
655func (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
666func (e *editor) Update(msg tea.Msg) (layout.Model, tea.Cmd) {

Callers 3

NewFunction · 0.95
UpdateMethod · 0.95

Calls 3

GetKeysFunction · 0.92
CloneMethod · 0.45
KeysMethod · 0.45

Tested by 1