MCPcopy Create free account
hub / github.com/breck7/scroll / getLineIndexAtCharacterPosition

Method getLineIndexAtCharacterPosition

external/.scrollLibs.js:14368–14376  ·  view source on GitHub ↗
(str, index)

Source from the content-addressed store, hash-verified

14366 return matrix[bLength][aLength]
14367 }
14368 static getLineIndexAtCharacterPosition(str, index) {
14369 const lines = str.split("\n")
14370 const len = lines.length
14371 let position = 0
14372 for (let lineNumber = 0; lineNumber < len; lineNumber++) {
14373 position += lines[lineNumber].length
14374 if (position >= index) return lineNumber
14375 }
14376 }
14377 static resolvePath(filePath, programFilepath) {
14378 // For use in Node.js only
14379 if (!filePath.startsWith(".")) return filePath

Callers

nothing calls this directly

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected