Commit 4fc706d7 authored by hluk's avatar hluk Committed by hjk

FakeVim: Don't handle user mapping in some commands

Don't handle user mappings in commands that cannot be followed by
movement command. For example, key "<SPACE>" in after "t" command cannot
be handled as user mapping.

Change-Id: I97582d23ae637b30b1058b9d2b381a869bbebb79
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 7b885b58
......@@ -2291,6 +2291,15 @@ void FakeVimPlugin::test_map()
data.setText("abc" N "def");
data.doCommand(QString::fromUtf8("no \xc3\xb8 l|no l k|no k j|no j h"));
KEYS(QString::fromUtf8("\xc3\xb8"), "a" X "bc" N "def");
// Don't handle mapping in sub-modes that are not followed by movement command.
data.setText("abc" N "def");
data.doCommand("map <SPACE> A<cr>xy z<esc><left><left>");
KEYS("<space>", "abc" N "x" X "y z" N "def");
KEYS("r<space>", "abc" N "x" X " z" N "def");
KEYS("f<space>", "abc" N "x " X " z" N "def");
KEYS("t<space>", "abc" N "x " X " z" N "def");
data.doCommand("unmap <SPACE>");
}
void FakeVimPlugin::test_vim_command_cc()
......
......@@ -2489,7 +2489,15 @@ void FakeVimHandler::Private::endMapping()
bool FakeVimHandler::Private::canHandleMapping()
{
return m_subsubmode != SearchSubSubMode
// Don't handle user mapping in sub-modes that cannot be followed by movement and in "noremap".
return m_subsubmode == NoSubSubMode
&& m_submode != RegisterSubMode
&& m_submode != WindowSubMode
&& m_submode != ZSubMode
&& m_submode != CapitalZSubMode
&& m_submode != ReplaceSubMode
&& m_submode != MacroRecordSubMode
&& m_submode != MacroExecuteSubMode
&& (g.mapStates.isEmpty() || !g.mapStates.last().noremap);
}
......
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