Skip to content

Commit

Permalink
Auto suggestion error when type "\\" character, fixes #602
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 17, 2020
1 parent 495b534 commit d92701d
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3966,14 +3966,12 @@ private String matchPreviousCommand(String buffer) {
}
History history = getHistory();
StringBuilder sb = new StringBuilder();
char prev = '0';
for (char c: buffer.toCharArray()) {
for (char c: buffer.replace("\\", "\\\\").toCharArray()) {
if (c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' || c == '^' || c == '*'
|| c == '$' || c == '.' || c == '?' || c == '+' || (c == '\\' && prev != '\\')) {
|| c == '$' || c == '.' || c == '?' || c == '+') {
sb.append('\\');
}
sb.append(c);
prev = c;
}
Pattern pattern = Pattern.compile(sb.toString() + ".*", Pattern.DOTALL);
Iterator<History.Entry> iter = history.reverseIterator(history.last());
Expand Down

0 comments on commit d92701d

Please sign in to comment.