Commit de33b3af authored by Lukas Holecek's avatar Lukas Holecek Committed by hjk

FakeVim: Properly replay macro with command line

Change-Id: I40617a1f6d28052e3593c186afb6db1d14222076
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 3ebdcdc7
......@@ -3476,6 +3476,25 @@ void FakeVimPlugin::test_macros()
data.setText(" abc xyz>." N " def xyz>." N " ghi xyz>." N " jkl xyz>.");
KEYS("qq" "^wdf>j" "q", " abc ." N " def " X "xyz>." N " ghi xyz>." N " jkl xyz>.");
KEYS("2@q", " abc ." N " def ." N " ghi ." N " jkl " X "xyz>.");
// record command line
data.setText("abc" N "def");
KEYS("qq" ":s/./*/g<ESC>" "iX<ESC>" "q", X "Xabc" N "def");
KEYS("@q", X "XXabc" N "def");
KEYS("qq" ":s/./*/g<BS><BS><BS><BS><BS><BS><BS><BS>" "iY<ESC>" "q", X "YXXabc" N "def");
KEYS("@q", X "YYXXabc" N "def");
KEYS("qq" ":s/./*/g<CR>" "q", X "*******" N "def");
KEYS("j@q", "*******" N X "***");
// record repeating last command
data.setText("abc" N "def");
KEYS(":s/./-/g<CR>", X "---" N "def");
KEYS("u", X "abc" N "def");
KEYS("qq" ":<UP><CR>" "q", X "---" N "def");
KEYS(":s/./!/g<CR>", X "!!!" N "def");
KEYS("j@q", "!!!" N X "!!!");
}
void FakeVimPlugin::test_vim_qtcreator()
......
......@@ -1856,6 +1856,7 @@ public:
Q_SLOT void onContentsChanged(int position, int charsRemoved, int charsAdded);
Q_SLOT void onUndoCommandAdded();
bool isCommandLineMode() const { return g.mode == ExMode || g.subsubmode == SearchSubSubMode; }
bool isInsertMode() const { return g.mode == InsertMode || g.mode == ReplaceMode; }
// Waiting for movement operator.
bool isOperatorPending() const {
......@@ -2283,7 +2284,7 @@ void FakeVimHandler::Private::focus()
commitCursor();
}
bool exitCommandLine = (g.subsubmode == SearchSubSubMode || g.mode == ExMode);
bool exitCommandLine = isCommandLineMode();
resetCommandMode();
if (exitCommandLine)
updateMiniBuffer();
......@@ -7892,6 +7893,9 @@ void FakeVimHandler::Private::enterVisualInsertMode(QChar command)
void FakeVimHandler::Private::enterCommandMode(Mode returnToMode)
{
if (g.isRecording && isCommandLineMode())
record(Input(Key_Escape, NoModifier));
if (isNoVisualMode() && atEndOfLine())
moveLeft();
g.mode = CommandMode;
......
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