MCPcopy Create free account
hub / github.com/c-bata/go-prompt / findLineStartIndex

Method findLineStartIndex

document.go:300–305  ·  view source on GitHub ↗

For the index of a character at a certain line, calculate the index of the first character on that line.

(index int)

Source from the content-addressed store, hash-verified

298// For the index of a character at a certain line, calculate the index of
299// the first character on that line.
300func (d *Document) findLineStartIndex(index int) (pos int, lineStartIndex int) {
301 indexes := d.lineStartIndexes()
302 pos = bisect.Right(indexes, index) - 1
303 lineStartIndex = indexes[pos]
304 return
305}
306
307// CursorPositionRow returns the current row. (0-based.)
308func (d *Document) CursorPositionRow() (row int) {

Callers 3

CursorPositionRowMethod · 0.95
CursorPositionColMethod · 0.95

Calls 2

lineStartIndexesMethod · 0.95
RightFunction · 0.92

Tested by

no test coverage detected