MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / down

Method down

src/utils/Cursor.ts:352–383  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

350 }
351
352 down(): Cursor {
353 const { line, column } = this.getPosition()
354 if (line >= this.measuredText.lineCount - 1) {
355 return this
356 }
357
358 // If there is no next line, stay on the current line,
359 // and let the caller handle it (e.g. for prompt input,
360 // we move to the next history entry)
361 const nextLine = this.measuredText.getWrappedText()[line + 1]
362 if (nextLine === undefined) {
363 return this
364 }
365
366 // If the current column is past the end of the next line,
367 // move to the end of the next line
368 const nextLineDisplayWidth = stringWidth(nextLine)
369 if (column > nextLineDisplayWidth) {
370 const newOffset = this.getOffset({
371 line: line + 1,
372 column: nextLineDisplayWidth,
373 })
374 return new Cursor(this.measuredText, newOffset, 0)
375 }
376
377 // Otherwise, move to the same column on the next line
378 const newOffset = this.getOffset({
379 line: line + 1,
380 column,
381 })
382 return new Cursor(this.measuredText, newOffset, 0)
383 }
384
385 /**
386 * Move to the start of the current line (column 0).

Callers 2

applySingleMotionFunction · 0.80
downOrHistoryDownFunction · 0.80

Calls 3

getPositionMethod · 0.95
getOffsetMethod · 0.95
getWrappedTextMethod · 0.80

Tested by

no test coverage detected