0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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 #10323)
This commit is contained in:
zeertzjq
2022-04-30 15:02:22 +01:00
committed by Bram Moolenaar
parent a5d3590505
commit ee44603069
3 changed files with 22 additions and 6 deletions

View File

@@ -2342,10 +2342,10 @@ typedef enum {
/* /*
* 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 int static int
at_ctrl_x_key(void) 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;
@@ -2355,7 +2355,8 @@ at_ctrl_x_key(void)
&& p[1] == KS_MODIFIER && p[1] == KS_MODIFIER
&& (p[2] & MOD_MASK_CTRL)) && (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_status_local() && (c == Ctrl_N || c == Ctrl_P));
} }
/* /*
@@ -2486,9 +2487,7 @@ handle_mapping(
&& !(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_status_local()
&& (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P))))
{ {
#ifdef FEAT_GUI #ifdef FEAT_GUI
if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2 if (gui.in_use && tb_c1 == CSI && typebuf.tb_len >= 2

View File

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

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4848,
/**/ /**/
4847, 4847,
/**/ /**/