MCPcopy Create free account
hub / github.com/codehamr/codehamr / looksLikePaste

Function looksLikePaste

internal/tui/prompt.go:183–196  ·  view source on GitHub ↗

looksLikePaste recognises paste-like key events. Primary signal: the bracketed-paste Paste flag (terminal wraps content in \x1b[200~...\x1b[201~). Some terminals omit those markers, so a KeyRunes event containing a newline also counts: bubbletea breaks runs on control chars, so a single keystroke ca

(msg tea.KeyMsg)

Source from the content-addressed store, hash-verified

181// also counts: bubbletea breaks runs on control chars, so a single keystroke
182// can never produce a newline inside one KeyMsg.
183func looksLikePaste(msg tea.KeyMsg) bool {
184 if msg.Paste {
185 return true
186 }
187 if msg.Type != tea.KeyRunes {
188 return false
189 }
190 for _, r := range msg.Runes {
191 if r == '\n' || r == '\r' {
192 return true
193 }
194 }
195 return false
196}
197
198// shouldChip collapses a paste when either its line count or char count clears
199// the threshold: lines catch multi line pastes, chars catch single line blobs.

Callers 1

UpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected