From c71c338e72bd30f20fcc49cec47b65a5371fa514 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Aum=C3=BCller?= <aumuell@reserv.at>
Date: Tue, 5 Jan 2010 18:42:26 +0100
Subject: [PATCH] fakevim: common implementation of 'G' and 'gg'

Merge-request: 96
Reviewed-by: hjk <qtc-committer@nokia.com>
---
 src/plugins/fakevim/fakevimhandler.cpp | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index d3d0586c03c..7085d8dc555 100755
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -1381,21 +1381,25 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
         m_subsubmode = FtSubSubMode;
         m_movetype = MoveExclusive;
         m_subsubdata = key;
-    } else if (key == 'g') {
-        if (m_gflag) {
+    } else if (key == 'g' && !m_gflag) {
+        m_gflag = true;
+    } else if (key == 'g' || key == 'G') {
+        QString dotCommand = key + m_mvcount;
+        if (key == 'g')
             m_gflag = false;
-            int n = m_mvcount.isEmpty() ? 1 : count();
+        int n = (key == 'g') ? 1 : linesInDocument();
+        n = m_mvcount.isEmpty() ? n : count();
+        if (m_submode == NoSubMode || m_submode == ZSubMode
+                || m_submode == CapitalZSubMode || m_submode == RegisterSubMode) {
             m_tc.setPosition(firstPositionInLine(n), KeepAnchor);
             handleStartOfLine();
-            finishMovement();
         } else {
-            m_gflag = true;
+            m_movetype = MoveLineWise;
+            m_rangemode = RangeLineMode;
+            setAnchor();
+            m_tc.setPosition(firstPositionInLine(n), KeepAnchor);
         }
-    } else if (key == 'G') {
-        int n = m_mvcount.isEmpty() ? linesInDocument() : count();
-        m_tc.setPosition(firstPositionInLine(n), KeepAnchor);
-        handleStartOfLine();
-        finishMovement();
+        finishMovement(dotCommand);
     } else if (key == 'h' || key == Key_Left
             || key == Key_Backspace || key == control('h')) {
         int n = qMin(count(), leftDist());
-- 
GitLab