ops: fix i<c-r> with multi-byte text (#6524)

This commit is contained in:
Björn Linse 2017-04-15 11:19:40 +02:00 committed by Justin M. Keyes
parent 58d2ce9bdb
commit 12fc1defd6
2 changed files with 21 additions and 2 deletions

View File

@ -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++) {

View File

@ -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)