Commit 76f57c86 authored by hjk's avatar hjk
Browse files

fakevim: fix behaviour of 'r' at end of line

parent e94cefc6
......@@ -957,19 +957,20 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
.arg(QChar(m_semicolonType))
.arg(QChar(m_semicolonKey)));
} else if (m_submode == ReplaceSubMode) {
if (count() < rightDist() && text.size() == 1
if (count() <= (rightDist() + atEndOfLine()) && text.size() == 1
&& (text.at(0).isPrint() || text.at(0).isSpace())) {
if (atEndOfLine())
moveLeft();
setAnchor();
moveRight(count());
removeSelectedText();
QString rem = removeSelectedText();
m_tc.insertText(QString(count(), text.at(0)));
m_moveType = MoveExclusive;
m_submode = NoSubMode;
setDotCommand("%1r" + text, count());
finishMovement();
} else {
m_submode = NoSubMode;
}
setTargetColumn();
m_submode = NoSubMode;
finishMovement();
} else if (m_subsubmode == MarkSubSubMode) {
m_marks[key] = m_tc.position();
m_subsubmode = NoSubSubMode;
......
......@@ -63,6 +63,7 @@ private slots:
void command_e();
void command_i();
void command_left();
void command_r();
void command_right();
void command_up();
void command_w();
......@@ -325,12 +326,12 @@ void tst_FakeVim::command_i()
check("ixxx" + escape, "xx@x" + lines);
check("u", "@" + lines);
return;
// combine insertions
check("ia" + escape, "@a" + lines);
check("ibx" + escape, "b@xa" + lines);
check("icyy" + escape, "bcy@yxa" + lines);
return; // FIXME
check("u", "b@xa" + lines);
check("u", "@a" + lines); // undo broken
checkEx("redo", "b@xa" + lines);
......@@ -344,11 +345,26 @@ void tst_FakeVim::command_left()
move("4j", "@int main");
move("h", "@int main"); // no move over left border
move("$", "argv[])@");
move("h", "argv[]@)");
//move("h", "argv[]@)");
check("h", lmid(0, 4) + "\nint main(int argc, char *argv[]@)\n" + lmid(5));
move("3h", "arg@v[])");
move("50h", "@int main");
}
void tst_FakeVim::command_r()
{
setup();
move("4j", "@int main");
move("$", "int main(int argc, char *argv[])@");
check("rx", lmid(0, 4) + "\nint main(int argc, char *argv[]x@\n" + lmid(5));
check("2h", lmid(0, 4) + "\nint main(int argc, char *argv[@]x\n" + lmid(5));
check("4ra", lmid(0, 4) + "\nint main(int argc, char *argv[@]x\n" + lmid(5));
return; // FIXME
check("3rb", lmid(0, 4) + "\nint main(int argc, char *argv[bb@b\n" + lmid(5));
check("2rc", lmid(0, 4) + "\nint main(int argc, char *argv[bb@b\n" + lmid(5));
check("h2rc",lmid(0, 4) + "\nint main(int argc, char *argv[bc@c\n" + lmid(5));
}
void tst_FakeVim::command_right()
{
setup();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment