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

Method up

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

Source from the content-addressed store, hash-verified

326 }
327
328 up(): Cursor {
329 const { line, column } = this.getPosition()
330 if (line === 0) {
331 return this
332 }
333
334 const prevLine = this.measuredText.getWrappedText()[line - 1]
335 if (prevLine === undefined) {
336 return this
337 }
338
339 const prevLineDisplayWidth = stringWidth(prevLine)
340 if (column > prevLineDisplayWidth) {
341 const newOffset = this.getOffset({
342 line: line - 1,
343 column: prevLineDisplayWidth,
344 })
345 return new Cursor(this.measuredText, newOffset, 0)
346 }
347
348 const newOffset = this.getOffset({ line: line - 1, column })
349 return new Cursor(this.measuredText, newOffset, 0)
350 }
351
352 down(): Cursor {
353 const { line, column } = this.getPosition()

Callers 2

applySingleMotionFunction · 0.80
upOrHistoryUpFunction · 0.80

Calls 3

getPositionMethod · 0.95
getOffsetMethod · 0.95
getWrappedTextMethod · 0.80

Tested by

no test coverage detected