FakeVim: Remember that cursor is at the end of line

Change-Id: I62098a409028593664b813931d5974de5e787993
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Lukas Holecek
2013-01-16 17:49:37 +01:00
committed by hjk
parent 402affa9c2
commit 2622eb2415
2 changed files with 14 additions and 1 deletions

View File

@@ -421,6 +421,13 @@ void FakeVimPlugin::test_vim_movement()
data.setText("abc def" N "ghi"); data.setText("abc def" N "ghi");
KEYS("$a", "abc def" X N "ghi"); KEYS("$a", "abc def" X N "ghi");
data.setText("abc" N "def ghi");
KEYS("i<end><down>", "abc" N "def ghi" X);
data.setText("abc" N "def ghi");
KEYS("<end>i<down>", "abc" N "de" X "f ghi");
data.setText("abc" N "def ghi");
KEYS("<end>a<down>", "abc" N "def" X " ghi");
// paragraph movement // paragraph movement
data.setText("abc" N N "def"); data.setText("abc" N N "def");
KEYS("}", "abc" N X N "def"); KEYS("}", "abc" N X N "def");

View File

@@ -4220,6 +4220,7 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input)
moveBehindEndOfLine(); moveBehindEndOfLine();
move = true; move = true;
setTargetColumn(); setTargetColumn();
m_targetColumn = -1;
} else if (input.isReturn() || input.isControl('j') || input.isControl('m')) { } else if (input.isReturn() || input.isControl('j') || input.isControl('m')) {
joinPreviousEditBlock(); joinPreviousEditBlock();
m_submode = NoSubMode; m_submode = NoSubMode;
@@ -6686,7 +6687,12 @@ void FakeVimHandler::Private::enterInsertMode()
m_subsubmode = NoSubSubMode; m_subsubmode = NoSubSubMode;
m_lastInsertion.clear(); m_lastInsertion.clear();
m_oldPosition = position(); m_oldPosition = position();
if (g.returnToMode != InsertMode) {
g.returnToMode = InsertMode; g.returnToMode = InsertMode;
// If entering insert mode from command mode, m_targetColumn shouldn't be -1 (end of line).
if (m_targetColumn == -1)
setTargetColumn();
}
} }
void FakeVimHandler::Private::initVisualBlockInsertMode(QChar command) void FakeVimHandler::Private::initVisualBlockInsertMode(QChar command)