Skip to content

Commit aab9d71

Browse files
committed
[match-highlighter addon] Escape special characters when creating regexp
Issue codemirror#5265
1 parent ebaccf6 commit aab9d71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

addon/search/match-highlighter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
var state = cm.state.matchHighlighter;
9191
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
9292
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
93-
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
93+
var searchFor = hasBoundary ? new RegExp("\\b" + query.replace(/[\\\[+*?(){|^$]/g, "\\$&") + "\\b") : query;
9494
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
9595
{className: "CodeMirror-selection-highlight-scrollbar"});
9696
}

0 commit comments

Comments
 (0)