vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js in codemirror-rails-4.1 vs vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js in codemirror-rails-4.2
- old
+ new
@@ -1,5 +1,8 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
// Highlighting text that matches the selection
//
// Defines an option highlightSelectionMatches, which, when enabled,
// will style strings that match the selection throughout the
// document.
@@ -74,11 +77,12 @@
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
return;
}
- if (cm.getCursor("head").line != cm.getCursor("anchor").line) return;
- var selection = cm.getSelections()[0].replace(/^\s+|\s+$/g, "");
+ var from = cm.getCursor("from"), to = cm.getCursor("to");
+ if (from.line != to.line) return;
+ var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
});
}