- // If no point could be found, use whole text length for selection.
- if (indexOfExtension < 1) {
+ // if there either is no dot, or the last dot is the first or last char, treat as no extension.
+ if (indexOfExtension < 1 || indexOfExtension == text.length() - 1) {