Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/cm/markselection.js

Issue 2772343006: DevTools: Roll CodeMirror to 5.25.1 (Closed)
Patch Set: stray space Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE 2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3 3
4 // Because sometimes you need to mark the selected *text*. 4 // Because sometimes you need to mark the selected *text*.
5 // 5 //
6 // Adds an option 'styleSelectedText' which, when enabled, gives 6 // Adds an option 'styleSelectedText' which, when enabled, gives
7 // selected text the CSS class given as option value, or 7 // selected text the CSS class given as option value, or
8 // "CodeMirror-selectedtext" when the value is not a string. 8 // "CodeMirror-selectedtext" when the value is not a string.
9 9
10 (function(mod) { 10 (function(mod) {
(...skipping 16 matching lines...) Expand all
27 cm.on("change", onChange); 27 cm.on("change", onChange);
28 } else if (!val && prev) { 28 } else if (!val && prev) {
29 cm.off("cursorActivity", onCursorActivity); 29 cm.off("cursorActivity", onCursorActivity);
30 cm.off("change", onChange); 30 cm.off("change", onChange);
31 clear(cm); 31 clear(cm);
32 cm.state.markedSelection = cm.state.markedSelectionStyle = null; 32 cm.state.markedSelection = cm.state.markedSelectionStyle = null;
33 } 33 }
34 }); 34 });
35 35
36 function onCursorActivity(cm) { 36 function onCursorActivity(cm) {
37 cm.operation(function() { update(cm); }); 37 if (cm.state.markedSelection)
38 cm.operation(function() { update(cm); });
38 } 39 }
39 40
40 function onChange(cm) { 41 function onChange(cm) {
41 if (cm.state.markedSelection.length) 42 if (cm.state.markedSelection && cm.state.markedSelection.length)
42 cm.operation(function() { clear(cm); }); 43 cm.operation(function() { clear(cm); });
43 } 44 }
44 45
45 var CHUNK_SIZE = 8; 46 var CHUNK_SIZE = 8;
46 var Pos = CodeMirror.Pos; 47 var Pos = CodeMirror.Pos;
47 var cmp = CodeMirror.cmpPos; 48 var cmp = CodeMirror.cmpPos;
48 49
49 function coverRange(cm, from, to, addAt) { 50 function coverRange(cm, from, to, addAt) {
50 if (cmp(from, to) == 0) return; 51 if (cmp(from, to) == 0) return;
51 var array = cm.state.markedSelection; 52 var array = cm.state.markedSelection;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (cmp(to, coverEnd.to) > 0) { 110 if (cmp(to, coverEnd.to) > 0) {
110 if (to.line - coverEnd.from.line < CHUNK_SIZE) { 111 if (to.line - coverEnd.from.line < CHUNK_SIZE) {
111 array.pop().clear(); 112 array.pop().clear();
112 coverRange(cm, coverEnd.from, to); 113 coverRange(cm, coverEnd.from, to);
113 } else { 114 } else {
114 coverRange(cm, coverEnd.to, to); 115 coverRange(cm, coverEnd.to, to);
115 } 116 }
116 } 117 }
117 } 118 }
118 }); 119 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698