diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 44928aef5040da4d8684f9f59ea35c12c8542fab..f8d1e01a6a38e5358a96332cc78f2710080296ca 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -4853,7 +4853,8 @@ int FakeVimHandler::Private::blockBoundary(const QString &left,
             tc1 = document()->find(begin, tc1, flags);
         }
 
-        while (level > 0 && (closing ? (tc2 < tc1) : (tc1 < tc2))) {
+        while (level > 0
+               && (tc1.isNull() || (closing ? (tc2 < tc1) : (tc1 < tc2)))) {
             --level;
             tc2 = document()->find(end, tc2, flags);
             if (tc2.isNull())
@@ -5158,7 +5159,7 @@ void FakeVimHandler::Private::selectBlockTextObject(bool inner,
         p2 -= sright.size() - 1;
     }
 
-    setAnchorAndPosition(p2, p1);
+    setAnchorAndPosition(p1, p2);
     m_movetype = MoveInclusive;
 }