From bbdfec42458e16367a0d5f8cdf458a65622d9fce Mon Sep 17 00:00:00 2001 From: irengrig Date: Tue, 21 Oct 2014 17:04:56 +0200 Subject: [PATCH] brace matching util, check for each brace type once --- .../codeInsight/highlighting/BraceMatchingUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java index 2eceba6e82e6..55793515e999 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceMatchingUtil.java @@ -136,13 +136,17 @@ public class BraceMatchingUtil { } String tagName = getTagName(myMatcher, fileText, iterator); if (!isStrict && !Comparing.equal(brace1TagName, tagName, isCaseSensitive)) continue; - if (forward ? isLBraceToken(iterator, fileText, fileType) : isRBraceToken(iterator, fileText, fileType)) { + + final boolean isLeftBrace = isLBraceToken(iterator, fileText, fileType); + final boolean isRightBrace = isRBraceToken(iterator, fileText, fileType); + + if (forward ? isLeftBrace : isRightBrace) { myBraceStack.push(tokenType); if (isStrict) { myTagNameStack.push(tagName); } } - else if (forward ? isRBraceToken(iterator, fileText, fileType) : isLBraceToken(iterator, fileText, fileType)) { + else if (forward ? isRightBrace : isLeftBrace) { IElementType topTokenType = myBraceStack.pop(); String topTagName = null; if (isStrict) {