MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / cursorUp

Function cursorUp

cli/src/utils/word-wrap-utils.ts:1–17  ·  view source on GitHub ↗
(params: {
  lineStarts: number[]
  cursorPosition: number
  desiredIndex: number
})

Source from the content-addressed store, hash-verified

1function cursorUp(params: {
2 lineStarts: number[]
3 cursorPosition: number
4 desiredIndex: number
5}): number {
6 const { lineStarts, cursorPosition, desiredIndex } = params
7 const lineIndex = lineStarts.findLastIndex((start) => start <= cursorPosition)
8
9 if (lineIndex === -1 || lineIndex === 0) {
10 return 0
11 }
12
13 const prevLineStart = lineStarts[lineIndex - 1]
14 const prevLineEndExclusive = lineStarts[lineIndex] - 1
15
16 return Math.min(prevLineEndExclusive, prevLineStart + desiredIndex)
17}
18
19function cursorDown(params: {
20 lineStarts: number[]

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected