()
| 664 | } |
| 665 | |
| 666 | endOfVimWord(): Cursor { |
| 667 | if (this.isAtEnd()) { |
| 668 | return this |
| 669 | } |
| 670 | |
| 671 | const text = this.text |
| 672 | let pos = this.offset |
| 673 | const advance = (p: number): number => this.measuredText.nextOffset(p) |
| 674 | |
| 675 | if (this.graphemeAt(pos) === '') { |
| 676 | return this |
| 677 | } |
| 678 | |
| 679 | pos = advance(pos) |
| 680 | |
| 681 | while (pos < text.length && WHITESPACE_REGEX.test(this.graphemeAt(pos))) { |
| 682 | pos = advance(pos) |
| 683 | } |
| 684 | |
| 685 | if (pos >= text.length) { |
| 686 | return new Cursor(this.measuredText, text.length) |
| 687 | } |
| 688 | |
| 689 | const charAtPos = this.graphemeAt(pos) |
| 690 | if (isVimWordChar(charAtPos)) { |
| 691 | while (pos < text.length) { |
| 692 | const nextPos = advance(pos) |
| 693 | if (nextPos >= text.length || !isVimWordChar(this.graphemeAt(nextPos))) |
| 694 | break |
| 695 | pos = nextPos |
| 696 | } |
| 697 | } else if (isVimPunctuation(charAtPos)) { |
| 698 | while (pos < text.length) { |
| 699 | const nextPos = advance(pos) |
| 700 | if ( |
| 701 | nextPos >= text.length || |
| 702 | !isVimPunctuation(this.graphemeAt(nextPos)) |
| 703 | ) |
| 704 | break |
| 705 | pos = nextPos |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | return new Cursor(this.measuredText, pos) |
| 710 | } |
| 711 | |
| 712 | prevVimWord(): Cursor { |
| 713 | if (this.isAtStart()) { |
no test coverage detected