From d46bd84f9159cccd7ad1c93bdb7044bd9cea0e0a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijnh@gmail.com> Date: Thu, 12 Jan 2012 09:47:32 +0100 Subject: [PATCH] Make sure undo doesn't leave the cursor in an invalid position Closes #325 --- lib/codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index d5cb3ff1..62f62ce0 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2737,7 +2737,7 @@ var CodeMirror = (function() { // Used to position the cursor after an undo/redo by finding the // last edited character. function editEnd(from, to) { - if (!to) return from ? from.length : 0; + if (!to) return 0; if (!from) return to.length; for (var i = from.length, j = to.length; i >= 0 && j >= 0; --i, --j) if (from.charAt(i) != to.charAt(j)) break; -- GitLab