(text: string, offset: number)
| 138 | } |
| 139 | |
| 140 | export const getWordForward = (text: string, offset: number) => { |
| 141 | let currentChar = getCharFromGraphemeBreaker(text, offset) |
| 142 | let forwardOffset = offset + 1 |
| 143 | for (; forwardOffset < text.length; ) { |
| 144 | const forwardChar = getCharFromGraphemeBreaker(text, forwardOffset) |
| 145 | if (equalOfCharacterType(currentChar, forwardChar)) { |
| 146 | forwardOffset += forwardChar.length |
| 147 | } else break |
| 148 | } |
| 149 | if (forwardOffset - offset > 1) { |
| 150 | const newText = text.substring(offset, forwardOffset) |
| 151 | const { text: wordText, offset: wordOffset } = splitTextOfWord(newText, segments => segments[0]) |
| 152 | forwardOffset = offset + wordOffset + wordText.length |
| 153 | } |
| 154 | return text.substring(offset, forwardOffset > text.length ? text.length : forwardOffset) |
| 155 | } |
| 156 | |
| 157 | export const getWordOffsetForward = (text: string, offset: number) => { |
| 158 | return offset + getWordForward(text, offset).length |
no test coverage detected
searching dependent graphs…