TextMateAutoClosingPair (int offset, @NotNull CharSequence fileText, @Nullable TextMateScope currentScope) { if (offset == 0 || !TextMateService.getInstance().getPreferenceRegistry().isPossibleLeftSmartTypingBrace(fileText.charAt(offset - 1))) { return null; } Set<TextMateAutoClosingPair> pairs = getSmartTypingPairs(currentScope); for (TextMateAutoClosingPair pair : pairs) { int startOffset = offset - pair.getLeft().length(); if (startOffset >= 0 && StringUtil.equals(pair.getLeft(), fileText.subSequence(startOffset, offset))) { return pair; } } return null; }