##// END OF EJS Templates
Updating CodeMirror to c813c94 to fix #1344.
Brian Granger -
Show More
@@ -5,7 +5,7
5 We carry a mostly unmodified copy of CodeMirror. The current version we use
5 We carry a mostly unmodified copy of CodeMirror. The current version we use
6 is (*please update this information when updating versions*)::
6 is (*please update this information when updating versions*)::
7
7
8 CodeMirror 7f93a5c
8 CodeMirror c813c94
9
9
10 The only changes we've applied so far are these::
10 The only changes we've applied so far are these::
11
11
@@ -149,8 +149,10 var CodeMirror = (function() {
149 else if (option == "theme") themeChanged();
149 else if (option == "theme") themeChanged();
150 else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
150 else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
151 else if (option == "tabSize") operation(tabsChanged)();
151 else if (option == "tabSize") operation(tabsChanged)();
152 if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme")
152 if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme") {
153 gutterChanged();
153 updateDisplay(true);
154 updateDisplay(true);
155 }
154 },
156 },
155 getOption: function(option) {return options[option];},
157 getOption: function(option) {return options[option];},
156 undo: operation(undo),
158 undo: operation(undo),
@@ -278,8 +280,8 var CodeMirror = (function() {
278 return index;
280 return index;
279 },
281 },
280 scrollTo: function(x, y) {
282 scrollTo: function(x, y) {
281 if (x != null) scroller.scrollTop = x;
283 if (x != null) scroller.scrollLeft = x;
282 if (y != null) scroller.scrollLeft = y;
284 if (y != null) scroller.scrollTop = y;
283 updateDisplay([]);
285 updateDisplay([]);
284 },
286 },
285
287
@@ -440,10 +442,10 var CodeMirror = (function() {
440 try {
442 try {
441 var text = e.dataTransfer.getData("Text");
443 var text = e.dataTransfer.getData("Text");
442 if (text) {
444 if (text) {
443 var end = replaceRange(text, pos, pos);
444 var curFrom = sel.from, curTo = sel.to;
445 var curFrom = sel.from, curTo = sel.to;
445 setSelectionUser(pos, end);
446 setSelectionUser(pos, pos);
446 if (draggingText) replaceRange("", curFrom, curTo);
447 if (draggingText) replaceRange("", curFrom, curTo);
448 replaceSelection(text);
447 focusInput();
449 focusInput();
448 }
450 }
449 }
451 }
@@ -511,9 +513,9 var CodeMirror = (function() {
511 }
513 }
512 }
514 }
513 function onKeyPress(e) {
515 function onKeyPress(e) {
516 if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
514 var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
517 var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
515 if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
518 if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
516 if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
517 if (window.opera && !e.which && handleKeyBinding(e)) return;
519 if (window.opera && !e.which && handleKeyBinding(e)) return;
518 if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
520 if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
519 var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
521 var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
@@ -565,20 +567,22 var CodeMirror = (function() {
565 }
567 }
566 updateLinesNoUndo(from, to, newText, selFrom, selTo);
568 updateLinesNoUndo(from, to, newText, selFrom, selTo);
567 }
569 }
568 function unredoHelper(from, to) {
570 function unredoHelper(from, to, dir) {
569 var change = from.pop();
571 var set = from.pop(), len = set ? set.length : 0, out = [];
570 if (change) {
572 for (var i = dir > 0 ? 0 : len - 1, e = dir > 0 ? len : -1; i != e; i += dir) {
573 var change = set[i];
571 var replaced = [], end = change.start + change.added;
574 var replaced = [], end = change.start + change.added;
572 doc.iter(change.start, end, function(line) { replaced.push(line.text); });
575 doc.iter(change.start, end, function(line) { replaced.push(line.text); });
573 to.push({start: change.start, added: change.old.length, old: replaced});
576 out.push({start: change.start, added: change.old.length, old: replaced});
574 var pos = clipPos({line: change.start + change.old.length - 1,
577 var pos = clipPos({line: change.start + change.old.length - 1,
575 ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
578 ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
576 updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
579 updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
577 updateInput = true;
578 }
580 }
581 updateInput = true;
582 to.push(out);
579 }
583 }
580 function undo() {unredoHelper(history.done, history.undone);}
584 function undo() {unredoHelper(history.done, history.undone, -1);}
581 function redo() {unredoHelper(history.undone, history.done);}
585 function redo() {unredoHelper(history.undone, history.done, 1);}
582
586
583 function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
587 function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
584 if (suppressEdits) return;
588 if (suppressEdits) return;
@@ -780,7 +784,7 var CodeMirror = (function() {
780 if (!posEq(sel.from, sel.to)) {
784 if (!posEq(sel.from, sel.to)) {
781 prevInput = "";
785 prevInput = "";
782 input.value = getSelection();
786 input.value = getSelection();
783 input.select();
787 selectInput(input);
784 } else if (user) prevInput = input.value = "";
788 } else if (user) prevInput = input.value = "";
785 }
789 }
786
790
@@ -1537,7 +1541,7 var CodeMirror = (function() {
1537 leaveInputAlone = true;
1541 leaveInputAlone = true;
1538 var val = input.value = getSelection();
1542 var val = input.value = getSelection();
1539 focusInput();
1543 focusInput();
1540 input.select();
1544 selectInput(input);
1541 function rehide() {
1545 function rehide() {
1542 var newVal = splitLines(input.value).join("\n");
1546 var newVal = splitLines(input.value).join("\n");
1543 if (newVal != val) operation(replaceSelection)(newVal, "end");
1547 if (newVal != val) operation(replaceSelection)(newVal, "end");
@@ -2551,11 +2555,13 var CodeMirror = (function() {
2551 History.prototype = {
2555 History.prototype = {
2552 addChange: function(start, added, old) {
2556 addChange: function(start, added, old) {
2553 this.undone.length = 0;
2557 this.undone.length = 0;
2554 var time = +new Date, last = this.done[this.done.length - 1];
2558 var time = +new Date, cur = this.done[this.done.length - 1], last = cur && cur[cur.length - 1];
2555 if (time - this.time > 400 || !last ||
2559 var dtime = time - this.time;
2556 last.start > start + added || last.start + last.added < start - last.added + last.old.length)
2560 if (dtime > 400 || !last) {
2557 this.done.push({start: start, added: added, old: old});
2561 this.done.push([{start: start, added: added, old: old}]);
2558 else {
2562 } else if (last.start > start + added || last.start + last.added < start - last.added + last.old.length) {
2563 cur.push({start: start, added: added, old: old});
2564 } else {
2559 var oldoff = 0;
2565 var oldoff = 0;
2560 if (start < last.start) {
2566 if (start < last.start) {
2561 for (var i = last.start - start - 1; i >= 0; --i)
2567 for (var i = last.start - start - 1; i >= 0; --i)
@@ -15,7 +15,7 CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
15
15
16 var hrRE = /^[*-=_]/
16 var hrRE = /^[*-=_]/
17 , ulRE = /^[*-+]\s+/
17 , ulRE = /^[*-+]\s+/
18 , olRE = /^[0-9]\.\s+/
18 , olRE = /^[0-9]+\.\s+/
19 , headerRE = /^(?:\={3,}|-{3,})$/
19 , headerRE = /^(?:\={3,}|-{3,})$/
20 , codeRE = /^(k:\t|\s{4,})/
20 , codeRE = /^(k:\t|\s{4,})/
21 , textRE = /^[^\[*_\\<>`]+/;
21 , textRE = /^[^\[*_\\<>`]+/;
@@ -213,6 +213,10 CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
213
213
214 token: function(stream, state) {
214 token: function(stream, state) {
215 if (stream.sol()) {
215 if (stream.sol()) {
216 // Reset EM state
217 state.em = false;
218 // Reset STRONG state
219 state.strong = false;
216 state.f = state.block;
220 state.f = state.block;
217 var previousIndentation = state.indentation
221 var previousIndentation = state.indentation
218 , currentIndentation = 0;
222 , currentIndentation = 0;
General Comments 0
You need to be logged in to leave comments. Login now