fakevim: fix undo of 'J'

This commit is contained in:
hjk
2009-11-19 08:36:21 +01:00
parent bfb01f4162
commit aa3b274a93
2 changed files with 27 additions and 7 deletions

View File

@@ -1178,7 +1178,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_passing = !m_passing; m_passing = !m_passing;
updateMiniBuffer(); updateMiniBuffer();
} else if (key == '.') { } else if (key == '.') {
//qDebug() << "REPEATING" << quoteUnprintable(m_dotCommand); //qDebug() << "REPEATING" << quoteUnprintable(m_dotCommand) << count();
QString savedCommand = m_dotCommand; QString savedCommand = m_dotCommand;
m_dotCommand.clear(); m_dotCommand.clear();
replay(savedCommand, count()); replay(savedCommand, count());
@@ -1366,6 +1366,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} }
finishMovement("j"); finishMovement("j");
} else if (key == 'J') { } else if (key == 'J') {
setDotCommand("%1J", count());
beginEditBlock();
if (m_submode == NoSubMode) { if (m_submode == NoSubMode) {
for (int i = qMax(count(), 2) - 1; --i >= 0; ) { for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
moveToEndOfLine(); moveToEndOfLine();
@@ -1380,6 +1382,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
if (!m_gflag) if (!m_gflag)
moveLeft(); moveLeft();
} }
endEditBlock();
finishMovement();
} else if (key == 'k' || key == Key_Up) { } else if (key == 'k' || key == Key_Up) {
if (m_submode == NoSubMode || m_submode == ZSubMode if (m_submode == NoSubMode || m_submode == ZSubMode
|| m_submode == CapitalZSubMode || m_submode == RegisterSubMode) { || m_submode == CapitalZSubMode || m_submode == RegisterSubMode) {

View File

@@ -56,26 +56,27 @@ public slots:
private slots: private slots:
// command mode // command mode
void command_Cxx_down_dot();
void command_Gyyp();
void command_J();
void command_Yp();
void command_cc(); void command_cc();
void command_cw(); void command_cw();
void command_dw();
void command_dd(); void command_dd();
void command_dd_2(); void command_dd_2();
void command_dfx_down();
void command_dollar(); void command_dollar();
void command_down(); void command_down();
void command_dfx_down(); void command_dw();
void command_Cxx_down_dot();
void command_e(); void command_e();
void command_i(); void command_i();
void command_left(); void command_left();
void command_ma_yank();
void command_r(); void command_r();
void command_right(); void command_right();
void command_up(); void command_up();
void command_w(); void command_w();
void command_yyp(); void command_yyp();
void command_Yp();
void command_Gyyp();
void command_ma_yank();
// special tests // special tests
void test_i_cw_i(); void test_i_cw_i();
@@ -525,6 +526,21 @@ return; // FIXME: not in sync with Gui behaviour?
check("iaa" + escape, l[0] + "\nxya@ay" + lmid(1)); check("iaa" + escape, l[0] + "\nxya@ay" + lmid(1));
} }
void tst_FakeVim::command_J()
{
setup();
move("4j4l", "int @main");
check("J", lmid(0, 5) + "@ " + lmid(5));
check("u", lmid(0, 4) + "\nint @main(int argc, char *argv[])\n" + lmid(5));
checkEx("redo", lmid(0, 5) + "@ " + lmid(5));
return; // FIXME: not in sync with Gui behaviour?
check("3J", lmid(0, 5) + " " + lmid(5, 1) + "@" + lmid(6).mid(3));
check("u", lmid(0, 4) + "\nint @main(int argc, char *argv[])\n" + lmid(5));
checkEx("redo", lmid(0, 5) + "@ " + lmid(5));
}
/* /*