| Index: Source/devtools/front_end/cm/markselection.js
|
| diff --git a/Source/devtools/front_end/cm/markselection.js b/Source/devtools/front_end/cm/markselection.js
|
| index c97776e492dda6ecd3d321b4407fec7bbe61a25a..ae0d393143845f055178aa1fefdd63038e66eed4 100644
|
| --- a/Source/devtools/front_end/cm/markselection.js
|
| +++ b/Source/devtools/front_end/cm/markselection.js
|
| @@ -4,7 +4,14 @@
|
| // selected text the CSS class given as option value, or
|
| // "CodeMirror-selectedtext" when the value is not a string.
|
|
|
| -(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";
|
|
|
| CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
| @@ -34,10 +41,7 @@
|
|
|
| var CHUNK_SIZE = 8;
|
| var Pos = CodeMirror.Pos;
|
| -
|
| - function cmp(pos1, pos2) {
|
| - return pos1.line - pos2.line || pos1.ch - pos2.ch;
|
| - }
|
| + var cmp = CodeMirror.cmpPos;
|
|
|
| function coverRange(cm, from, to, addAt) {
|
| if (cmp(from, to) == 0) return;
|
| @@ -63,13 +67,16 @@
|
|
|
| function reset(cm) {
|
| clear(cm);
|
| - var from = cm.getCursor("start"), to = cm.getCursor("end");
|
| - coverRange(cm, from, to);
|
| + var ranges = cm.listSelections();
|
| + for (var i = 0; i < ranges.length; i++)
|
| + coverRange(cm, ranges[i].from(), ranges[i].to());
|
| }
|
|
|
| function update(cm) {
|
| + if (!cm.somethingSelected()) return clear(cm);
|
| + if (cm.listSelections().length > 1) return reset(cm);
|
| +
|
| var from = cm.getCursor("start"), to = cm.getCursor("end");
|
| - if (cmp(from, to) == 0) return clear(cm);
|
|
|
| var array = cm.state.markedSelection;
|
| if (!array.length) return coverRange(cm, from, to);
|
| @@ -105,4 +112,4 @@
|
| }
|
| }
|
| }
|
| -})();
|
| +});
|
|
|