Commit 9a224d7e authored by hjk's avatar hjk
Browse files

Fixes: fakevim: 'r' and 'R' revisited

parent cabc2da9
...@@ -105,7 +105,7 @@ enum SubMode ...@@ -105,7 +105,7 @@ enum SubMode
ChangeSubMode, ChangeSubMode,
DeleteSubMode, DeleteSubMode,
FilterSubMode, FilterSubMode,
ReplaceSubMode, // used for R ReplaceSubMode, // used for R and r
YankSubMode, YankSubMode,
IndentSubMode, IndentSubMode,
ZSubMode, ZSubMode,
...@@ -113,12 +113,13 @@ enum SubMode ...@@ -113,12 +113,13 @@ enum SubMode
enum SubSubMode enum SubSubMode
{ {
// typically used for things that require one more data item
// and are 'nested' behind a mode
NoSubSubMode, NoSubSubMode,
FtSubSubMode, // used for f, F, t, T FtSubSubMode, // used for f, F, t, T
MarkSubSubMode, // used for m MarkSubSubMode, // used for m
BackTickSubSubMode, // used for ` BackTickSubSubMode, // used for `
TickSubSubMode, // used for ' TickSubSubMode, // used for '
ReplaceSubSubMode // used for r
}; };
enum VisualMode enum VisualMode
...@@ -633,12 +634,6 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -633,12 +634,6 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveDown(count()); moveDown(count());
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
finishMovement("y"); finishMovement("y");
} else if (m_submode == ReplaceSubMode) {
if (atEol())
moveLeft();
else
m_tc.deleteChar();
recordInsertText(text);
} else if (m_submode == IndentSubMode && key == '=') { } else if (m_submode == IndentSubMode && key == '=') {
indentRegion(m_tc.block(), m_tc.block().next()); indentRegion(m_tc.block(), m_tc.block().next());
finishMovement(); finishMovement();
...@@ -656,7 +651,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -656,7 +651,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
handleFfTt(key); handleFfTt(key);
m_subsubmode = NoSubSubMode; m_subsubmode = NoSubSubMode;
finishMovement(QString(QChar(m_subsubdata)) + QChar(key)); finishMovement(QString(QChar(m_subsubdata)) + QChar(key));
} else if (m_subsubmode == ReplaceSubSubMode) { } else if (m_submode == ReplaceSubMode) {
if (count() < rightDist() && text.size() == 1 if (count() < rightDist() && text.size() == 1
&& (text.at(0).isPrint() || text.at(0).isSpace())) { && (text.at(0).isPrint() || text.at(0).isSpace())) {
recordBeginGroup(); recordBeginGroup();
...@@ -666,11 +661,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -666,11 +661,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
recordInsertText(QString(count(), text.at(0))); recordInsertText(QString(count(), text.at(0)));
recordEndGroup(); recordEndGroup();
m_moveType = MoveExclusive; m_moveType = MoveExclusive;
m_subsubmode = NoSubSubMode; m_submode = NoSubMode;
m_dotCommand = QString("%1r%2").arg(count()).arg(text); m_dotCommand = QString("%1r%2").arg(count()).arg(text);
finishMovement(); finishMovement();
} else { } else {
m_subsubmode = NoSubSubMode; m_submode = NoSubMode;
} }
} else if (m_subsubmode == MarkSubSubMode) { } else if (m_subsubmode == MarkSubSubMode) {
m_marks[key] = m_tc.position(); m_marks[key] = m_tc.position();
...@@ -947,10 +942,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -947,10 +942,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
recordEndGroup(); recordEndGroup();
m_dotCommand = "p"; m_dotCommand = "p";
} else if (key == 'r') { } else if (key == 'r') {
m_subsubmode = ReplaceSubSubMode; m_submode = ReplaceSubMode;
m_dotCommand = "r"; m_dotCommand = "r";
} else if (key == 'R') { } else if (key == 'R') {
// FIXME: right now we repeat the insertion count() times,
// but not the deletion
recordBeginGroup(); recordBeginGroup();
m_lastInsertion.clear();
m_mode = InsertMode; m_mode = InsertMode;
m_submode = ReplaceSubMode; m_submode = ReplaceSubMode;
m_dotCommand = "R"; m_dotCommand = "R";
......
Supports Markdown
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