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

Method prevVimWord

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

Source from the content-addressed store, hash-verified

735 }
736
737 prevVimWord(): Cursor {
738 if (this.isAtStart()) {
739 return this
740 }
741
742 let pos = this.offset
743 const retreat = (p: number): number => this.measuredText.prevOffset(p)
744
745 pos = retreat(pos)
746
747 while (pos > 0 && WHITESPACE_REGEX.test(this.graphemeAt(pos))) {
748 pos = retreat(pos)
749 }
750
751 // At position 0 with whitespace means no previous word exists, go to start
752 if (pos === 0 && WHITESPACE_REGEX.test(this.graphemeAt(0))) {
753 return new Cursor(this.measuredText, 0)
754 }
755
756 const charAtPos = this.graphemeAt(pos)
757 if (isVimWordChar(charAtPos)) {
758 while (pos > 0) {
759 const prevPos = retreat(pos)
760 if (!isVimWordChar(this.graphemeAt(prevPos))) break
761 pos = prevPos
762 }
763 } else if (isVimPunctuation(charAtPos)) {
764 while (pos > 0) {
765 const prevPos = retreat(pos)
766 if (!isVimPunctuation(this.graphemeAt(prevPos))) break
767 pos = prevPos
768 }
769 }
770
771 return new Cursor(this.measuredText, pos)
772 }
773
774 nextWORD(): Cursor {
775 // 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