()
| 580 | } |
| 581 | |
| 582 | endOfWord(): Cursor { |
| 583 | if (this.isAtEnd()) { |
| 584 | return this |
| 585 | } |
| 586 | |
| 587 | // Use Intl.Segmenter for proper word boundary detection (including CJK) |
| 588 | const wordBoundaries = this.measuredText.getWordBoundaries() |
| 589 | |
| 590 | // Find the current word boundary we're in |
| 591 | for (const boundary of wordBoundaries) { |
| 592 | if (!boundary.isWordLike) continue |
| 593 | |
| 594 | // If we're inside this word but NOT at the last character |
| 595 | if (this.offset >= boundary.start && this.offset < boundary.end - 1) { |
| 596 | // Move to end of this word (last character position) |
| 597 | return new Cursor(this.measuredText, boundary.end - 1) |
| 598 | } |
| 599 | |
| 600 | // If we're at the last character of a word (end - 1), find the next word's end |
| 601 | if (this.offset === boundary.end - 1) { |
| 602 | // Find next word |
| 603 | for (const nextBoundary of wordBoundaries) { |
| 604 | if (nextBoundary.isWordLike && nextBoundary.start > this.offset) { |
| 605 | return new Cursor(this.measuredText, nextBoundary.end - 1) |
| 606 | } |
| 607 | } |
| 608 | return this |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | // If not in a word, find the next word and go to its end |
| 613 | for (const boundary of wordBoundaries) { |
| 614 | if (boundary.isWordLike && boundary.start > this.offset) { |
| 615 | return new Cursor(this.measuredText, boundary.end - 1) |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | return this |
| 620 | } |
| 621 | |
| 622 | prevWord(): Cursor { |
| 623 | if (this.isAtStart()) { |
nothing calls this directly
no test coverage detected