()
| 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 |
no test coverage detected