diff --git a/lib/codemirror.js b/lib/codemirror.js
index 138f10d224a3f9e6a9e2f51700aca8abbd01e95f..03ddeb39316159fcea91bdfe6627e843f531aaba 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -2644,6 +2644,7 @@
     if (!addNew) {
       ourIndex = 0;
       setSelection(doc, new Selection([ourRange], 0), sel_mouse);
+      startSel = doc.sel;
     } else if (ourIndex > -1) {
       replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
     } else {