MCPcopy
hub / github.com/codeaashu/claude-code / down

Method down

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

Source from the content-addressed store, hash-verified

375 }
376
377 down(): Cursor {
378 const { line, column } = this.getPosition()
379 if (line >= this.measuredText.lineCount - 1) {
380 return this
381 }
382
383 // If there is no next line, stay on the current line,
384 // and let the caller handle it (e.g. for prompt input,
385 // we move to the next history entry)
386 const nextLine = this.measuredText.getWrappedText()[line + 1]
387 if (nextLine === undefined) {
388 return this
389 }
390
391 // If the current column is past the end of the next line,
392 // move to the end of the next line
393 const nextLineDisplayWidth = stringWidth(nextLine)
394 if (column > nextLineDisplayWidth) {
395 const newOffset = this.getOffset({
396 line: line + 1,
397 column: nextLineDisplayWidth,
398 })
399 return new Cursor(this.measuredText, newOffset, 0)
400 }
401
402 // Otherwise, move to the same column on the next line
403 const newOffset = this.getOffset({
404 line: line + 1,
405 column,
406 })
407 return new Cursor(this.measuredText, newOffset, 0)
408 }
409
410 /**
411 * 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