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

Function cursorDown

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

Source from the content-addressed store, hash-verified

17}
18
19function cursorDown(params: {
20 lineStarts: number[]
21 cursorPosition: number
22 desiredIndex: number
23}): number {
24 const { lineStarts, cursorPosition, desiredIndex } = params
25 const lineIndex = lineStarts.findLastIndex((start) => start <= cursorPosition)
26
27 if (lineIndex === -1 || lineIndex === lineStarts.length - 1) {
28 return Infinity
29 }
30
31 return Math.min(
32 (lineStarts[lineIndex + 2] ?? Infinity) - 1,
33 lineStarts[lineIndex + 1] + desiredIndex,
34 )
35}
36
37export function calculateNewCursorPosition(params: {
38 cursorPosition: number

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected