public String upToCursor() { String start = words.subList(0, wordIndex).stream().collect(Collectors.joining(" ")); if (wordIndex < words.size()) { if (!start.isEmpty()) { start += " "; } start += currentWord().substring(0, position); } return start; }
public String currentWordUpToCursor() { String currentWord = currentWord(); return currentWord != null ? currentWord.substring(0, getPosition()) : null; }