diff --git a/RegExpSupport/src/org/intellij/lang/regexp/inspection/SingleCharAlternationInspection.java b/RegExpSupport/src/org/intellij/lang/regexp/inspection/SingleCharAlternationInspection.java index ec622931fde9..3cd1fff2582c 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/inspection/SingleCharAlternationInspection.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/inspection/SingleCharAlternationInspection.java @@ -105,7 +105,13 @@ public class SingleCharAlternationInspection extends LocalInspectionTool { final RegExpChar ch = (RegExpChar)child; final IElementType type = ch.getNode().getFirstChildNode().getElementType(); if (type == RegExpTT.REDUNDANT_ESCAPE) { - text.append((char)ch.getValue()); + final int value = ch.getValue(); + if (value == ']') { + text.append(ch.getUnescapedText()); + } + else { + text.append((char)value); + } } else if (type == RegExpTT.ESC_CHARACTER) { final int value = ch.getValue(); diff --git a/RegExpSupport/test/org/intellij/lang/regexp/inspection/SingleCharAlternationInspectionTest.java b/RegExpSupport/test/org/intellij/lang/regexp/inspection/SingleCharAlternationInspectionTest.java index 216b5f580b3b..f9e6d16a9563 100644 --- a/RegExpSupport/test/org/intellij/lang/regexp/inspection/SingleCharAlternationInspectionTest.java +++ b/RegExpSupport/test/org/intellij/lang/regexp/inspection/SingleCharAlternationInspectionTest.java @@ -39,6 +39,10 @@ public class SingleCharAlternationInspectionTest extends RegExpInspectionTestCas "([.\\[\\](){}^?*|+\\-$])ab", "Replace with '[.\\[\\](){}^?*|+\\-$]'"); } + public void testRedundantEscapeReplacement() { + quickfixTest("(\\[|\\])", "([\\[\\]])", "Replace with '[\\[\\]]"); + } + @NotNull @Override protected LocalInspectionTool getInspection() {