vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js in codemirror-rails-3.24 vs vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js in codemirror-rails-4.0

- old
+ new

@@ -10,11 +10,20 @@ // selected for the behavior to occur, and style is the token style to // apply to the matches. This will be prefixed by "cm-" to create an // actual CSS class name. showToken, when enabled, will cause the // current token to be highlighted when nothing is selected. -(function() { +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + var DEFAULT_MIN_CHARS = 2; var DEFAULT_TOKEN_STYLE = "matchhighlight"; var DEFAULT_DELAY = 100; function State(options) { @@ -66,11 +75,11 @@ 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.getSelection().replace(/^\s+|\s+$/g, ""); + var selection = cm.getSelections()[0].replace(/^\s+|\s+$/g, ""); if (selection.length >= state.minChars) cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style)); }); } @@ -86,6 +95,6 @@ return style; stream.next(); stream.skipTo(query.charAt(0)) || stream.skipToEnd(); }}; } -})(); +});