mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 9.1.1498: completion: 'complete' funcs behave different to 'omnifunc'
Problem: completion: Functions specified in the 'complete' option did not have the leader string removed when called with findstart = 0, unlike 'omnifunc' behavior Solution: update behaviour and make behaviour consistent (Girish Palya) closes: #17636 Signed-off-by: Girish Palya <girishji@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
e92989b07a
commit
fa16c7ab3f
@ -250,7 +250,7 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg);
|
|||||||
static void ins_compl_add_list(list_T *list);
|
static void ins_compl_add_list(list_T *list);
|
||||||
static void ins_compl_add_dict(dict_T *dict);
|
static void ins_compl_add_dict(dict_T *dict);
|
||||||
static int get_userdefined_compl_info(colnr_T curs_col, callback_T *cb, int *startcol);
|
static int get_userdefined_compl_info(colnr_T curs_col, callback_T *cb, int *startcol);
|
||||||
static void get_cpt_func_completion_matches(callback_T *cb);
|
static void get_cpt_func_completion_matches(callback_T *cb, int restore_leader);
|
||||||
static callback_T *get_callback_if_cpt_func(char_u *p);
|
static callback_T *get_callback_if_cpt_func(char_u *p);
|
||||||
# endif
|
# endif
|
||||||
static int setup_cpt_sources(void);
|
static int setup_cpt_sources(void);
|
||||||
@ -4807,20 +4807,6 @@ get_callback_if_cpt_func(char_u *p)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve new completion matches by invoking callback "cb".
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
expand_cpt_function(callback_T *cb)
|
|
||||||
{
|
|
||||||
// Re-insert the text removed by ins_compl_delete().
|
|
||||||
ins_compl_insert_bytes(compl_orig_text.string + get_compl_len(), -1);
|
|
||||||
// Get matches
|
|
||||||
get_cpt_func_completion_matches(cb);
|
|
||||||
// Undo insertion
|
|
||||||
ins_compl_delete();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4984,7 +4970,7 @@ get_next_completion_match(int type, ins_compl_next_state_T *st, pos_T *ini)
|
|||||||
#ifdef FEAT_COMPL_FUNC
|
#ifdef FEAT_COMPL_FUNC
|
||||||
case CTRL_X_FUNCTION:
|
case CTRL_X_FUNCTION:
|
||||||
if (ctrl_x_mode_normal()) // Invoked by a func in 'cpt' option
|
if (ctrl_x_mode_normal()) // Invoked by a func in 'cpt' option
|
||||||
expand_cpt_function(st->func_cb);
|
get_cpt_func_completion_matches(st->func_cb, TRUE);
|
||||||
else
|
else
|
||||||
expand_by_function(type, compl_pattern.string, NULL);
|
expand_by_function(type, compl_pattern.string, NULL);
|
||||||
break;
|
break;
|
||||||
@ -6989,16 +6975,23 @@ remove_old_matches(void)
|
|||||||
*/
|
*/
|
||||||
#ifdef FEAT_COMPL_FUNC
|
#ifdef FEAT_COMPL_FUNC
|
||||||
static void
|
static void
|
||||||
get_cpt_func_completion_matches(callback_T *cb UNUSED)
|
get_cpt_func_completion_matches(callback_T *cb UNUSED, int restore_leader)
|
||||||
{
|
{
|
||||||
int startcol = cpt_sources_array[cpt_sources_index].cs_startcol;
|
int startcol = cpt_sources_array[cpt_sources_index].cs_startcol;
|
||||||
|
int result;
|
||||||
|
|
||||||
VIM_CLEAR_STRING(cpt_compl_pattern);
|
VIM_CLEAR_STRING(cpt_compl_pattern);
|
||||||
|
|
||||||
if (startcol == -2 || startcol == -3)
|
if (startcol == -2 || startcol == -3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (set_compl_globals(startcol, curwin->w_cursor.col, TRUE) == OK)
|
if (restore_leader) // Re-insert the text removed by ins_compl_delete()
|
||||||
|
ins_compl_insert_bytes(compl_orig_text.string + get_compl_len(), -1);
|
||||||
|
result = set_compl_globals(startcol, curwin->w_cursor.col, TRUE);
|
||||||
|
if (restore_leader)
|
||||||
|
ins_compl_delete(); // Undo insertion
|
||||||
|
|
||||||
|
if (result == OK)
|
||||||
{
|
{
|
||||||
expand_by_function(0, cpt_compl_pattern.string, cb);
|
expand_by_function(0, cpt_compl_pattern.string, cb);
|
||||||
cpt_sources_array[cpt_sources_index].cs_refresh_always =
|
cpt_sources_array[cpt_sources_index].cs_refresh_always =
|
||||||
@ -7051,7 +7044,7 @@ cpt_compl_refresh(void)
|
|||||||
}
|
}
|
||||||
cpt_sources_array[cpt_sources_index].cs_startcol = startcol;
|
cpt_sources_array[cpt_sources_index].cs_startcol = startcol;
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
get_cpt_func_completion_matches(cb);
|
get_cpt_func_completion_matches(cb, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,8 +592,8 @@ func Test_cpt_func_cursorcol()
|
|||||||
call assert_equal(8, col('.'))
|
call assert_equal(8, col('.'))
|
||||||
return col('.')
|
return col('.')
|
||||||
endif
|
endif
|
||||||
call assert_equal("foo bar", getline(1))
|
call assert_equal("foo ", getline(1))
|
||||||
call assert_equal(8, col('.'))
|
call assert_equal(5, col('.'))
|
||||||
return v:none
|
return v:none
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@ -719,6 +719,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 */
|
||||||
|
/**/
|
||||||
|
1498,
|
||||||
/**/
|
/**/
|
||||||
1497,
|
1497,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user