From a0f69ddf3d82a5bac7fe3dea8fbac5a818bd108e Mon Sep 17 00:00:00 2001
From: Adrian Heine <mail@adrianheine.de>
Date: Wed, 14 Dec 2016 12:49:01 +0100
Subject: [PATCH] Adapt tests

---
 test/doc_test.js      |  24 +--
 test/driver.js        |   8 +-
 test/emacs_test.js    |   8 +-
 test/multi_test.js    |  18 +-
 test/search_test.js   |   8 +-
 test/sql-hint-test.js |   4 +-
 test/sublime_test.js  |   8 +-
 test/test.js          | 410 +++++++++++++++++++++---------------------
 test/vim_test.js      | 122 ++++++-------
 9 files changed, 304 insertions(+), 306 deletions(-)

diff --git a/test/doc_test.js b/test/doc_test.js
index 5f242f658..3af20ff98 100644
--- a/test/doc_test.js
+++ b/test/doc_test.js
@@ -163,13 +163,13 @@
   testDoc("undoKeepRanges", "A='abcdefg' B<A", function(a, b) {
     var m = a.markText(Pos(0, 1), Pos(0, 3), {className: "foo"});
     b.replaceRange("x", Pos(0, 0));
-    eqPos(m.find().from, Pos(0, 2));
+    eqCharPos(m.find().from, Pos(0, 2));
     b.replaceRange("yzzy", Pos(0, 1), Pos(0));
     eq(m.find(), null);
     b.undo();
-    eqPos(m.find().from, Pos(0, 2));
+    eqCharPos(m.find().from, Pos(0, 2));
     b.undo();
-    eqPos(m.find().from, Pos(0, 1));
+    eqCharPos(m.find().from, Pos(0, 1));
   });
 
   testDoc("longChain", "A='uv' B<A C<B D<C", function(a, b, c, d) {
@@ -271,12 +271,12 @@
     eq(b.getValue(), "2\n3");
     eq(b.firstLine(), 1);
     b.setCursor(Pos(4));
-    eqPos(b.getCursor(), Pos(2, 1));
+    eqCharPos(b.getCursor(), Pos(2, 1));
     a.replaceRange("-1\n0\n", Pos(0, 0));
     eq(b.firstLine(), 3);
-    eqPos(b.getCursor(), Pos(4, 1));
+    eqCharPos(b.getCursor(), Pos(4, 1));
     a.undo();
-    eqPos(b.getCursor(), Pos(2, 1));
+    eqCharPos(b.getCursor(), Pos(2, 1));
     b.replaceRange("oyoy\n", Pos(2, 0));
     eq(a.getValue(), "1\n2\noyoy\n3\n4\n5");
     b.undo();
@@ -305,11 +305,11 @@
     eq(found.length, 1);
     eq(found[0], mark);
     eq(c.findMarksAt(Pos(1, 1)).length, 1);
-    eqPos(mark.find().from, Pos(0, 1));
-    eqPos(mark.find().to, Pos(3, 1));
+    eqCharPos(mark.find().from, Pos(0, 1));
+    eqCharPos(mark.find().to, Pos(3, 1));
     b.replaceRange("x\ny\n", Pos(0, 0));
-    eqPos(mark.find().from, Pos(2, 1));
-    eqPos(mark.find().to, Pos(5, 1));
+    eqCharPos(mark.find().from, Pos(2, 1));
+    eqCharPos(mark.find().to, Pos(5, 1));
     var cleared = 0;
     CodeMirror.on(mark, "clear", function() {++cleared;});
     b.operation(function(){mark.clear();});
@@ -349,9 +349,9 @@
     eq(found.length, 1);
     eq(found[0], mark);
     eq(c.findMarksAt(Pos(1, 1)).length, 1);
-    eqPos(mark.find(), Pos(1, 1));
+    eqCharPos(mark.find(), Pos(1, 1));
     b.replaceRange("x\ny\n", Pos(0, 0));
-    eqPos(mark.find(), Pos(3, 1));
+    eqCharPos(mark.find(), Pos(3, 1));
     var cleared = 0;
     CodeMirror.on(mark, "clear", function() {++cleared;});
     b.operation(function() {mark.clear();});
diff --git a/test/driver.js b/test/driver.js
index 01736450f..8789f73be 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -106,12 +106,16 @@ function near(a, b, margin, msg) {
   if (Math.abs(a - b) > margin)
     throw new Failure(label(a + " is not close to " + b + " (" + margin + ")", msg));
 }
-function eqPos(a, b, msg) {
+function eqCharPos(a, b, msg) {
   function str(p) { return "{line:" + p.line + ",ch:" + p.ch + ",sticky:" + p.sticky + "}"; }
   if (a == b) return;
   if (a == null) throw new Failure(label("comparing null to " + str(b), msg));
   if (b == null) throw new Failure(label("comparing " + str(a) + " to null", msg));
-  if (a.line != b.line || a.ch != b.ch || a.sticky != b.sticky) throw new Failure(label(str(a) + " != " + str(b), msg));
+  if (a.line != b.line || a.ch != b.ch) throw new Failure(label(str(a) + " != " + str(b), msg));
+}
+function eqCursorPos(a, b, msg) {
+  eqCharPos(a, b, msg);
+  if (a) eq(a.sticky, b.sticky, msg ? msg + ' (sticky)' : 'sticky');
 }
 function is(a, msg) {
   if (!a) throw new Failure(label("assertion failed", msg));
diff --git a/test/emacs_test.js b/test/emacs_test.js
index 2e1764235..b73eedaa6 100644
--- a/test/emacs_test.js
+++ b/test/emacs_test.js
@@ -39,13 +39,13 @@
     }, {keyMap: "emacs", value: start, mode: "javascript"});
   }
 
-  function at(line, ch) { return function(cm) { eqPos(cm.getCursor(), Pos(line, ch)); }; }
+  function at(line, ch, sticky) { return function(cm) { eqCursorPos(cm.getCursor(), Pos(line, ch, sticky)); }; }
   function txt(str) { return function(cm) { eq(cm.getValue(), str); }; }
 
-  sim("motionHSimple", "abc", "Ctrl-F", "Ctrl-F", "Ctrl-B", at(0, 1));
+  sim("motionHSimple", "abc", "Ctrl-F", "Ctrl-F", "Ctrl-B", at(0, 1, "after"));
   sim("motionHMulti", "abcde",
-      "Ctrl-4", "Ctrl-F", at(0, 4), "Ctrl--", "Ctrl-2", "Ctrl-F", at(0, 2),
-      "Ctrl-5", "Ctrl-B", at(0, 0));
+      "Ctrl-4", "Ctrl-F", at(0, 4, "before"), "Ctrl--", "Ctrl-2", "Ctrl-F", at(0, 2, "after"),
+      "Ctrl-5", "Ctrl-B", at(0, 0, "after"));
 
   sim("motionHWord", "abc. def ghi",
       "Alt-F", at(0, 3, "before"), "Alt-F", at(0, 8, "before"),
diff --git a/test/multi_test.js b/test/multi_test.js
index a8e760d27..49169b990 100644
--- a/test/multi_test.js
+++ b/test/multi_test.js
@@ -9,8 +9,8 @@
     for (var i = 0, p = 1; i < given; i++, p += 4) {
       var anchor = Pos(arguments[p], arguments[p + 1]);
       var head = Pos(arguments[p + 2], arguments[p + 3]);
-      eqPos(sels[i].anchor, anchor, "anchor of selection " + i);
-      eqPos(sels[i].head, head, "head of selection " + i);
+      eqCharPos(sels[i].anchor, anchor, "anchor of selection " + i);
+      eqCharPos(sels[i].head, head, "head of selection " + i);
     }
   }
   function hasCursors(cm) {
@@ -19,9 +19,9 @@
     if (sels.length != given)
       throw new Failure("expected " + given + " selections, found " + sels.length);
     for (var i = 0, p = 1; i < given; i++, p += 2) {
-      eqPos(sels[i].anchor, sels[i].head, "something selected for " + i);
+      eqCursorPos(sels[i].anchor, sels[i].head, "something selected for " + i);
       var head = Pos(arguments[p], arguments[p + 1]);
-      eqPos(sels[i].head, head, "selection " + i);
+      eqCharPos(sels[i].head, head, "selection " + i);
     }
   }
 
@@ -47,10 +47,10 @@
     cm.setSelections([{anchor: Pos(0, 1), head: Pos(0, 2)},
                       {anchor: Pos(1, 1), head: Pos(1, 2)},
                       {anchor: Pos(2, 1), head: Pos(2, 2)}], 1);
-    eqPos(cm.getCursor("head"), Pos(1, 2));
-    eqPos(cm.getCursor("anchor"), Pos(1, 1));
-    eqPos(cm.getCursor("from"), Pos(1, 1));
-    eqPos(cm.getCursor("to"), Pos(1, 2));
+    eqCharPos(cm.getCursor("head"), Pos(1, 2));
+    eqCharPos(cm.getCursor("anchor"), Pos(1, 1));
+    eqCharPos(cm.getCursor("from"), Pos(1, 1));
+    eqCharPos(cm.getCursor("to"), Pos(1, 2));
     cm.setCursor(Pos(1, 1));
     hasCursors(cm, 1, 1);
   }, {value: "abcde\nabcde\nabcde\n"});
@@ -274,7 +274,7 @@
     eq(cm.getSelection(), "1");
     cm.execCommand("undoSelection");
     eq(cm.getSelection(), "");
-    eqPos(cm.getCursor(), Pos(0, 0));
+    eqCharPos(cm.getCursor(), Pos(0, 0));
     cm.execCommand("redoSelection");
     eq(cm.getSelection(), "1");
     cm.execCommand("redoSelection");
diff --git a/test/search_test.js b/test/search_test.js
index 04a1e685a..9fe898bac 100644
--- a/test/search_test.js
+++ b/test/search_test.js
@@ -14,15 +14,15 @@
     for (var i = 3; i < arguments.length; i += 4) {
       var found = cursor.findNext();
       is(found, "not enough results (forward)");
-      eqPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, forward, " + (i - 3) / 4);
-      eqPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, forward, " + (i - 3) / 4);
+      eqCharPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, forward, " + (i - 3) / 4);
+      eqCharPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, forward, " + (i - 3) / 4);
     }
     is(!cursor.findNext(), "too many matches (forward)");
     for (var i = arguments.length - 4; i >= 3; i -= 4) {
       var found = cursor.findPrevious();
       is(found, "not enough results (backwards)");
-      eqPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, backwards, " + (i - 3) / 4);
-      eqPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, backwards, " + (i - 3) / 4);
+      eqCharPos(Pos(arguments[i], arguments[i + 1]), cursor.from(), "from, backwards, " + (i - 3) / 4);
+      eqCharPos(Pos(arguments[i + 2], arguments[i + 3]), cursor.to(), "to, backwards, " + (i - 3) / 4);
     }
     is(!cursor.findPrevious(), "too many matches (backwards)");
   }
diff --git a/test/sql-hint-test.js b/test/sql-hint-test.js
index 39f2172e1..31d0490f1 100644
--- a/test/sql-hint-test.js
+++ b/test/sql-hint-test.js
@@ -30,8 +30,8 @@
       var completion = CodeMirror.hint.sql(cm, {tables: spec.tables});
       if (!deepCompare(completion.list, spec.list))
         throw new Failure("Wrong completion results " + JSON.stringify(completion.list) + " vs " + JSON.stringify(spec.list));
-      eqPos(completion.from, spec.from);
-      eqPos(completion.to, spec.to);
+      eqCharPos(completion.from, spec.from);
+      eqCharPos(completion.to, spec.to);
     }, {
       value: spec.value,
       mode: "text/x-mysql"
diff --git a/test/sublime_test.js b/test/sublime_test.js
index 57f16485e..e9cd342ff 100644
--- a/test/sublime_test.js
+++ b/test/sublime_test.js
@@ -24,8 +24,8 @@
   function at(line, ch, msg) {
     return function(cm) {
       eq(cm.listSelections().length, 1);
-      eqPos(cm.getCursor("head"), Pos(line, ch), msg);
-      eqPos(cm.getCursor("anchor"), Pos(line, ch), msg);
+      eqCursorPos(cm.getCursor("head"), Pos(line, ch), msg);
+      eqCursorPos(cm.getCursor("anchor"), Pos(line, ch), msg);
     };
   }
 
@@ -54,8 +54,8 @@
       if (sels.length != ranges.length)
         throw new Failure("Expected " + ranges.length + " selections, but found " + sels.length);
       for (var i = 0; i < sels.length; i++) {
-        eqPos(sels[i].anchor, ranges[i].anchor, "anchor " + i);
-        eqPos(sels[i].head, ranges[i].head, "head " + i);
+        eqCharPos(sels[i].anchor, ranges[i].anchor, "anchor " + i);
+        eqCharPos(sels[i].head, ranges[i].head, "head " + i);
       }
     };
   }
diff --git a/test/test.js b/test/test.js
index 2367de6a6..38659f875 100644
--- a/test/test.js
+++ b/test/test.js
@@ -34,6 +34,7 @@ var opera = /Opera\/\./.test(navigator.userAgent);
 var opera_version = opera && navigator.userAgent.match(/Version\/(\d+\.\d+)/);
 if (opera_version) opera_version = Number(opera_version);
 var opera_lt10 = opera && (!opera_version || opera_version < 10);
+var webkit = /WebKit\//.test(navigator.userAgent);
 
 namespace = "core_";
 
@@ -82,59 +83,59 @@ testCM("selection", function(cm) {
   cm.setSelection(Pos(0, 4), Pos(2, 2));
   is(cm.somethingSelected());
   eq(cm.getSelection(), "11\n222222\n33");
-  eqPos(cm.getCursor(false), Pos(2, 2));
-  eqPos(cm.getCursor(true), Pos(0, 4));
+  eqCursorPos(cm.getCursor(false), Pos(2, 2));
+  eqCursorPos(cm.getCursor(true), Pos(0, 4));
   cm.setSelection(Pos(1, 0));
   is(!cm.somethingSelected());
   eq(cm.getSelection(), "");
-  eqPos(cm.getCursor(true), Pos(1, 0));
+  eqCursorPos(cm.getCursor(true), Pos(1, 0));
   cm.replaceSelection("abc", "around");
   eq(cm.getSelection(), "abc");
   eq(cm.getValue(), "111111\nabc222222\n333333");
   cm.replaceSelection("def", "end");
   eq(cm.getSelection(), "");
-  eqPos(cm.getCursor(true), Pos(1, 3));
+  eqCursorPos(cm.getCursor(true), Pos(1, 3));
   cm.setCursor(Pos(2, 1));
-  eqPos(cm.getCursor(true), Pos(2, 1));
+  eqCursorPos(cm.getCursor(true), Pos(2, 1));
   cm.setCursor(1, 2);
-  eqPos(cm.getCursor(true), Pos(1, 2));
+  eqCursorPos(cm.getCursor(true), Pos(1, 2));
 }, {value: "111111\n222222\n333333"});
 
 testCM("extendSelection", function(cm) {
   cm.setExtending(true);
   addDoc(cm, 10, 10);
   cm.setSelection(Pos(3, 5));
-  eqPos(cm.getCursor("head"), Pos(3, 5));
-  eqPos(cm.getCursor("anchor"), Pos(3, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(3, 5));
+  eqCursorPos(cm.getCursor("anchor"), Pos(3, 5));
   cm.setSelection(Pos(2, 5), Pos(5, 5));
-  eqPos(cm.getCursor("head"), Pos(5, 5));
-  eqPos(cm.getCursor("anchor"), Pos(2, 5));
-  eqPos(cm.getCursor("start"), Pos(2, 5));
-  eqPos(cm.getCursor("end"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("anchor"), Pos(2, 5));
+  eqCursorPos(cm.getCursor("start"), Pos(2, 5));
+  eqCursorPos(cm.getCursor("end"), Pos(5, 5));
   cm.setSelection(Pos(5, 5), Pos(2, 5));
-  eqPos(cm.getCursor("head"), Pos(2, 5));
-  eqPos(cm.getCursor("anchor"), Pos(5, 5));
-  eqPos(cm.getCursor("start"), Pos(2, 5));
-  eqPos(cm.getCursor("end"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(2, 5));
+  eqCursorPos(cm.getCursor("anchor"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("start"), Pos(2, 5));
+  eqCursorPos(cm.getCursor("end"), Pos(5, 5));
   cm.extendSelection(Pos(3, 2));
-  eqPos(cm.getCursor("head"), Pos(3, 2));
-  eqPos(cm.getCursor("anchor"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(3, 2));
+  eqCursorPos(cm.getCursor("anchor"), Pos(5, 5));
   cm.extendSelection(Pos(6, 2));
-  eqPos(cm.getCursor("head"), Pos(6, 2));
-  eqPos(cm.getCursor("anchor"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(6, 2));
+  eqCursorPos(cm.getCursor("anchor"), Pos(5, 5));
   cm.extendSelection(Pos(6, 3), Pos(6, 4));
-  eqPos(cm.getCursor("head"), Pos(6, 4));
-  eqPos(cm.getCursor("anchor"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(6, 4));
+  eqCursorPos(cm.getCursor("anchor"), Pos(5, 5));
   cm.extendSelection(Pos(0, 3), Pos(0, 4));
-  eqPos(cm.getCursor("head"), Pos(0, 3));
-  eqPos(cm.getCursor("anchor"), Pos(5, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(0, 3));
+  eqCursorPos(cm.getCursor("anchor"), Pos(5, 5));
   cm.extendSelection(Pos(4, 5), Pos(6, 5));
-  eqPos(cm.getCursor("head"), Pos(6, 5));
-  eqPos(cm.getCursor("anchor"), Pos(4, 5));
+  eqCursorPos(cm.getCursor("head"), Pos(6, 5));
+  eqCursorPos(cm.getCursor("anchor"), Pos(4, 5));
   cm.setExtending(false);
   cm.extendSelection(Pos(0, 3), Pos(0, 4));
-  eqPos(cm.getCursor("head"), Pos(0, 3));
-  eqPos(cm.getCursor("anchor"), Pos(0, 4));
+  eqCursorPos(cm.getCursor("head"), Pos(0, 3));
+  eqCursorPos(cm.getCursor("anchor"), Pos(0, 4));
 });
 
 testCM("lines", function(cm) {
@@ -231,7 +232,7 @@ testCM("coordsChar", function(cm) {
         cm.setCursor(line, ch);
         var coords = cm.charCoords(Pos(line, ch), sys);
         var pos = cm.coordsChar({left: coords.left + 1, top: coords.top + 1}, sys);
-        eqPos(pos, Pos(line, ch));
+        eqCharPos(pos, Pos(line, ch));
       }
     }
   }
@@ -344,12 +345,12 @@ testCM("undoSelection", function(cm) {
   cm.replaceSelection("");
   cm.setCursor(Pos(1, 0));
   cm.undo();
-  eqPos(cm.getCursor(true), Pos(0, 2));
-  eqPos(cm.getCursor(false), Pos(0, 4));
+  eqCursorPos(cm.getCursor(true), Pos(0, 2));
+  eqCursorPos(cm.getCursor(false), Pos(0, 4));
   cm.setCursor(Pos(1, 0));
   cm.redo();
-  eqPos(cm.getCursor(true), Pos(0, 2));
-  eqPos(cm.getCursor(false), Pos(0, 2));
+  eqCursorPos(cm.getCursor(true), Pos(0, 2));
+  eqCursorPos(cm.getCursor(false), Pos(0, 2));
 }, {value: "abcdefgh\n"});
 
 testCM("undoSelectionAsBefore", function(cm) {
@@ -413,7 +414,7 @@ testCM("markTextMultiLine", function(cm) {
                         {className: "CodeMirror-matchingbracket"});
     cm.replaceRange(test.c, p(test.a), p(test.b));
     var f = r.find();
-    eqPos(f && f.from, p(test.f)); eqPos(f && f.to, p(test.t));
+    eqCursorPos(f && f.from, p(test.f)); eqCursorPos(f && f.to, p(test.t));
   });
 });
 
@@ -432,16 +433,16 @@ testCM("markTextUndo", function(cm) {
   cm.setValue("");
   eq(marker1.find(), null); eq(marker2.find(), null); eq(bookmark.find(), null);
   cm.undo();
-  eqPos(bookmark.find(), Pos(1, 5), "still there");
+  eqCursorPos(bookmark.find(), Pos(1, 5), "still there");
   cm.undo();
   var m1Pos = marker1.find(), m2Pos = marker2.find();
-  eqPos(m1Pos.from, Pos(0, 1)); eqPos(m1Pos.to, Pos(0, 3));
-  eqPos(m2Pos.from, Pos(0, 0)); eqPos(m2Pos.to, Pos(2, 1));
-  eqPos(bookmark.find(), Pos(1, 5));
+  eqCursorPos(m1Pos.from, Pos(0, 1)); eqCursorPos(m1Pos.to, Pos(0, 3));
+  eqCursorPos(m2Pos.from, Pos(0, 0)); eqCursorPos(m2Pos.to, Pos(2, 1));
+  eqCursorPos(bookmark.find(), Pos(1, 5));
   cm.redo(); cm.redo();
   eq(bookmark.find(), null);
   cm.undo();
-  eqPos(bookmark.find(), Pos(1, 5));
+  eqCursorPos(bookmark.find(), Pos(1, 5));
   eq(cm.getValue(), v1);
 }, {value: "1234\n56789\n00\n"});
 
@@ -491,12 +492,12 @@ testCM("undoPreservesNewMarks", function(cm) {
   var mAfter = cm.markText(Pos(0, 5), Pos(0, 6));
   var mAround = cm.markText(Pos(0, 2), Pos(0, 4));
   cm.undo();
-  eqPos(mBefore.find().from, Pos(0, 0));
-  eqPos(mBefore.find().to, Pos(0, 1));
-  eqPos(mAfter.find().from, Pos(3, 3));
-  eqPos(mAfter.find().to, Pos(3, 4));
-  eqPos(mAround.find().from, Pos(0, 2));
-  eqPos(mAround.find().to, Pos(3, 2));
+  eqCursorPos(mBefore.find().from, Pos(0, 0));
+  eqCursorPos(mBefore.find().to, Pos(0, 1));
+  eqCursorPos(mAfter.find().from, Pos(3, 3));
+  eqCursorPos(mAfter.find().to, Pos(3, 4));
+  eqCursorPos(mAround.find().from, Pos(0, 2));
+  eqCursorPos(mAround.find().to, Pos(3, 2));
   var found = cm.findMarksAt(Pos(2, 2));
   eq(found.length, 1);
   eq(found[0], mAround);
@@ -547,7 +548,7 @@ testCM("bookmark", function(cm) {
     cm.setValue("1234567890\n1234567890\n1234567890");
     var b = cm.setBookmark(p(test.bm) || Pos(1, 5));
     cm.replaceRange(test.c, p(test.a), p(test.b));
-    eqPos(b.find(), p(test.d));
+    eqCursorPos(b.find(), p(test.d));
   });
 });
 
@@ -556,14 +557,14 @@ testCM("bookmarkInsertLeft", function(cm) {
   var bl = cm.setBookmark(Pos(0, 2), {insertLeft: true});
   cm.setCursor(Pos(0, 2));
   cm.replaceSelection("hi");
-  eqPos(br.find(), Pos(0, 2));
-  eqPos(bl.find(), Pos(0, 4));
+  eqCursorPos(br.find(), Pos(0, 2));
+  eqCursorPos(bl.find(), Pos(0, 4));
   cm.replaceRange("", Pos(0, 4), Pos(0, 5));
   cm.replaceRange("", Pos(0, 2), Pos(0, 4));
   cm.replaceRange("", Pos(0, 1), Pos(0, 2));
   // Verify that deleting next to bookmarks doesn't kill them
-  eqPos(br.find(), Pos(0, 1));
-  eqPos(bl.find(), Pos(0, 1));
+  eqCursorPos(br.find(), Pos(0, 1));
+  eqCursorPos(bl.find(), Pos(0, 1));
 }, {value: "abcdef"});
 
 testCM("bookmarkCursor", function(cm) {
@@ -789,15 +790,15 @@ testCM("collapsedLines", function(cm) {
   CodeMirror.on(range, "clear", function() {cleared++;});
   cm.setCursor(Pos(3, 0));
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(5, 0));
+  eqCharPos(cm.getCursor(), Pos(5, 0));
   cm.replaceRange("abcdefg", Pos(3, 0), Pos(3));
   cm.setCursor(Pos(3, 6));
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(5, 4));
+  eqCharPos(cm.getCursor(), Pos(5, 4));
   cm.replaceRange("ab", Pos(3, 0), Pos(3));
   cm.setCursor(Pos(3, 2));
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(5, 2));
+  eqCharPos(cm.getCursor(), Pos(5, 2));
   cm.operation(function() {range.clear(); range.clear();});
   eq(cleared, 1);
 });
@@ -807,14 +808,14 @@ testCM("collapsedRangeCoordsChar", function(cm) {
   pos_1_3.left += 2; pos_1_3.top += 2;
   var opts = {collapsed: true, inclusiveLeft: true, inclusiveRight: true};
   var m1 = cm.markText(Pos(0, 0), Pos(2, 0), opts);
-  eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
+  eqCharPos(cm.coordsChar(pos_1_3), Pos(3, 3));
   m1.clear();
   var m1 = cm.markText(Pos(0, 0), Pos(1, 1), {collapsed: true, inclusiveLeft: true});
   var m2 = cm.markText(Pos(1, 1), Pos(2, 0), {collapsed: true, inclusiveRight: true});
-  eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
+  eqCharPos(cm.coordsChar(pos_1_3), Pos(3, 3));
   m1.clear(); m2.clear();
   var m1 = cm.markText(Pos(0, 0), Pos(1, 6), opts);
-  eqPos(cm.coordsChar(pos_1_3), Pos(3, 3));
+  eqCharPos(cm.coordsChar(pos_1_3), Pos(3, 3));
 }, {value: "123456\nabcdef\nghijkl\nmnopqr\n"});
 
 testCM("collapsedRangeBetweenLinesSelected", function(cm) {
@@ -852,7 +853,7 @@ testCM("hiddenLinesAutoUnfold", function(cm) {
   eq(cleared, 1);
   range = foldLines(cm, 1, 3, true);
   CodeMirror.on(range, "clear", function() {cleared++;});
-  eqPos(cm.getCursor(), Pos(3, 0));
+  eqCursorPos(cm.getCursor(), Pos(3, 0));
   cm.setCursor(Pos(0, 3));
   cm.execCommand("goCharRight");
   eq(cleared, 2);
@@ -863,8 +864,8 @@ testCM("hiddenLinesSelectAll", function(cm) {  // Issue #484
   foldLines(cm, 0, 10);
   foldLines(cm, 11, 20);
   CodeMirror.commands.selectAll(cm);
-  eqPos(cm.getCursor(true), Pos(10, 0));
-  eqPos(cm.getCursor(false), Pos(10, 4));
+  eqCursorPos(cm.getCursor(true), Pos(10, 0));
+  eqCursorPos(cm.getCursor(false), Pos(10, 4));
 });
 
 
@@ -891,9 +892,9 @@ testCM("structuredFold", function(cm) {
   });
   cm.setCursor(0, 3);
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(6, 2));
+  eqCharPos(cm.getCursor(), Pos(6, 2));
   CodeMirror.commands.goCharLeft(cm);
-  eqPos(cm.getCursor(), Pos(1, 2));
+  eqCharPos(cm.getCursor(), Pos(1, 2));
   CodeMirror.commands.delCharAfter(cm);
   eq(cm.getValue(), "xxxx\nxxxx\nxxxx");
   addDoc(cm, 4, 8);
@@ -905,9 +906,9 @@ testCM("structuredFold", function(cm) {
   CodeMirror.on(range, "clear", function(){++cleared;});
   cm.setCursor(0, 3);
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(6, 2));
+  eqCharPos(cm.getCursor(), Pos(6, 2));
   CodeMirror.commands.goCharLeft(cm);
-  eqPos(cm.getCursor(), Pos(6, 1));
+  eqCharPos(cm.getCursor(), Pos(6, 1));
   eq(cleared, 1);
   range.clear();
   eq(cleared, 1);
@@ -918,13 +919,13 @@ testCM("structuredFold", function(cm) {
   range.clear();
   cm.setCursor(1, 2);
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(1, 3));
+  eqCharPos(cm.getCursor(), Pos(1, 3));
   range = cm.markText(Pos(2, 0), Pos(4, 4), {
     replacedWith: document.createTextNode("M")
   });
   cm.setCursor(1, 0);
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(2, 0));
+  eqCharPos(cm.getCursor(), Pos(2, 0));
 }, null);
 
 testCM("nestedFold", function(cm) {
@@ -935,23 +936,23 @@ testCM("nestedFold", function(cm) {
   var inner1 = fold(0, 6, 1, 3), inner2 = fold(0, 2, 1, 8), outer = fold(0, 1, 2, 3), inner0 = fold(0, 5, 0, 6);
   cm.setCursor(0, 1);
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(2, 3));
+  eqCursorPos(cm.getCursor(), Pos(2, 3));
   inner0.clear();
   CodeMirror.commands.goCharLeft(cm);
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   outer.clear();
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2, "before"));
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(1, 8));
+  eqCursorPos(cm.getCursor(), Pos(1, 8));
   inner2.clear();
   CodeMirror.commands.goCharLeft(cm);
-  eqPos(cm.getCursor(), Pos(1, 7));
+  eqCursorPos(cm.getCursor(), Pos(1, 7, "after"));
   cm.setCursor(0, 5);
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(0, 6));
+  eqCursorPos(cm.getCursor(), Pos(0, 6, "before"));
   CodeMirror.commands.goCharRight(cm);
-  eqPos(cm.getCursor(), Pos(1, 3));
+  eqCursorPos(cm.getCursor(), Pos(1, 3));
 });
 
 testCM("badNestedFold", function(cm) {
@@ -1045,13 +1046,13 @@ testCM("inlineWidget", function(cm) {
   var w = cm.setBookmark(Pos(0, 2), {widget: document.createTextNode("uu")});
   cm.setCursor(0, 2);
   CodeMirror.commands.goLineDown(cm);
-  eqPos(cm.getCursor(), Pos(1, 4));
+  eqCharPos(cm.getCursor(), Pos(1, 4));
   cm.setCursor(0, 2);
   cm.replaceSelection("hi");
-  eqPos(w.find(), Pos(0, 2));
+  eqCharPos(w.find(), Pos(0, 2));
   cm.setCursor(0, 1);
   cm.replaceSelection("ay");
-  eqPos(w.find(), Pos(0, 4));
+  eqCharPos(w.find(), Pos(0, 4));
   eq(cm.getLine(0), "uayuhiuu");
 }, {value: "uuuu\nuuuuuu"});
 
@@ -1083,7 +1084,7 @@ testCM("wrappingAndResizing", function(cm) {
            Pos(0, 0), Pos(1, doc.length), Pos(1, doc.length - 1)],
           function(pos) {
     var coords = cm.charCoords(pos);
-    eqPos(pos, cm.coordsChar({left: coords.left + 2, top: coords.top + 5}));
+    eqCharPos(pos, cm.coordsChar({left: coords.left + 2, top: coords.top + 5}));
   });
 }, null, ie_lt8);
 
@@ -1102,13 +1103,13 @@ testCM("measureEndOfLine", function(cm) {
   cm.setValue(cm.getValue() + "\n\n");
   var endPos = cm.charCoords(Pos(0, 18), "local");
   is(endPos.top > lh * .8, "not at top");
-  is(endPos.left > w - 20, "not at right");
+  is(endPos.left > w - 20, "at right");
   endPos = cm.charCoords(Pos(0, 18));
   eqCursorPos(cm.coordsChar({left: endPos.left, top: endPos.top + 5}), Pos(0, 18, "before"));
 
   var wrapPos = cm.cursorCoords(Pos(0, 9, "before"));
   is(wrapPos.top < endPos.top, "wrapPos is actually in first line");
-  eqPos(cm.coordsChar({left: wrapPos.left + 10, top: wrapPos.top}), Pos(0, 9, "before"));
+  eqCursorPos(cm.coordsChar({left: wrapPos.left + 10, top: wrapPos.top}), Pos(0, 9, "before"));
 }, {mode: "text/html", value: "<!-- foo barrr -->", lineWrapping: true}, ie_lt8 || opera_lt10);
 
 testCM("measureWrappedEndOfLine", function(cm) {
@@ -1125,9 +1126,9 @@ testCM("measureWrappedEndOfLine", function(cm) {
   }
   var endPos = cm.charCoords(Pos(0, 12)); // Next-to-last since last would wrap (#1862)
   endPos.left += w; // Add width of editor just to be sure that we are behind last character
-  eqPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
+  eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
   endPos.left += w * 100;
-  eqPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
+  eqCursorPos(cm.coordsChar(endPos), Pos(0, 13, "before"));
 }, {mode: "text/html", value: "0123456789abcde0123456789", lineWrapping: true}, ie_lt8 || opera_lt10);
 
 testCM("scrollVerticallyAndHorizontally", function(cm) {
@@ -1153,7 +1154,7 @@ testCM("moveVstuck", function(cm) {
   }
   cm.setCursor(Pos(0, val.length - 1));
   cm.moveV(-1, "line");
-  eqPos(cm.getCursor(), Pos(0, 27, "before"));
+  eqCursorPos(cm.getCursor(), Pos(0, 27, "before"));
   is(cm.cursorCoords(null, "local").top < h0, "cursor is in first visual line");
 }, {lineWrapping: true}, ie_lt8 || opera_lt10);
 
@@ -1161,24 +1162,24 @@ testCM("collapseOnMove", function(cm) {
   cm.setSelection(Pos(0, 1), Pos(2, 4));
   cm.execCommand("goLineUp");
   is(!cm.somethingSelected());
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCharPos(cm.getCursor(), Pos(0, 1));
   cm.setSelection(Pos(0, 1), Pos(2, 4));
   cm.execCommand("goPageDown");
   is(!cm.somethingSelected());
-  eqPos(cm.getCursor(), Pos(2, 4));
+  eqCharPos(cm.getCursor(), Pos(2, 4));
   cm.execCommand("goLineUp");
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCharPos(cm.getCursor(), Pos(0, 4));
   cm.setSelection(Pos(0, 1), Pos(2, 4));
   cm.execCommand("goCharLeft");
   is(!cm.somethingSelected());
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCharPos(cm.getCursor(), Pos(0, 1));
 }, {value: "aaaaa\nb\nccccc"});
 
 testCM("clickTab", function(cm) {
   var p0 = cm.charCoords(Pos(0, 0));
-  eqPos(cm.coordsChar({left: p0.left + 5, top: p0.top + 5}), Pos(0, 0));
-  eqPos(cm.coordsChar({left: p0.right - 5, top: p0.top + 5}), Pos(0, 1));
+  eqCharPos(cm.coordsChar({left: p0.left + 5, top: p0.top + 5}), Pos(0, 0));
+  eqCharPos(cm.coordsChar({left: p0.right - 5, top: p0.top + 5}), Pos(0, 1));
 }, {value: "\t\n\n", lineWrapping: true, tabSize: 8});
 
 testCM("verticalScroll", function(cm) {
@@ -1230,53 +1231,53 @@ testCM("extraKeys", function(cm) {
 
 testCM("wordMovementCommands", function(cm) {
   cm.execCommand("goWordLeft");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(0, 7));
+  eqCursorPos(cm.getCursor(), Pos(0, 7, "before"));
   cm.execCommand("goWordLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 5, "after"));
   cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(0, 12));
+  eqCursorPos(cm.getCursor(), Pos(0, 12, "before"));
   cm.execCommand("goWordLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 9, "after"));
   cm.execCommand("goWordRight"); cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(0, 24));
+  eqCursorPos(cm.getCursor(), Pos(0, 24, "before"));
   cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(1, 9));
+  eqCursorPos(cm.getCursor(), Pos(1, 9, "before"));
   cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(1, 13));
+  eqCursorPos(cm.getCursor(), Pos(1, 13, "before"));
   cm.execCommand("goWordRight"); cm.execCommand("goWordRight");
-  eqPos(cm.getCursor(), Pos(2, 0));
+  eqCharPos(cm.getCursor(), Pos(2, 0));
 }, {value: "this is (the) firstline.\na foo12\u00e9\u00f8\u00d7bar\n"});
 
 testCM("groupMovementCommands", function(cm) {
   cm.execCommand("goGroupLeft");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCursorPos(cm.getCursor(), Pos(0, 4, "before"));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(0, 7));
+  eqCursorPos(cm.getCursor(), Pos(0, 7, "before"));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(0, 10));
+  eqCursorPos(cm.getCursor(), Pos(0, 10, "before"));
   cm.execCommand("goGroupLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 7, "after"));
   cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(0, 15));
+  eqCursorPos(cm.getCursor(), Pos(0, 15, "before"));
   cm.setCursor(Pos(0, 17));
   cm.execCommand("goGroupLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 16, "after"));
   cm.execCommand("goGroupLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 14, "after"));
   cm.execCommand("goGroupRight"); cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(0, 20));
+  eqCursorPos(cm.getCursor(), Pos(0, 20, "before"));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0, "after"));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(1, 2));
+  eqCursorPos(cm.getCursor(), Pos(1, 2, "before"));
   cm.execCommand("goGroupRight");
-  eqPos(cm.getCursor(), Pos(1, 5));
+  eqCursorPos(cm.getCursor(), Pos(1, 5, "before"));
   cm.execCommand("goGroupLeft"); cm.execCommand("goGroupLeft");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0, "after"));
   cm.execCommand("goGroupLeft");
   eqCursorPos(cm.getCursor(), Pos(0, 20, "after"));
   cm.execCommand("goGroupLeft");
@@ -1288,60 +1289,60 @@ testCM("groupsAndWhitespace", function(cm) {
                    Pos(1, 0), Pos(1, 2), Pos(1, 5)];
   for (var i = 1; i < positions.length; i++) {
     cm.execCommand("goGroupRight");
-    eqPos(cm.getCursor(), positions[i]);
+    eqCharPos(cm.getCursor(), positions[i]);
   }
   for (var i = positions.length - 2; i >= 0; i--) {
     cm.execCommand("goGroupLeft");
-    eqPos(cm.getCursor(), i == 2 ? Pos(0, 6) : positions[i]);
+    eqCharPos(cm.getCursor(), i == 2 ? Pos(0, 6, "before") : positions[i]);
   }
 }, {value: "  foo +++  \n  bar"});
 
 testCM("charMovementCommands", function(cm) {
   cm.execCommand("goCharLeft"); cm.execCommand("goColumnLeft");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goCharRight"); cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2, "before"));
   cm.setCursor(Pos(1, 0));
   cm.execCommand("goColumnLeft");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0));
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(0, 5));
+  eqCursorPos(cm.getCursor(), Pos(0, 5, "before"));
   cm.execCommand("goColumnRight");
-  eqPos(cm.getCursor(), Pos(0, 5));
+  eqCursorPos(cm.getCursor(), Pos(0, 5, "before"));
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0, "after"));
   cm.execCommand("goLineEnd");
-  eqPos(cm.getCursor(), Pos(1, 5));
+  eqCursorPos(cm.getCursor(), Pos(1, 5, "before"));
   cm.execCommand("goLineStartSmart");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCursorPos(cm.getCursor(), Pos(1, 1, "after"));
   cm.execCommand("goLineStartSmart");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0, "after"));
   cm.setCursor(Pos(2, 0));
   cm.execCommand("goCharRight"); cm.execCommand("goColumnRight");
-  eqPos(cm.getCursor(), Pos(2, 0));
+  eqCursorPos(cm.getCursor(), Pos(2, 0));
 }, {value: "line1\n ine2\n"});
 
 testCM("verticalMovementCommands", function(cm) {
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCharPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goLineDown");
   if (!phantom) // This fails in PhantomJS, though not in a real Webkit
-    eqPos(cm.getCursor(), Pos(1, 0));
+    eqCharPos(cm.getCursor(), Pos(1, 0));
   cm.setCursor(Pos(1, 12));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(2, 5));
+  eqCharPos(cm.getCursor(), Pos(2, 5));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(3, 0));
+  eqCharPos(cm.getCursor(), Pos(3, 0));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(2, 5));
+  eqCharPos(cm.getCursor(), Pos(2, 5));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(1, 12));
+  eqCharPos(cm.getCursor(), Pos(1, 12));
   cm.execCommand("goPageDown");
-  eqPos(cm.getCursor(), Pos(5, 0));
+  eqCharPos(cm.getCursor(), Pos(5, 0));
   cm.execCommand("goPageDown"); cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(5, 0));
+  eqCharPos(cm.getCursor(), Pos(5, 0));
   cm.execCommand("goPageUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCharPos(cm.getCursor(), Pos(0, 0));
 }, {value: "line1\nlong long line2\nline3\n\nline5\n"});
 
 testCM("verticalMovementCommandsWrapping", function(cm) {
@@ -1364,30 +1365,30 @@ testCM("verticalMovementCommandsSingleLine", function(cm) {
   cm.display.wrapper.style.height = "auto";
   cm.refresh();
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
   cm.setCursor(Pos(0, 5));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.execCommand("goPageDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
   cm.execCommand("goPageDown"); cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
   cm.execCommand("goPageUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.setCursor(Pos(0, 5));
   cm.execCommand("goPageUp");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   cm.setCursor(Pos(0, 5));
   cm.execCommand("goPageDown");
-  eqPos(cm.getCursor(), Pos(0, 11));
+  eqCursorPos(cm.getCursor(), Pos(0, 11));
 }, {value: "single line"});
 
 
@@ -1396,8 +1397,7 @@ testCM("rtlMovement", function(cm) {
   forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج",
            "خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر", "خ ة ق",
            "<img src=\"/בדיקה3.jpg\">", "يتم السحب في 05 فبراير 2014"], function(line) {
-    var inv = line.charCodeAt(0) > 128;
-    cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart");
+    cm.setValue(line + "\n"); cm.execCommand("goLineStart");
     var cursors = byClassName(cm.getWrapperElement(), "CodeMirror-cursors")[0];
     var cursor = cursors.firstChild;
     var prevX = cursor.offsetLeft, prevY = cursor.offsetTop;
@@ -1408,7 +1408,7 @@ testCM("rtlMovement", function(cm) {
       else is(cursor.offsetLeft > prevX, "moved right");
       prevX = cursor.offsetLeft; prevY = cursor.offsetTop;
     }
-    cm.setCursor(0, 0); cm.execCommand(inv ? "goLineStart" : "goLineEnd");
+    cm.setCursor(0, 0); cm.execCommand("goLineEnd");
     prevX = cursors.firstChild.offsetLeft;
     for (var i = 0; i < line.length; ++i) {
       cm.execCommand("goCharLeft");
@@ -1421,24 +1421,24 @@ testCM("rtlMovement", function(cm) {
 
 // Verify that updating a line clears its bidi ordering
 testCM("bidiUpdate", function(cm) {
-  cm.setCursor(Pos(0, 2));
+  cm.setCursor(Pos(0, 2, "before"));
   cm.replaceSelection("خحج", "start");
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCursorPos(cm.getCursor(), Pos(0, 6, "before"));
 }, {value: "abcd\n"});
 
 testCM("movebyTextUnit", function(cm) {
   cm.setValue("בְּרֵאשִ\nééé́\n");
-  cm.execCommand("goLineEnd");
+  cm.execCommand("goLineStart");
   for (var i = 0; i < 4; ++i) cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0, "after"));
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(1, 0));
+  eqCursorPos(cm.getCursor(), Pos(1, 0, "after"));
   cm.execCommand("goCharRight");
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(1, 4));
+  eqCursorPos(cm.getCursor(), Pos(1, 4, "before"));
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(1, 7));
+  eqCursorPos(cm.getCursor(), Pos(1, 7, "before"));
 });
 
 testCM("lineChangeEvents", function(cm) {
@@ -1478,9 +1478,9 @@ testCM("lineWidgets", function(cm) {
   is(last.top < cm.charCoords(Pos(2, 0)).top, "took up space");
   cm.setCursor(Pos(1, 1));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(2, 1));
+  eqCharPos(cm.getCursor(), Pos(2, 1));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCharPos(cm.getCursor(), Pos(1, 1));
 });
 
 testCM("lineWidgetFocus", function(cm) {
@@ -1604,25 +1604,25 @@ testCM("jumpTheGap", function(cm) {
   cm.refresh();
   cm.setCursor(Pos(0, 1));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCharPos(cm.getCursor(), Pos(1, 1));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(2, 1));
+  eqCharPos(cm.getCursor(), Pos(2, 1));
   cm.execCommand("goLineDown");
   eq(cm.getCursor().line, 2);
   is(cm.getCursor().ch > 1);
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(2, 1));
+  eqCharPos(cm.getCursor(), Pos(2, 1));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCharPos(cm.getCursor(), Pos(1, 1));
   var node = document.createElement("div");
   node.innerHTML = "hi"; node.style.height = "30px";
   cm.addLineWidget(0, node);
   cm.addLineWidget(1, node.cloneNode(true), {above: true});
   cm.setCursor(Pos(0, 2));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(1, 2));
+  eqCharPos(cm.getCursor(), Pos(1, 2));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCharPos(cm.getCursor(), Pos(0, 2));
 }, {lineWrapping: true, value: "abc\ndef\nghi\njkl\n"});
 
 testCM("addLineClass", function(cm) {
@@ -1678,37 +1678,37 @@ testCM("atomicMarker", function(cm) {
   var m = atom(0, 1, 0, 5);
   cm.setCursor(Pos(0, 1));
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(0, 5));
+  eqCursorPos(cm.getCursor(), Pos(0, 5));
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   m.clear();
   m = atom(0, 0, 0, 5, true);
-  eqPos(cm.getCursor(), Pos(0, 5), "pushed out");
+  eqCursorPos(cm.getCursor(), Pos(0, 5), "pushed out");
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(0, 5));
+  eqCursorPos(cm.getCursor(), Pos(0, 5));
   m.clear();
   m = atom(8, 4, 9, 10, false, true);
   cm.setCursor(Pos(9, 8));
-  eqPos(cm.getCursor(), Pos(8, 4), "set");
+  eqCursorPos(cm.getCursor(), Pos(8, 4), "set");
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(8, 4), "char right");
+  eqCursorPos(cm.getCursor(), Pos(8, 4), "char right");
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(8, 4), "line down");
+  eqCursorPos(cm.getCursor(), Pos(8, 4), "line down");
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(8, 3));
+  eqCursorPos(cm.getCursor(), Pos(8, 3, "after"));
   m.clear();
   m = atom(1, 1, 3, 8);
   cm.setCursor(Pos(0, 0));
   cm.setCursor(Pos(2, 0));
-  eqPos(cm.getCursor(), Pos(3, 8));
+  eqCursorPos(cm.getCursor(), Pos(3, 8));
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCursorPos(cm.getCursor(), Pos(1, 1));
   cm.execCommand("goCharRight");
-  eqPos(cm.getCursor(), Pos(3, 8));
+  eqCursorPos(cm.getCursor(), Pos(3, 8));
   cm.execCommand("goLineUp");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCursorPos(cm.getCursor(), Pos(1, 1));
   cm.execCommand("goLineDown");
-  eqPos(cm.getCursor(), Pos(3, 8));
+  eqCursorPos(cm.getCursor(), Pos(3, 8));
   cm.execCommand("delCharBefore");
   eq(cm.getValue().length, 80, "del chunk");
   m = atom(3, 0, 5, 5);
@@ -1720,16 +1720,16 @@ testCM("atomicMarker", function(cm) {
 testCM("selectionBias", function(cm) {
   cm.markText(Pos(0, 1), Pos(0, 3), {atomic: true});
   cm.setCursor(Pos(0, 2));
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   cm.setCursor(Pos(0, 2));
-  eqPos(cm.getCursor(), Pos(0, 3));
+  eqCursorPos(cm.getCursor(), Pos(0, 3));
   cm.setCursor(Pos(0, 2));
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   cm.setCursor(Pos(0, 2), null, {bias: -1});
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   cm.setCursor(Pos(0, 4));
   cm.setCursor(Pos(0, 2), null, {bias: 1});
-  eqPos(cm.getCursor(), Pos(0, 3));
+  eqCursorPos(cm.getCursor(), Pos(0, 3));
 }, {value: "12345"});
 
 testCM("selectionHomeEnd", function(cm) {
@@ -1737,9 +1737,9 @@ testCM("selectionHomeEnd", function(cm) {
   cm.markText(Pos(1, 3), Pos(1, 4), {atomic: true, inclusiveRight: true});
   cm.setCursor(Pos(1, 2));
   cm.execCommand("goLineStart");
-  eqPos(cm.getCursor(), Pos(1, 1));
+  eqCursorPos(cm.getCursor(), Pos(1, 1));
   cm.execCommand("goLineEnd");
-  eqPos(cm.getCursor(), Pos(1, 3));
+  eqCursorPos(cm.getCursor(), Pos(1, 3));
 }, {value: "ab\ncdef\ngh"});
 
 testCM("readOnlyMarker", function(cm) {
@@ -1750,30 +1750,30 @@ testCM("readOnlyMarker", function(cm) {
   var m = mark(0, 1, 0, 4);
   cm.setCursor(Pos(0, 2));
   cm.replaceSelection("hi", "end");
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2));
   eq(cm.getLine(0), "abcde");
   cm.execCommand("selectAll");
   cm.replaceSelection("oops", "around");
   eq(cm.getValue(), "oopsbcd");
   cm.undo();
-  eqPos(m.find().from, Pos(0, 1));
-  eqPos(m.find().to, Pos(0, 4));
+  eqCursorPos(m.find().from, Pos(0, 1));
+  eqCursorPos(m.find().to, Pos(0, 4));
   m.clear();
   cm.setCursor(Pos(0, 2));
   cm.replaceSelection("hi", "around");
   eq(cm.getLine(0), "abhicde");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCursorPos(cm.getCursor(), Pos(0, 4));
   m = mark(0, 2, 2, 2, true);
   cm.setSelection(Pos(1, 1), Pos(2, 4));
   cm.replaceSelection("t", "end");
-  eqPos(cm.getCursor(), Pos(2, 3));
+  eqCursorPos(cm.getCursor(), Pos(2, 3));
   eq(cm.getLine(2), "klto");
   cm.execCommand("goCharLeft");
   cm.execCommand("goCharLeft");
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2));
   cm.setSelection(Pos(0, 1), Pos(0, 3));
   cm.replaceSelection("xx", "around");
-  eqPos(cm.getCursor(), Pos(0, 3));
+  eqCursorPos(cm.getCursor(), Pos(0, 3));
   eq(cm.getLine(0), "axxhicde");
 }, {value: "abcde\nfghij\nklmno\n"});
 
@@ -1817,12 +1817,12 @@ testCM("addKeyMap", function(cm) {
   }
 
   sendKey(39);
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1, "before"));
   var test = 0;
   var map1 = {Right: function() { ++test; }}, map2 = {Right: function() { test += 10; }}
   cm.addKeyMap(map1);
   sendKey(39);
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1, "before"));
   eq(test, 1);
   cm.addKeyMap(map2, true);
   sendKey(39);
@@ -1833,13 +1833,13 @@ testCM("addKeyMap", function(cm) {
   cm.removeKeyMap(map2);
   sendKey(39);
   eq(test, 12);
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2, "before"));
   cm.addKeyMap({Right: function() { test = 55; }, name: "mymap"});
   sendKey(39);
   eq(test, 55);
   cm.removeKeyMap("mymap");
   sendKey(39);
-  eqPos(cm.getCursor(), Pos(0, 3));
+  eqCursorPos(cm.getCursor(), Pos(0, 3, "before"));
 }, {value: "abc"});
 
 testCM("findPosH", function(cm) {
@@ -1847,7 +1847,7 @@ testCM("findPosH", function(cm) {
            {from: Pos(0, 0), to: Pos(0, 0), by: -1, hitSide: true},
            {from: Pos(0, 0), to: Pos(0, 4, "before"), by: 1, unit: "word"},
            {from: Pos(0, 0), to: Pos(0, 8, "before"), by: 2, unit: "word"},
-           {from: Pos(0, 0), to: Pos(2, 0, "before"), by: 20, unit: "word", hitSide: true},
+           {from: Pos(0, 0), to: Pos(2, 0, "after"), by: 20, unit: "word", hitSide: true},
            {from: Pos(0, 7), to: Pos(0, 5, "after"), by: -1, unit: "word"},
            {from: Pos(0, 4), to: Pos(0, 8, "before"), by: 1, unit: "word"},
            {from: Pos(1, 0), to: Pos(1, 18, "before"), by: 3, unit: "word"},
@@ -1856,9 +1856,9 @@ testCM("findPosH", function(cm) {
            {from: Pos(1, 15), to: Pos(1, 10, "after"), by: -5, unit: "column"},
            {from: Pos(1, 15), to: Pos(1, 0, "after"), by: -50, unit: "column", hitSide: true},
            {from: Pos(1, 15), to: Pos(1, 24, "before"), by: 50, unit: "column", hitSide: true},
-           {from: Pos(1, 15), to: Pos(2, 0, "before"), by: 50, hitSide: true}], function(t) {
+           {from: Pos(1, 15), to: Pos(2, 0, "after"), by: 50, hitSide: true}], function(t) {
     var r = cm.findPosH(t.from, t.by, t.unit || "char");
-    eqPos(r, t.to);
+    eqCursorPos(r, t.to);
     eq(!!r.hitSide, !!t.hitSide);
   });
 }, {value: "line one\nline two.something.other\n"});
@@ -1907,10 +1907,10 @@ testCM("beforeSelectionChange", function(cm) {
 
   addDoc(cm, 10, 10);
   cm.execCommand("goLineEnd");
-  eqPos(cm.getCursor(), Pos(0, 9));
+  eqCursorPos(cm.getCursor(), Pos(0, 9));
   cm.execCommand("selectAll");
-  eqPos(cm.getCursor("start"), Pos(0, 0));
-  eqPos(cm.getCursor("end"), Pos(9, 9));
+  eqCursorPos(cm.getCursor("start"), Pos(0, 0));
+  eqCursorPos(cm.getCursor("end"), Pos(9, 9));
 });
 
 testCM("change_removedText", function(cm) {
@@ -2015,17 +2015,17 @@ testCM("selectionHistory", function(cm) {
   eq(cm.getSelection(), "c");
   cm.execCommand("undoSelection");
   eq(cm.getSelection(), "");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCursorPos(cm.getCursor(), Pos(0, 4, "before"));
   cm.execCommand("undoSelection");
   eq(cm.getSelection(), "b");
   cm.execCommand("redoSelection");
   eq(cm.getSelection(), "");
-  eqPos(cm.getCursor(), Pos(0, 4));
+  eqCursorPos(cm.getCursor(), Pos(0, 4, "before"));
   cm.execCommand("redoSelection");
   eq(cm.getSelection(), "c");
   cm.execCommand("redoSelection");
   eq(cm.getSelection(), "");
-  eqPos(cm.getCursor(), Pos(0, 6));
+  eqCursorPos(cm.getCursor(), Pos(0, 6, "before"));
 }, {value: "a b c d"});
 
 testCM("selectionChangeReducesRedo", function(cm) {
@@ -2035,7 +2035,7 @@ testCM("selectionChangeReducesRedo", function(cm) {
   cm.execCommand("selectAll");
   cm.undoSelection();
   eq(cm.getValue(), "Xabc");
-  eqPos(cm.getCursor(), Pos(0, 1));
+  eqCursorPos(cm.getCursor(), Pos(0, 1));
   cm.undoSelection();
   eq(cm.getValue(), "abc");
 }, {value: "abc"});
@@ -2044,8 +2044,8 @@ testCM("selectionHistoryNonOverlapping", function(cm) {
   cm.setSelection(Pos(0, 0), Pos(0, 1));
   cm.setSelection(Pos(0, 2), Pos(0, 3));
   cm.execCommand("undoSelection");
-  eqPos(cm.getCursor("anchor"), Pos(0, 0));
-  eqPos(cm.getCursor("head"), Pos(0, 1));
+  eqCursorPos(cm.getCursor("anchor"), Pos(0, 0));
+  eqCursorPos(cm.getCursor("head"), Pos(0, 1));
 }, {value: "1234"});
 
 testCM("cursorMotionSplitsHistory", function(cm) {
@@ -2055,10 +2055,10 @@ testCM("cursorMotionSplitsHistory", function(cm) {
   cm.replaceSelection("c");
   cm.undo();
   eq(cm.getValue(), "a1234");
-  eqPos(cm.getCursor(), Pos(0, 2));
+  eqCursorPos(cm.getCursor(), Pos(0, 2, "before"));
   cm.undo();
   eq(cm.getValue(), "1234");
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
 }, {value: "1234"});
 
 testCM("selChangeInOperationDoesNotSplit", function(cm) {
@@ -2068,7 +2068,7 @@ testCM("selChangeInOperationDoesNotSplit", function(cm) {
       cm.setCursor(Pos(0, cm.getCursor().ch - 1));
     });
   }
-  eqPos(cm.getCursor(), Pos(0, 0));
+  eqCursorPos(cm.getCursor(), Pos(0, 0));
   eq(cm.getValue(), "xxxxa");
   cm.undo();
   eq(cm.getValue(), "a");
@@ -2220,7 +2220,7 @@ function makeItWrapAfter(cm, pos) {
 
 function testMoveBidi(str) {
   testCM("move_bidi_" + str, function(cm) {
-console.log("TESTING", encodeURIComponent(str))
+    if (cm.getOption("inputStyle") != "textarea" || webkit || !cm.getOption("rtlMoveVisually")) return;
     cm.getScrollerElement().style.fontFamily = "monospace";
     makeItWrapAfter(cm, Pos(0, 5));
 
@@ -2230,7 +2230,6 @@ console.log("TESTING", encodeURIComponent(str))
     if (str.indexOf("\n") != -1) {
       lineBreaks[steps - 2] = 'n';
     }
-console.log("TESTING", str.length, steps, lineBreaks)
 
     // Make sure we are at the visual beginning of the first line
     var pos = Pos(0, 0), lastPos;
@@ -2246,18 +2245,15 @@ console.log("TESTING", str.length, steps, lineBreaks)
       cm.execCommand("goCharRight");
       coords = cm.cursorCoords();
       if ((i >= 10 && i <= 12) && !lineBreaks[i] && coords.left < prevCoords.left && coords.top > prevCoords.top) {
-console.log("MOVED WRAPPED AT>", i)
         // The first line wraps twice
         lineBreaks[i] = 'w';
       }
       if (!lineBreaks[i]) {
         is(coords.left > prevCoords.left, "In step " + i + ", cursor didn't move right");
         eq(coords.top, prevCoords.top, "In step " + i + ", cursor moved out of line");
-console.log("MOVED", i, "right")
       } else {
         is(coords.left < prevCoords.left, i);
         is(coords.top > prevCoords.top, i);
-console.log("MOVED", i, "down")
       }
       prevCoords = coords;
     }
@@ -2273,11 +2269,9 @@ console.log("MOVED", i, "down")
       if (!(lineBreaks[i] == 'n' || lineBreaks[i + 1] == 'w')) {
         is(coords.left < prevCoords.left, "In step " + i + ", cursor didn't move left");
         eq(coords.top, prevCoords.top, "In step " + i + ", cursor is not at the same line anymore");
-console.log("MOVED", i, "left")
       } else {
         is(coords.left > prevCoords.left, i);
         is(coords.top < prevCoords.top, i);
-console.log("MOVED", i, "up")
       }
       prevCoords = coords;
     }
@@ -2289,7 +2283,7 @@ console.log("MOVED", i, "up")
   }, {value: str, lineWrapping: true})
 };
 
-testMoveBidi("Say ا ب جabj\nS"); // https://bugs.webkit.org/show_bug.cgi?id=165753
+testMoveBidi("Say ا ب جabj\nS");
 testMoveBidi("Όȝǝڪȉۥ״ۺ׆ɀҩۏ\nҳ");
 testMoveBidi("ό׊۷٢ԜһОצЉيčǟ\nѩ");
 testMoveBidi("ۑÚҳҕڬġڹհяųKV\nr");
diff --git a/test/vim_test.js b/test/vim_test.js
index d6b0ad16b..acb5ba4be 100644
--- a/test/vim_test.js
+++ b/test/vim_test.js
@@ -174,7 +174,7 @@ function testVim(name, run, opts, expectedFail) {
         } else {
           pos = makeCursor(line, ch);
         }
-        eqPos(pos, cm.getCursor());
+        eqCursorPos(cm.getCursor(), pos);
       }
     }
     function fakeOpenDialog(result) {
@@ -531,14 +531,14 @@ testVim('paragraph_motions', function(cm, vim, helpers) {
   // ip inside empty space
   cm.setCursor(10, 0);
   helpers.doKeys('v', 'i', 'p');
-  eqPos(Pos(7, 0), cm.getCursor('anchor'));
-  eqPos(Pos(12, 0), cm.getCursor('head'));
+  eqCursorPos(Pos(7, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(12, 0), cm.getCursor('head'));
   helpers.doKeys('i', 'p');
-  eqPos(Pos(7, 0), cm.getCursor('anchor'));
-  eqPos(Pos(13, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(7, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(13, 1), cm.getCursor('head'));
   helpers.doKeys('2', 'i', 'p');
-  eqPos(Pos(7, 0), cm.getCursor('anchor'));
-  eqPos(Pos(16, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(7, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(16, 1), cm.getCursor('head'));
 
   // should switch to visualLine mode
   cm.setCursor(14, 0);
@@ -547,31 +547,31 @@ testVim('paragraph_motions', function(cm, vim, helpers) {
 
   cm.setCursor(14, 0);
   helpers.doKeys('<Esc>', 'V', 'i', 'p');
-  eqPos(Pos(16, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(16, 1), cm.getCursor('head'));
 
   // ap inside empty space
   cm.setCursor(10, 0);
   helpers.doKeys('<Esc>', 'v', 'a', 'p');
-  eqPos(Pos(7, 0), cm.getCursor('anchor'));
-  eqPos(Pos(13, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(7, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(13, 1), cm.getCursor('head'));
   helpers.doKeys('a', 'p');
-  eqPos(Pos(7, 0), cm.getCursor('anchor'));
-  eqPos(Pos(16, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(7, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(16, 1), cm.getCursor('head'));
 
   cm.setCursor(13, 0);
   helpers.doKeys('v', 'a', 'p');
-  eqPos(Pos(13, 0), cm.getCursor('anchor'));
-  eqPos(Pos(14, 0), cm.getCursor('head'));
+  eqCursorPos(Pos(13, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(14, 0), cm.getCursor('head'));
 
   cm.setCursor(16, 0);
   helpers.doKeys('v', 'a', 'p');
-  eqPos(Pos(14, 0), cm.getCursor('anchor'));
-  eqPos(Pos(16, 1), cm.getCursor('head'));
+  eqCursorPos(Pos(14, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(16, 1), cm.getCursor('head'));
 
   cm.setCursor(0, 0);
   helpers.doKeys('v', 'a', 'p');
-  eqPos(Pos(0, 0), cm.getCursor('anchor'));
-  eqPos(Pos(4, 0), cm.getCursor('head'));
+  eqCursorPos(Pos(0, 0), cm.getCursor('anchor'));
+  eqCursorPos(Pos(4, 0), cm.getCursor('head'));
 
   cm.setCursor(0, 0);
   helpers.doKeys('d', 'i', 'p');
@@ -593,7 +593,7 @@ testVim('dl', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq(' ', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1 ' });
 testVim('dl_eol', function(cm, vim, helpers) {
   cm.setCursor(0, 6);
@@ -612,7 +612,7 @@ testVim('dl_repeat', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq(' w', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1 ' });
 testVim('dh', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 3);
@@ -622,7 +622,7 @@ testVim('dh', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('o', register.toString());
   is(!register.linewise);
-  eqPos(offsetCursor(curStart, 0 , -1), cm.getCursor());
+  eqCursorPos(offsetCursor(curStart, 0 , -1), cm.getCursor());
 }, { value: ' word1 ' });
 testVim('dj', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 3);
@@ -672,7 +672,7 @@ testVim('dw_space', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq(' ', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1 ' });
 testVim('dw_word', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 1);
@@ -682,7 +682,7 @@ testVim('dw_word', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('word1 ', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1 word2' });
 testVim('dw_unicode_word', function(cm, vim, helpers) {
   helpers.doKeys('d', 'w');
@@ -852,7 +852,7 @@ testVim('d_inclusive', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('word1', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1 ' });
 testVim('d_reverse', function(cm, vim, helpers) {
   // Test that deleting in reverse works.
@@ -940,7 +940,7 @@ testVim('yw_repeat', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('word1\nword2', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1\nword2' });
 testVim('yy_multiply_repeat', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 3);
@@ -953,7 +953,7 @@ testVim('yy_multiply_repeat', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq(expectedBuffer, register.toString());
   is(register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 });
 // Change commands behave like d commands except that it also enters insert
 // mode. In addition, when the change is linewise, an additional newline is
@@ -974,7 +974,7 @@ testVim('cw_repeat', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('word1\nword2', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
   eq('vim-insert', cm.getOption('keyMap'));
 }, { value: ' word1\nword2' });
 testVim('cc_multiply_repeat', function(cm, vim, helpers) {
@@ -1074,7 +1074,7 @@ testVim('g~w_repeat', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1\nword2' });
 testVim('g~g~', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 3);
@@ -1086,7 +1086,7 @@ testVim('g~g~', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
 }, { value: ' word1\nword2\nword3\nword4\nword5\nword6' });
 testVim('gu_and_gU', function(cm, vim, helpers) {
   var curStart = makeCursor(0, 7);
@@ -1094,21 +1094,21 @@ testVim('gu_and_gU', function(cm, vim, helpers) {
   cm.setCursor(curStart);
   helpers.doKeys('2', 'g', 'U', 'w');
   eq(cm.getValue(), 'wa wb xX WC wd');
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
   helpers.doKeys('2', 'g', 'u', 'w');
   eq(cm.getValue(), value);
 
   helpers.doKeys('2', 'g', 'U', 'B');
   eq(cm.getValue(), 'wa WB Xx wc wd');
-  eqPos(makeCursor(0, 3), cm.getCursor());
+  eqCursorPos(makeCursor(0, 3), cm.getCursor());
 
   cm.setCursor(makeCursor(0, 4));
   helpers.doKeys('g', 'u', 'i', 'w');
   eq(cm.getValue(), 'wa wb Xx wc wd');
-  eqPos(makeCursor(0, 3), cm.getCursor());
+  eqCursorPos(makeCursor(0, 3), cm.getCursor());
 
   // TODO: support gUgU guu
-  // eqPos(makeCursor(0, 0), cm.getCursor());
+  // eqCursorPos(makeCursor(0, 0), cm.getCursor());
 
   var register = helpers.getRegisterController().getRegister();
   eq('', register.toString());
@@ -1333,7 +1333,7 @@ testVim('C', function(cm, vim, helpers) {
   var register = helpers.getRegisterController().getRegister();
   eq('rd1', register.toString());
   is(!register.linewise);
-  eqPos(curStart, cm.getCursor());
+  eqCursorPos(curStart, cm.getCursor());
   eq('vim-insert', cm.getOption('keyMap'));
 }, { value: ' word1\nword2\n word3' });
 testVim('Y', function(cm, vim, helpers) {
@@ -1446,7 +1446,7 @@ testVim('i_overwrite_backspace', function(cm, vim, helpers) {
   helpers.doKeys('i');
   helpers.doKeys('<Ins>');
   helpers.doInsertModeKeys('Backspace');
-  helpers.assertCursorAt(0, 9);
+  helpers.assertCursorAt(Pos(0, 9, "after"));
   eq('0123456789', cm.getValue());
 }, { value: '0123456789'});
 testVim('A', function(cm, vim, helpers) {
@@ -1879,7 +1879,7 @@ testVim('delmark_all', function(cm, vim, helpers) {
 testVim('visual', function(cm, vim, helpers) {
   helpers.doKeys('l', 'v', 'l', 'l');
   helpers.assertCursorAt(0, 4);
-  eqPos(makeCursor(0, 1), cm.getCursor('anchor'));
+  eqCursorPos(makeCursor(0, 1), cm.getCursor('anchor'));
   helpers.doKeys('d');
   eq('15', cm.getValue());
 }, { value: '12345' });
@@ -1911,24 +1911,24 @@ testVim('visual_crossover_left', function(cm, vim, helpers) {
 testVim('visual_crossover_up', function(cm, vim, helpers) {
   cm.setCursor(3, 2);
   helpers.doKeys('v', 'j', 'k', 'k');
-  eqPos(Pos(2, 2), cm.getCursor('head'));
-  eqPos(Pos(3, 3), cm.getCursor('anchor'));
+  eqCursorPos(Pos(2, 2), cm.getCursor('head'));
+  eqCursorPos(Pos(3, 3), cm.getCursor('anchor'));
   helpers.doKeys('k');
-  eqPos(Pos(1, 2), cm.getCursor('head'));
-  eqPos(Pos(3, 3), cm.getCursor('anchor'));
+  eqCursorPos(Pos(1, 2), cm.getCursor('head'));
+  eqCursorPos(Pos(3, 3), cm.getCursor('anchor'));
 }, { value: 'cross\ncross\ncross\ncross\ncross\n'});
 testVim('visual_crossover_down', function(cm, vim, helpers) {
   cm.setCursor(1, 2);
   helpers.doKeys('v', 'k', 'j', 'j');
-  eqPos(Pos(2, 3), cm.getCursor('head'));
-  eqPos(Pos(1, 2), cm.getCursor('anchor'));
+  eqCursorPos(Pos(2, 3), cm.getCursor('head'));
+  eqCursorPos(Pos(1, 2), cm.getCursor('anchor'));
   helpers.doKeys('j');
-  eqPos(Pos(3, 3), cm.getCursor('head'));
-  eqPos(Pos(1, 2), cm.getCursor('anchor'));
+  eqCursorPos(Pos(3, 3), cm.getCursor('head'));
+  eqCursorPos(Pos(1, 2), cm.getCursor('anchor'));
 }, { value: 'cross\ncross\ncross\ncross\ncross\n'});
 testVim('visual_exit', function(cm, vim, helpers) {
   helpers.doKeys('<C-v>', 'l', 'j', 'j', '<Esc>');
-  eqPos(cm.getCursor('anchor'), cm.getCursor('head'));
+  eqCursorPos(cm.getCursor('anchor'), cm.getCursor('head'));
   eq(vim.visualMode, false);
 }, { value: 'hello\nworld\nfoo' });
 testVim('visual_line', function(cm, vim, helpers) {
@@ -2011,7 +2011,7 @@ testVim('visual_block_crossing_short_line', function(cm, vim, helpers) {
 testVim('visual_block_curPos_on_exit', function(cm, vim, helpers) {
   cm.setCursor(0, 0);
   helpers.doKeys('<C-v>', '3' , 'l', '<Esc>');
-  eqPos(makeCursor(0, 3), cm.getCursor());
+  eqCursorPos(makeCursor(0, 3), cm.getCursor());
   helpers.doKeys('h', '<C-v>', '2' , 'j' ,'3' , 'l');
   eq(cm.getSelections().join(), "3456,,cdef");
   helpers.doKeys('4' , 'h');
@@ -2046,7 +2046,7 @@ testVim('visual_blank', function(cm, vim, helpers) {
 testVim('reselect_visual', function(cm, vim, helpers) {
   helpers.doKeys('l', 'v', 'l', 'l', 'l', 'y', 'g', 'v');
   helpers.assertCursorAt(0, 5);
-  eqPos(makeCursor(0, 1), cm.getCursor('anchor'));
+  eqCursorPos(makeCursor(0, 1), cm.getCursor('anchor'));
   helpers.doKeys('v');
   cm.setCursor(1, 0);
   helpers.doKeys('v', 'l', 'l', 'p');
@@ -2055,15 +2055,15 @@ testVim('reselect_visual', function(cm, vim, helpers) {
   helpers.doKeys('g', 'v');
   // here the fake cursor is at (1, 3)
   helpers.assertCursorAt(1, 4);
-  eqPos(makeCursor(1, 0), cm.getCursor('anchor'));
+  eqCursorPos(makeCursor(1, 0), cm.getCursor('anchor'));
   helpers.doKeys('v');
   cm.setCursor(2, 0);
   helpers.doKeys('v', 'l', 'l', 'g', 'v');
   helpers.assertCursorAt(1, 4);
-  eqPos(makeCursor(1, 0), cm.getCursor('anchor'));
+  eqCursorPos(makeCursor(1, 0), cm.getCursor('anchor'));
   helpers.doKeys('g', 'v');
   helpers.assertCursorAt(2, 3);
-  eqPos(makeCursor(2, 0), cm.getCursor('anchor'));
+  eqCursorPos(makeCursor(2, 0), cm.getCursor('anchor'));
   eq('123456\n2345\nbar', cm.getValue());
 }, { value: '123456\nfoo\nbar' });
 testVim('reselect_visual_line', function(cm, vim, helpers) {
@@ -2079,14 +2079,14 @@ testVim('reselect_visual_block', function(cm, vim, helpers) {
   helpers.doKeys('<C-v>', 'k', 'h', '<C-v>');
   cm.setCursor(2, 1);
   helpers.doKeys('v', 'l', 'g', 'v');
-  eqPos(Pos(1, 2), vim.sel.anchor);
-  eqPos(Pos(0, 1), vim.sel.head);
+  eqCursorPos(Pos(1, 2), vim.sel.anchor);
+  eqCursorPos(Pos(0, 1), vim.sel.head);
   // Ensure selection is done with visual block mode rather than one
   // continuous range.
   eq(cm.getSelections().join(''), '23oo')
   helpers.doKeys('g', 'v');
-  eqPos(Pos(2, 1), vim.sel.anchor);
-  eqPos(Pos(2, 2), vim.sel.head);
+  eqCursorPos(Pos(2, 1), vim.sel.anchor);
+  eqCursorPos(Pos(2, 2), vim.sel.head);
   helpers.doKeys('<Esc>');
   // Ensure selection of deleted range
   cm.setCursor(1, 1);
@@ -2121,14 +2121,14 @@ testVim('o_visual', function(cm, vim, helpers) {
 testVim('o_visual_block', function(cm, vim, helpers) {
   cm.setCursor(0, 1);
   helpers.doKeys('<C-v>','3','j','l','l', 'o');
-  eqPos(Pos(3, 3), vim.sel.anchor);
-  eqPos(Pos(0, 1), vim.sel.head);
+  eqCursorPos(Pos(3, 3), vim.sel.anchor);
+  eqCursorPos(Pos(0, 1), vim.sel.head);
   helpers.doKeys('O');
-  eqPos(Pos(3, 1), vim.sel.anchor);
-  eqPos(Pos(0, 3), vim.sel.head);
+  eqCursorPos(Pos(3, 1), vim.sel.anchor);
+  eqCursorPos(Pos(0, 3), vim.sel.head);
   helpers.doKeys('o');
-  eqPos(Pos(0, 3), vim.sel.anchor);
-  eqPos(Pos(3, 1), vim.sel.head);
+  eqCursorPos(Pos(0, 3), vim.sel.anchor);
+  eqCursorPos(Pos(3, 1), vim.sel.head);
 }, { value: 'abcd\nefgh\nijkl\nmnop'});
 testVim('changeCase_visual', function(cm, vim, helpers) {
   cm.setCursor(0, 0);
@@ -4068,7 +4068,7 @@ testVim('ex_map_key2key_from_colon', function(cm, vim, helpers) {
 // Test event handlers
 testVim('beforeSelectionChange', function(cm, vim, helpers) {
   cm.setCursor(0, 100);
-  eqPos(cm.getCursor('head'), cm.getCursor('anchor'));
+  eqCursorPos(cm.getCursor('head'), cm.getCursor('anchor'));
 }, { value: 'abc' });
 
 
-- 
GitLab