(text: string, start: number, limit: number)
| 489 | |
| 490 | /** moves `start` forward to the beginning of a word, but never past `limit` */ |
| 491 | const wordStart = (text: string, start: number, limit: number) => { |
| 492 | if (start === 0) return 0 |
| 493 | const space = text.slice(start - 1, limit).search(/\s/) |
| 494 | return space === -1 ? limit : start + space |
| 495 | } |
| 496 | |
| 497 | /** moves `end` back to the end of a word, but never before `floor` */ |
| 498 | const wordEnd = (text: string, end: number, floor: number) => { |