From aa6c55260fe2823f549ebcab90f41af46c3926db Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 5 May 2009 09:06:36 +0200 Subject: [PATCH] fakevim: better cursor poistioning after indenting --- src/plugins/fakevim/fakevimhandler.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 7a1d4a4246c..6c61fe38e47 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -698,8 +698,10 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) } else if (m_submode == ReplaceSubMode) { m_submode = NoSubMode; } else if (m_submode == IndentSubMode) { + recordJump(); indentRegion(); m_submode = NoSubMode; + updateMiniBuffer(); } else if (m_submode == ShiftRightSubMode) { recordJump(); shiftRegionRight(1); @@ -2057,8 +2059,13 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar) int endLine = lineForPosition(position()); if (beginLine > endLine) qSwap(beginLine, endLine); + int amount = 0; emit q->indentRegion(&amount, beginLine, endLine, typedChar); + + setPosition(firstPositionInLine(beginLine)); + moveToFirstNonBlankOnLine(); + setTargetColumn(); setDotCommand("%1==", endLine - beginLine + 1); } @@ -2072,8 +2079,6 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) QString indent(len, ' '); int firstPos = firstPositionInLine(beginLine); - //setPosition(firstPos); - for (int line = beginLine; line <= endLine; ++line) { setPosition(firstPositionInLine(line)); m_tc.insertText(indent); @@ -2081,6 +2086,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) setPosition(firstPos); moveToFirstNonBlankOnLine(); + setTargetColumn(); setDotCommand("%1>>", endLine - beginLine + 1); } @@ -2094,8 +2100,6 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) int tab = config(ConfigTabStop).toInt(); int firstPos = firstPositionInLine(beginLine); - //setPosition(firstPos); - for (int line = beginLine; line <= endLine; ++line) { int pos = firstPositionInLine(line); setPosition(pos); @@ -2118,6 +2122,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) setPosition(firstPos); moveToFirstNonBlankOnLine(); + setTargetColumn(); setDotCommand("%1<<", endLine - beginLine + 1); } -- GitLab