Skip to content

Commit

Permalink
[match-highlighter] Fix issue in highlighting non-alphanumeric tokens
Browse files Browse the repository at this point in the history
Closes #6279
  • Loading branch information
marijnh committed May 15, 2020
1 parent b6ac63e commit 25e7a32
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addon/search/match-highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
var state = cm.state.matchHighlighter;
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
var searchFor = hasBoundary ? new RegExp("\\b" + query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") + "\\b") : query;
var searchFor = hasBoundary ? new RegExp((/\w/.test(query.charAt(0)) ? "\\b" : "") +
query.replace(/[\\\[.+*?(){|^$]/g, "\\$&") +
(/\w/.test(query.charAt(query.length - 1)) ? "\\b" : "")) : query;
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
{className: "CodeMirror-selection-highlight-scrollbar"});
}
Expand Down

0 comments on commit 25e7a32

Please sign in to comment.