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

Function runeOffsetToRowCol

internal/tui/prompt.go:447–463  ·  view source on GitHub ↗

runeOffsetToRowCol converts an absolute rune offset into (row, col).

(value string, offset int)

Source from the content-addressed store, hash-verified

445
446// runeOffsetToRowCol converts an absolute rune offset into (row, col).
447func runeOffsetToRowCol(value string, offset int) (int, int) {
448 row, col := 0, 0
449 i := 0
450 for _, r := range value {
451 if i == offset {
452 return row, col
453 }
454 if r == '\n' {
455 row++
456 col = 0
457 } else {
458 col++
459 }
460 i++
461 }
462 return row, col
463}
464
465// View delegates to the textarea. Chip labels are already plain text in the
466// value, so no post-processing is needed.

Callers 1

setCursorRuneOffsetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected