MCPcopy Index your code
hub / github.com/codehamr/codehamr / Update

Method Update

internal/tui/prompt.go:96–121  ·  view source on GitHub ↗

Update is the promptInput's message entry point. Large pastes are swallowed into a chip and chip-aware keys handled before delegation; everything else falls through to the textarea. reconcile() runs after any value-shifting path.

(msg tea.Msg)

Source from the content-addressed store, hash-verified

94// into a chip and chip-aware keys handled before delegation; everything else
95// falls through to the textarea. reconcile() runs after any value-shifting path.
96func (p promptInput) Update(msg tea.Msg) (promptInput, tea.Cmd) {
97 if kmsg, ok := msg.(tea.KeyMsg); ok {
98 if looksLikePaste(kmsg) {
99 if pasted := string(kmsg.Runes); shouldChip(pasted) {
100 p.insertChip(pasted)
101 return p, nil
102 }
103 }
104 if handled, next := p.handlePageKey(kmsg); handled {
105 return next, nil
106 }
107 if handled, next := p.handleChipKey(kmsg); handled {
108 return next, nil
109 }
110 // A key the chip-aware handlers didn't claim (a typed rune, or a cursor
111 // move like Ctrl+B/Ctrl+F that the textarea owns) is about to reach the
112 // textarea. Snap out of any chip first so the keystroke can't land inside
113 // a label and split it: a split label desyncs reconcile, which, when two
114 // chips share a label, cross-maps the survivor to the wrong paste.
115 p.snapCursorOutOfChip()
116 }
117 var cmd tea.Cmd
118 p.ta, cmd = p.ta.Update(msg)
119 p.reconcile()
120 return p, cmd
121}
122
123// handlePageKey implements PgUp/PgDn. textarea disables its viewport keymap, so
124// page keys aren't wired, so we translate them to N×CursorUp/CursorDown (one

Callers

nothing calls this directly

Calls 7

insertChipMethod · 0.95
handlePageKeyMethod · 0.95
handleChipKeyMethod · 0.95
snapCursorOutOfChipMethod · 0.95
reconcileMethod · 0.95
looksLikePasteFunction · 0.85
shouldChipFunction · 0.85

Tested by

no test coverage detected