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

Function countLines

internal/tui/prompt.go:210–216  ·  view source on GitHub ↗

countLines returns a paste's visual line count. Terminals disagree on separators (\n unix, \r old-mac, \r\n Windows); max of the \n and \r counts handles all three without double-counting \r\n.

(s string)

Source from the content-addressed store, hash-verified

208// separators (\n unix, \r old-mac, \r\n Windows); max of the \n and \r counts
209// handles all three without double-counting \r\n.
210func countLines(s string) int {
211 n := strings.Count(s, "\n")
212 if r := strings.Count(s, "\r"); r > n {
213 n = r
214 }
215 return n + 1
216}
217
218// handleChipKey gives chips atomic-token semantics: Backspace/Delete at a
219// boundary removes the whole chip, ←/→ jumps across it, and a cursor inside a

Callers 2

shouldChipFunction · 0.85
insertChipMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected