Skip to content

Commit 8fd556c

Browse files
committed
Complete invalid patterns when validating regex during search #2564
If the error is due to an unwritten character at the end of the regex (e.g. an unescaped trailing backslash) then add a whitespace to avoid IOOBE. Fixes #2654
1 parent 2de3957 commit 8fd556c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bundles/org.eclipse.ui/src/org/eclipse/ui/internal/SearchDecoration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ private static String buildValidationErrorString(PatternSyntaxException e, Contr
8383
GC gc = new GC(targetControl);
8484
String pattern = e.getPattern();
8585

86+
// This happens when the error is in the last (still unwritten) character e.g.
87+
// for an "Unescaped trailing backslash"
88+
if (errorIndex >= pattern.length()) {
89+
pattern += " "; //$NON-NLS-1$
90+
}
91+
8692
StringBuilder validationErrorMessage = new StringBuilder();
8793

8894
validationErrorMessage.append(description);

0 commit comments

Comments
 (0)