CharSequence (@NotNull CharSequence sequence, int offset, @NotNull TextMateSnippet snippet) { int startOffset = Math.max(offset - snippet.getKey().length(), 0); for (int i = startOffset; i <= offset; i++) { if (i == 0 || StringUtil.isWhiteSpace(sequence.charAt(i - 1))) { CharSequence prefix = sequence.subSequence(i, offset); if (StringUtil.startsWith(snippet.getKey(), prefix)) { return prefix; } } } return null; }