boolean (char c, PsiFile file, @NotNull Editor editor) { if (file.getFileType() == TextMateFileType.INSTANCE) { final int offset = editor.getCaretModel().getOffset(); EditorHighlighter highlighter = editor.getHighlighter(); HighlighterIterator iterator = highlighter.createIterator(offset); if (offset == 0 && iterator.atEnd()) { return false; } final IElementType tokenType = iterator.getTokenType(); if (tokenType instanceof TextMateElementType) { TextMateScope scopeSelector = ((TextMateElementType)tokenType).getScope(); final TextMateAutoClosingPair pairForChar = findSingleCharSmartTypingPair(c, scopeSelector); if (pairForChar != null) { final Document document = editor.getDocument(); int endOffset = offset + pairForChar.getRight().length(); if (endOffset < document.getTextLength()) { if (StringUtil.equals(pairForChar.getRight(), document.getCharsSequence().subSequence(offset, endOffset))) { document.deleteString(offset, endOffset); return true; } } } } } return false; }