MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / endOfWord

Method endOfWord

source code/utils/Cursor.ts:582–620  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

580 }
581
582 endOfWord(): Cursor {
583 if (this.isAtEnd()) {
584 return this
585 }
586
587 // Use Intl.Segmenter for proper word boundary detection (including CJK)
588 const wordBoundaries = this.measuredText.getWordBoundaries()
589
590 // Find the current word boundary we're in
591 for (const boundary of wordBoundaries) {
592 if (!boundary.isWordLike) continue
593
594 // If we're inside this word but NOT at the last character
595 if (this.offset >= boundary.start && this.offset < boundary.end - 1) {
596 // Move to end of this word (last character position)
597 return new Cursor(this.measuredText, boundary.end - 1)
598 }
599
600 // If we're at the last character of a word (end - 1), find the next word's end
601 if (this.offset === boundary.end - 1) {
602 // Find next word
603 for (const nextBoundary of wordBoundaries) {
604 if (nextBoundary.isWordLike && nextBoundary.start > this.offset) {
605 return new Cursor(this.measuredText, nextBoundary.end - 1)
606 }
607 }
608 return this
609 }
610 }
611
612 // If not in a word, find the next word and go to its end
613 for (const boundary of wordBoundaries) {
614 if (boundary.isWordLike && boundary.start > this.offset) {
615 return new Cursor(this.measuredText, boundary.end - 1)
616 }
617 }
618
619 return this
620 }
621
622 prevWord(): Cursor {
623 if (this.isAtStart()) {

Callers

nothing calls this directly

Calls 2

isAtEndMethod · 0.95
getWordBoundariesMethod · 0.80

Tested by

no test coverage detected