diff --git a/plugin/snake/__init__.py b/plugin/snake/__init__.py index 13ee227..f146505 100644 --- a/plugin/snake/__init__.py +++ b/plugin/snake/__init__.py @@ -456,7 +456,10 @@ def wrapped(): fn = wrapped call = register_fn(fn) - command("%s %s :%s %s" % (map_command, key, PYTHON_CMD, call)) + if mode == INSERT_MODE: + command("%s %s :%s %s" % (map_command, key, PYTHON_CMD, call)) + else: + command("%s %s :%s %s" % (map_command, key, PYTHON_CMD, call)) else: command("%s %s %s" % (map_command, key, maybe_fn)) diff --git a/tests.py b/tests.py index fab6355..93d11b4 100644 --- a/tests.py +++ b/tests.py @@ -439,6 +439,17 @@ def process(stuff): self.assertEqual(output, "quick") self.assertEqual(changed, "The really fast brown fox jumps over the lazy dog") + def test_insert_key_map(self): + script = r""" +@key_map("a", mode=INSERT_MODE) +def change_words_and_move(): + replace_word('Test') + keys('1w') + +keys("aaaa") +""" + changed, output = run_vim(script, self.sample_text) + self.assertEqual(changed, "Test Test Test Test jumps over the lazy dog") class OptionsTests(VimTests):