mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.1533 #5320
Problem: Using feedkeys() with an empty string disregards 'x' option.
Solution: Make 'x' work with an empty string. (Thinca)
When integrating the patch to nvim, used same logic but different code
based on nvim codebase. New test passed.
74c5bbf134
This commit is contained in:
parent
ca65514a24
commit
c4c2969624
@ -59,10 +59,6 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
|
||||
bool typed = false;
|
||||
bool execute = false;
|
||||
|
||||
if (keys.size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < mode.size; ++i) {
|
||||
switch (mode.data[i]) {
|
||||
case 'n': remap = false; break;
|
||||
@ -73,6 +69,10 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
|
||||
}
|
||||
}
|
||||
|
||||
if (keys.size == 0 && !execute) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *keys_esc;
|
||||
if (escape_csi) {
|
||||
// Need to escape K_SPECIAL and CSI before putting the string in the
|
||||
|
@ -8831,14 +8831,13 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return;
|
||||
|
||||
keys = get_tv_string(&argvars[0]);
|
||||
if (*keys != NUL) {
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
flags = get_tv_string_buf(&argvars[1], nbuf);
|
||||
}
|
||||
|
||||
nvim_feedkeys(cstr_as_string((char *)keys),
|
||||
cstr_as_string((char *)flags), true);
|
||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||
flags = get_tv_string_buf(&argvars[1], nbuf);
|
||||
}
|
||||
|
||||
nvim_feedkeys(cstr_as_string((char *)keys),
|
||||
cstr_as_string((char *)flags), true);
|
||||
}
|
||||
|
||||
/// "filereadable()" function
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
source test_assign.vim
|
||||
source test_cursor_func.vim
|
||||
source test_feedkeys.vim
|
||||
source test_cmdline.vim
|
||||
source test_menu.vim
|
||||
source test_popup.vim
|
||||
|
10
src/nvim/testdir/test_feedkeys.vim
Normal file
10
src/nvim/testdir/test_feedkeys.vim
Normal file
@ -0,0 +1,10 @@
|
||||
" Test feedkeys() function.
|
||||
|
||||
func Test_feedkeys_x_with_empty_string()
|
||||
new
|
||||
call feedkeys("ifoo\<Esc>")
|
||||
call assert_equal('', getline('.'))
|
||||
call feedkeys('', 'x')
|
||||
call assert_equal('foo', getline('.'))
|
||||
quit!
|
||||
endfunc
|
@ -745,7 +745,7 @@ static int included_patches[] = {
|
||||
// 1536 NA
|
||||
// 1535,
|
||||
// 1534 NA
|
||||
// 1533,
|
||||
1533,
|
||||
// 1532 NA
|
||||
// 1531 NA
|
||||
// 1530 NA
|
||||
|
Loading…
Reference in New Issue
Block a user