aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/edit.c5
-rw-r--r--test/functional/insert/last_inserted_spec.lua22
2 files changed, 27 insertions, 0 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index ecc794fb14..0de8177467 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -844,6 +844,11 @@ static int insert_handle_key(InsertState *s)
return 0; // exit insert mode
+ case ' ':
+ if (mod_mask != 4) {
+ goto normalchar;
+ }
+ // FALLTHROUGH
case K_ZERO: // Insert the previously inserted text.
case NUL:
case Ctrl_A:
diff --git a/test/functional/insert/last_inserted_spec.lua b/test/functional/insert/last_inserted_spec.lua
new file mode 100644
index 0000000000..dce23a3790
--- /dev/null
+++ b/test/functional/insert/last_inserted_spec.lua
@@ -0,0 +1,22 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local expect = helpers.expect
+
+clear()
+
+describe('insert-mode', function()
+ it('CTRL-@ inserts last-inserted text, leaves insert-mode', function()
+ insert('hello')
+ feed('i<C-@>x')
+ expect('hellhello')
+ end)
+ -- C-Space is the same as C-@
+ it('CTRL-SPC inserts last-inserted text, leaves insert-mode', function()
+ feed('i<C-Space>x')
+ expect('hellhellhello')
+ end)
+ it('CTRL-A inserts last inserted text', function()
+ feed('i<C-A>x')
+ expect('hellhellhellhelloxo')
+ end)
+end)