()
| 689 | } |
| 690 | |
| 691 | endOfVimWord(): Cursor { |
| 692 | if (this.isAtEnd()) { |
| 693 | return this |
| 694 | } |
| 695 | |
| 696 | const text = this.text |
| 697 | let pos = this.offset |
| 698 | const advance = (p: number): number => this.measuredText.nextOffset(p) |
| 699 | |
| 700 | if (this.graphemeAt(pos) === '') { |
| 701 | return this |
| 702 | } |
| 703 | |
| 704 | pos = advance(pos) |
| 705 | |
| 706 | while (pos < text.length && WHITESPACE_REGEX.test(this.graphemeAt(pos))) { |
| 707 | pos = advance(pos) |
| 708 | } |
| 709 | |
| 710 | if (pos >= text.length) { |
| 711 | return new Cursor(this.measuredText, text.length) |
| 712 | } |
| 713 | |
| 714 | const charAtPos = this.graphemeAt(pos) |
| 715 | if (isVimWordChar(charAtPos)) { |
| 716 | while (pos < text.length) { |
| 717 | const nextPos = advance(pos) |
| 718 | if (nextPos >= text.length || !isVimWordChar(this.graphemeAt(nextPos))) |
| 719 | break |
| 720 | pos = nextPos |
| 721 | } |
| 722 | } else if (isVimPunctuation(charAtPos)) { |
| 723 | while (pos < text.length) { |
| 724 | const nextPos = advance(pos) |
| 725 | if ( |
| 726 | nextPos >= text.length || |
| 727 | !isVimPunctuation(this.graphemeAt(nextPos)) |
| 728 | ) |
| 729 | break |
| 730 | pos = nextPos |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | return new Cursor(this.measuredText, pos) |
| 735 | } |
| 736 | |
| 737 | prevVimWord(): Cursor { |
| 738 | if (this.isAtStart()) { |
no test coverage detected