mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.4848: local completion with mappings and simplification not working
Problem: Local completion with mappings and simplification not working.
Solution: Fix local completion <C-N>/<C-P> mappings not ignored if keys are
not simplified. (closes vim/vim#10323)
ee44603069
This commit is contained in:
parent
db355ca4e5
commit
0b12f6d7be
@ -1769,8 +1769,8 @@ static int put_string_in_typebuf(int offset, int slen, char_u *string, int new_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the bytes at the start of the typeahead buffer are a character used
|
/// Check if the bytes at the start of the typeahead buffer are a character used
|
||||||
/// in CTRL-X mode. This includes the form with a CTRL modifier.
|
/// in Insert mode completion. This includes the form with a CTRL modifier.
|
||||||
static bool at_ctrl_x_key(void)
|
static bool at_ins_compl_key(void)
|
||||||
{
|
{
|
||||||
char_u *p = typebuf.tb_buf + typebuf.tb_off;
|
char_u *p = typebuf.tb_buf + typebuf.tb_off;
|
||||||
int c = *p;
|
int c = *p;
|
||||||
@ -1778,7 +1778,8 @@ static bool at_ctrl_x_key(void)
|
|||||||
if (typebuf.tb_len > 3 && c == K_SPECIAL && p[1] == KS_MODIFIER && (p[2] & MOD_MASK_CTRL)) {
|
if (typebuf.tb_len > 3 && c == K_SPECIAL && p[1] == KS_MODIFIER && (p[2] & MOD_MASK_CTRL)) {
|
||||||
c = p[3] & 0x1f;
|
c = p[3] & 0x1f;
|
||||||
}
|
}
|
||||||
return vim_is_ctrl_x_key(c);
|
return (ctrl_x_mode_not_default() && vim_is_ctrl_x_key(c))
|
||||||
|
|| ((compl_cont_status & CONT_LOCAL) && (c == Ctrl_N || c == Ctrl_P));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if typebuf.tb_buf[] contains a modifer plus key that can be changed
|
/// Check if typebuf.tb_buf[] contains a modifer plus key that can be changed
|
||||||
@ -1883,9 +1884,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
|
|||||||
&& !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' '))
|
&& !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' '))
|
||||||
&& State != ASKMORE
|
&& State != ASKMORE
|
||||||
&& State != CONFIRM
|
&& State != CONFIRM
|
||||||
&& !((ctrl_x_mode_not_default() && at_ctrl_x_key())
|
&& !at_ins_compl_key()) {
|
||||||
|| ((compl_cont_status & CONT_LOCAL)
|
|
||||||
&& (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))) {
|
|
||||||
if (tb_c1 == K_SPECIAL) {
|
if (tb_c1 == K_SPECIAL) {
|
||||||
nolmaplen = 2;
|
nolmaplen = 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,6 +325,21 @@ func Test_compl_vim_cmds_after_register_expr()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_compl_ignore_mappings()
|
||||||
|
call setline(1, ['foo', 'bar', 'baz', 'foobar'])
|
||||||
|
inoremap <C-P> (C-P)
|
||||||
|
inoremap <C-N> (C-N)
|
||||||
|
normal! G
|
||||||
|
call feedkeys("o\<C-X>\<C-N>\<C-N>\<C-N>\<C-P>\<C-N>\<C-Y>", 'tx')
|
||||||
|
call assert_equal('baz', getline('.'))
|
||||||
|
" Also test with unsimplified keys
|
||||||
|
call feedkeys("o\<C-X>\<*C-N>\<*C-N>\<*C-N>\<*C-P>\<*C-N>\<C-Y>", 'tx')
|
||||||
|
call assert_equal('baz', getline('.'))
|
||||||
|
iunmap <C-P>
|
||||||
|
iunmap <C-N>
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func DummyCompleteOne(findstart, base)
|
func DummyCompleteOne(findstart, base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user