MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / prevVimWord

Method prevVimWord

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

Source from the content-addressed store, hash-verified

710 }
711
712 prevVimWord(): Cursor {
713 if (this.isAtStart()) {
714 return this
715 }
716
717 let pos = this.offset
718 const retreat = (p: number): number => this.measuredText.prevOffset(p)
719
720 pos = retreat(pos)
721
722 while (pos > 0 && WHITESPACE_REGEX.test(this.graphemeAt(pos))) {
723 pos = retreat(pos)
724 }
725
726 // At position 0 with whitespace means no previous word exists, go to start
727 if (pos === 0 && WHITESPACE_REGEX.test(this.graphemeAt(0))) {
728 return new Cursor(this.measuredText, 0)
729 }
730
731 const charAtPos = this.graphemeAt(pos)
732 if (isVimWordChar(charAtPos)) {
733 while (pos > 0) {
734 const prevPos = retreat(pos)
735 if (!isVimWordChar(this.graphemeAt(prevPos))) break
736 pos = prevPos
737 }
738 } else if (isVimPunctuation(charAtPos)) {
739 while (pos > 0) {
740 const prevPos = retreat(pos)
741 if (!isVimPunctuation(this.graphemeAt(prevPos))) break
742 pos = prevPos
743 }
744 }
745
746 return new Cursor(this.measuredText, pos)
747 }
748
749 nextWORD(): Cursor {
750 // eslint-disable-next-line @typescript-eslint/no-this-alias

Callers 1

applySingleMotionFunction · 0.80

Calls 4

isAtStartMethod · 0.95
graphemeAtMethod · 0.95
isVimWordCharFunction · 0.85
isVimPunctuationFunction · 0.85

Tested by

no test coverage detected