Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix premature position-clipping in undo/redo

Closes #577
  • Loading branch information...
commit c9a9234328757d73d94f0915d8433cfda63c58b0 1 parent dd1ce36
@marijnh marijnh authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/codemirror.js
View
7 lib/codemirror.js
@@ -718,8 +718,8 @@ var CodeMirror = (function() {
var replaced = [], end = change.start + change.added;
doc.iter(change.start, end, function(line) { replaced.push(line.text); });
out.push({start: change.start, added: change.old.length, old: replaced});
- var pos = clipPos({line: change.start + change.old.length - 1,
- ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
+ var pos = {line: change.start + change.old.length - 1,
+ ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])};
updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
}
updateInput = true;
@@ -820,7 +820,8 @@ var CodeMirror = (function() {
// Update the selection
function updateLine(n) {return n <= Math.min(to.line, to.line + lendiff) ? n : n + lendiff;}
- setSelection(selFrom, selTo, updateLine(sel.from.line), updateLine(sel.to.line));
+ setSelection(clipPos(selFrom), clipPos(selTo),
+ updateLine(sel.from.line), updateLine(sel.to.line));
}
function updateVerticalScroll(scrollTop) {
Please sign in to comment.
Something went wrong with that request. Please try again.