Skip to content

Commit 472e859

Browse files
committed
patch 8.0.0035
Problem: Order of matches for 'omnifunc' is messed up. (Danny Su) Solution: Do not set compl_curr_match when called from complete_check(). (closes #1168)
1 parent 9e507ca commit 472e859

12 files changed

Lines changed: 141 additions & 73 deletions

File tree

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ test1 \
20472047
test40 test41 test42 test43 test44 test45 test48 test49 \
20482048
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
20492049
test60 test64 test65 test66 test67 test68 test69 \
2050-
test70 test72 test73 test74 test75 test76 test77 test78 test79 \
2050+
test70 test72 test73 test74 test75 test77 test78 test79 \
20512051
test80 test82 test83 test84 test85 test86 test87 test88 test89 \
20522052
test90 test91 test92 test93 test94 test95 test97 test98 test99 \
20532053
test100 test101 test103 test104 test107 test108:

src/edit.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ static void ins_compl_add_dict(dict_T *dict);
179179
#endif
180180
static int ins_compl_get_exp(pos_T *ini);
181181
static void ins_compl_delete(void);
182-
static void ins_compl_insert(void);
183-
static int ins_compl_next(int allow_get_expansion, int count, int insert_match);
182+
static void ins_compl_insert(int in_compl_func);
183+
static int ins_compl_next(int allow_get_expansion, int count, int insert_match, int in_compl_func);
184184
static int ins_compl_key2dir(int c);
185185
static int ins_compl_pum_key(int c);
186186
static int ins_compl_key2count(int c);
@@ -861,7 +861,7 @@ edit(
861861
&& (c == CAR || c == K_KENTER || c == NL)))
862862
{
863863
ins_compl_delete();
864-
ins_compl_insert();
864+
ins_compl_insert(FALSE);
865865
}
866866
}
867867
}
@@ -3297,7 +3297,7 @@ ins_compl_files(
32973297
break;
32983298
}
32993299
line_breakcheck();
3300-
ins_compl_check_keys(50);
3300+
ins_compl_check_keys(50, FALSE);
33013301
}
33023302
fclose(fp);
33033303
}
@@ -4036,8 +4036,6 @@ ins_compl_next_buf(buf_T *buf, int flag)
40364036
}
40374037

40384038
#ifdef FEAT_COMPL_FUNC
4039-
static void expand_by_function(int type, char_u *base);
4040-
40414039
/*
40424040
* Execute user defined complete function 'completefunc' or 'omnifunc', and
40434041
* get matches in "matches".
@@ -4596,7 +4594,7 @@ ins_compl_get_exp(pos_T *ini)
45964594
break;
45974595
/* Fill the popup menu as soon as possible. */
45984596
if (type != -1)
4599-
ins_compl_check_keys(0);
4597+
ins_compl_check_keys(0, FALSE);
46004598

46014599
if ((ctrl_x_mode != 0 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode))
46024600
|| compl_interrupted)
@@ -4653,9 +4651,12 @@ ins_compl_delete(void)
46534651
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
46544652
}
46554653

4656-
/* Insert the new text being completed. */
4654+
/*
4655+
* Insert the new text being completed.
4656+
* "in_compl_func" is TRUE when called from complete_check().
4657+
*/
46574658
static void
4658-
ins_compl_insert(void)
4659+
ins_compl_insert(int in_compl_func)
46594660
{
46604661
dict_T *dict;
46614662

@@ -4682,7 +4683,8 @@ ins_compl_insert(void)
46824683
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
46834684
}
46844685
set_vim_var_dict(VV_COMPLETED_ITEM, dict);
4685-
compl_curr_match = compl_shown_match;
4686+
if (!in_compl_func)
4687+
compl_curr_match = compl_shown_match;
46864688
}
46874689

46884690
/*
@@ -4706,7 +4708,8 @@ ins_compl_next(
47064708
int allow_get_expansion,
47074709
int count, /* repeat completion this many times; should
47084710
be at least 1 */
4709-
int insert_match) /* Insert the newly selected match */
4711+
int insert_match, /* Insert the newly selected match */
4712+
int in_compl_func) /* called from complete_check() */
47104713
{
47114714
int num_matches = -1;
47124715
int i;
@@ -4856,7 +4859,7 @@ ins_compl_next(
48564859
else if (insert_match)
48574860
{
48584861
if (!compl_get_longest || compl_used_match)
4859-
ins_compl_insert();
4862+
ins_compl_insert(in_compl_func);
48604863
else
48614864
ins_bytes(compl_leader + ins_compl_len());
48624865
}
@@ -4921,9 +4924,11 @@ ins_compl_next(
49214924
* mode. Also, when compl_pending is not zero, show a completion as soon as
49224925
* possible. -- webb
49234926
* "frequency" specifies out of how many calls we actually check.
4927+
* "in_compl_func" is TRUE when called from complete_check(), don't set
4928+
* compl_curr_match.
49244929
*/
49254930
void
4926-
ins_compl_check_keys(int frequency)
4931+
ins_compl_check_keys(int frequency, int in_compl_func)
49274932
{
49284933
static int count = 0;
49294934

@@ -4949,7 +4954,7 @@ ins_compl_check_keys(int frequency)
49494954
c = safe_vgetc(); /* Eat the character */
49504955
compl_shows_dir = ins_compl_key2dir(c);
49514956
(void)ins_compl_next(FALSE, ins_compl_key2count(c),
4952-
c != K_UP && c != K_DOWN);
4957+
c != K_UP && c != K_DOWN, in_compl_func);
49534958
}
49544959
else
49554960
{
@@ -4972,7 +4977,7 @@ ins_compl_check_keys(int frequency)
49724977
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
49734978

49744979
compl_pending = 0;
4975-
(void)ins_compl_next(FALSE, todo, TRUE);
4980+
(void)ins_compl_next(FALSE, todo, TRUE, in_compl_func);
49764981
}
49774982
}
49784983

@@ -5490,7 +5495,8 @@ ins_complete(int c, int enable_pum)
54905495
* Find next match (and following matches).
54915496
*/
54925497
save_w_wrow = curwin->w_wrow;
5493-
n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
5498+
n = ins_compl_next(TRUE, ins_compl_key2count(c),
5499+
ins_compl_use_match(c), FALSE);
54945500

54955501
/* may undisplay the popup menu */
54965502
ins_compl_upd_pum();

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
21752175
int saved = RedrawingDisabled;
21762176

21772177
RedrawingDisabled = 0;
2178-
ins_compl_check_keys(0);
2178+
ins_compl_check_keys(0, TRUE);
21792179
rettv->vval.v_number = compl_interrupted;
21802180
RedrawingDisabled = saved;
21812181
}

src/proto/edit.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ char_u *find_word_start(char_u *ptr);
1515
char_u *find_word_end(char_u *ptr);
1616
int ins_compl_active(void);
1717
int ins_compl_add_tv(typval_T *tv, int dir);
18-
void ins_compl_check_keys(int frequency);
18+
void ins_compl_check_keys(int frequency, int in_compl_func);
1919
int get_literal(void);
2020
void insertchar(int c, int flags, int second_indent);
2121
void auto_format(int trailblank, int prev_line);

src/search.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5429,7 +5429,7 @@ find_pattern_in_path(
54295429
line_breakcheck();
54305430
#ifdef FEAT_INS_EXPAND
54315431
if (action == ACTION_EXPAND)
5432-
ins_compl_check_keys(30);
5432+
ins_compl_check_keys(30, FALSE);
54335433
if (got_int || compl_interrupted)
54345434
#else
54355435
if (got_int)

src/spell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8694,7 +8694,7 @@ spell_dump_compl(
86948694
/* Done all bytes at this node, go up one level. */
86958695
--depth;
86968696
line_breakcheck();
8697-
ins_compl_check_keys(50);
8697+
ins_compl_check_keys(50, FALSE);
86988698
}
86998699
else
87008700
{

src/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ find_tags(
15871587
fast_breakcheck();
15881588
#ifdef FEAT_INS_EXPAND
15891589
if ((flags & TAG_INS_COMP)) /* Double brackets for gcc */
1590-
ins_compl_check_keys(30);
1590+
ins_compl_check_keys(30, FALSE);
15911591
if (got_int || compl_interrupted)
15921592
#else
15931593
if (got_int)

src/testdir/Make_all.mak

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ SCRIPTS_ALL = \
5555
test70.out \
5656
test73.out \
5757
test75.out \
58-
test76.out \
5958
test77.out \
6059
test79.out \
6160
test80.out \

src/testdir/test76.in

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/testdir/test76.ok

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)