aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/getchar.c4
-rw-r--r--test/functional/insert/ctrl_r_spec.lua19
2 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index b83681ad01..3b248c4bc6 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -302,13 +302,13 @@ static void add_num_buff(buffheader_T *buf, long n)
*/
static void add_char_buff(buffheader_T *buf, int c)
{
- char bytes[MB_MAXBYTES + 1];
+ uint8_t bytes[MB_MAXBYTES + 1];
int len;
if (IS_SPECIAL(c)) {
len = 1;
} else {
- len = (*mb_char2bytes)(c, (char_u *)bytes);
+ len = mb_char2bytes(c, bytes);
}
for (int i = 0; i < len; i++) {
diff --git a/test/functional/insert/ctrl_r_spec.lua b/test/functional/insert/ctrl_r_spec.lua
new file mode 100644
index 0000000000..adc3c4b406
--- /dev/null
+++ b/test/functional/insert/ctrl_r_spec.lua
@@ -0,0 +1,19 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear, feed = helpers.clear, helpers.feed
+local expect, command = helpers.expect, helpers.command
+
+describe('insert-mode Ctrl-R', function()
+ before_each(clear)
+
+ it('works', function()
+ command("let @@ = 'test'")
+ feed('i<C-r>"')
+ expect('test')
+ end)
+
+ it('works with multi-byte text', function()
+ command("let @@ = 'påskägg'")
+ feed('i<C-r>"')
+ expect('påskägg')
+ end)
+end)