mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0021: i_CTRL-R- doesn't work for multibyte chars in Replace mode
Problem: i_CTRL-R- doesn't work for multibyte chars in Replace mode,
Coverity complains missing return value for u_save_cursor()
Solution: Use mb_charlen() and del_chars() instead, handle failure mode
for u_save_cursor() correctly (@zeertzjq)
closes: vim/vim#13846
424ec1f235
This commit is contained in:
parent
2783b6b0a4
commit
64a50d08c4
@ -1286,7 +1286,10 @@ int insert_reg(int regname, bool literally_arg)
|
||||
if ((State & REPLACE_FLAG) != 0) {
|
||||
pos_T curpos;
|
||||
u_save_cursor();
|
||||
del_bytes((colnr_T)strlen(reg->y_array[0]), true, false);
|
||||
if (u_save_cursor() == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
del_chars(mb_charlen(reg->y_array[0]), true);
|
||||
curpos = curwin->w_cursor;
|
||||
if (oneright() == FAIL) {
|
||||
// hit end of line, need to put forward (after the current position)
|
||||
|
@ -907,6 +907,18 @@ func Test_insert_small_delete_replace_mode()
|
||||
let @- = ''
|
||||
exe ":norm! R\<C-R>-ZZZ"
|
||||
call assert_equal(['ZZZ', 'foofoo', '', 'bfoobarZZZZ'], getline(1, 4))
|
||||
let @- = 'βbβ'
|
||||
call cursor(4, 1)
|
||||
exe ":norm! R\<C-R>-"
|
||||
call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4))
|
||||
let @- = 'bβb'
|
||||
call cursor(4, 1)
|
||||
exe ":norm! R\<C-R>-"
|
||||
call assert_equal(['ZZZ', 'foofoo', '', 'bβbobarZZZZ'], getline(1, 4))
|
||||
let @- = 'βbβ'
|
||||
call cursor(4, 1)
|
||||
exe ":norm! R\<C-R>-"
|
||||
call assert_equal(['ZZZ', 'foofoo', '', 'βbβobarZZZZ'], getline(1, 4))
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user