Skip to content

Commit a77a9b2

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 265671c + 869e352 commit a77a9b2

File tree

5 files changed

+63
-26
lines changed

5 files changed

+63
-26
lines changed

src/edit.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,9 +2808,6 @@ set_completion(colnr_T startcol, list_T *list)
28082808
ins_compl_prep(' ');
28092809
ins_compl_clear();
28102810

2811-
if (stop_arrow() == FAIL)
2812-
return;
2813-
28142811
compl_direction = FORWARD;
28152812
if (startcol > curwin->w_cursor.col)
28162813
startcol = curwin->w_cursor.col;
@@ -3890,7 +3887,8 @@ ins_compl_prep(int c)
38903887
/* put the cursor on the last char, for 'tw' formatting */
38913888
if (prev_col > 0)
38923889
dec_cursor();
3893-
if (stop_arrow() == OK)
3890+
/* only format when something was inserted */
3891+
if (!arrow_used && !ins_need_undo)
38943892
insertchar(NUL, 0, -1);
38953893
if (prev_col > 0
38963894
&& ml_get_curline()[curwin->w_cursor.col] != NUL)

src/screen.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7786,6 +7786,10 @@ next_search_hl(
77867786
}
77877787
}
77887788

7789+
/*
7790+
* If there is a match fill "shl" and return one.
7791+
* Return zero otherwise.
7792+
*/
77897793
static int
77907794
next_search_hl_pos(
77917795
match_T *shl, /* points to a match */
@@ -7794,55 +7798,52 @@ next_search_hl_pos(
77947798
colnr_T mincol) /* minimal column for a match */
77957799
{
77967800
int i;
7797-
int bot = -1;
7801+
int found = -1;
77987802

7799-
shl->lnum = 0;
78007803
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
78017804
{
78027805
llpos_T *pos = &posmatch->pos[i];
78037806

78047807
if (pos->lnum == 0)
78057808
break;
7806-
if (pos->col + pos->len - 1 <= mincol)
7809+
if (pos->len == 0 && pos->col < mincol)
78077810
continue;
78087811
if (pos->lnum == lnum)
78097812
{
7810-
if (shl->lnum == lnum)
7813+
if (found >= 0)
78117814
{
7812-
/* partially sort positions by column numbers
7813-
* on the same line */
7814-
if (pos->col < posmatch->pos[bot].col)
7815+
/* if this match comes before the one at "found" then swap
7816+
* them */
7817+
if (pos->col < posmatch->pos[found].col)
78157818
{
78167819
llpos_T tmp = *pos;
78177820

7818-
*pos = posmatch->pos[bot];
7819-
posmatch->pos[bot] = tmp;
7821+
*pos = posmatch->pos[found];
7822+
posmatch->pos[found] = tmp;
78207823
}
78217824
}
78227825
else
7823-
{
7824-
bot = i;
7825-
shl->lnum = lnum;
7826-
}
7826+
found = i;
78277827
}
78287828
}
78297829
posmatch->cur = 0;
7830-
if (shl->lnum == lnum && bot >= 0)
7830+
if (found >= 0)
78317831
{
7832-
colnr_T start = posmatch->pos[bot].col == 0
7833-
? 0 : posmatch->pos[bot].col - 1;
7834-
colnr_T end = posmatch->pos[bot].col == 0
7835-
? MAXCOL : start + posmatch->pos[bot].len;
7832+
colnr_T start = posmatch->pos[found].col == 0
7833+
? 0 : posmatch->pos[found].col - 1;
7834+
colnr_T end = posmatch->pos[found].col == 0
7835+
? MAXCOL : start + posmatch->pos[found].len;
78367836

7837+
shl->lnum = lnum;
78377838
shl->rm.startpos[0].lnum = 0;
78387839
shl->rm.startpos[0].col = start;
78397840
shl->rm.endpos[0].lnum = 0;
78407841
shl->rm.endpos[0].col = end;
78417842
shl->is_addpos = TRUE;
7842-
posmatch->cur = bot + 1;
7843-
return TRUE;
7843+
posmatch->cur = found + 1;
7844+
return 1;
78447845
}
7845-
return FALSE;
7846+
return 0;
78467847
}
78477848
#endif
78487849

src/testdir/test_match.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ func Test_matchaddpos()
191191
call assert_equal(screenattr(2,2), screenattr(1,7))
192192
call assert_notequal(screenattr(2,2), screenattr(1,8))
193193

194+
call clearmatches()
195+
call matchaddpos('Error', [[1], [2,2]])
196+
redraw!
197+
call assert_equal(screenattr(2,2), screenattr(1,1))
198+
call assert_equal(screenattr(2,2), screenattr(1,10))
199+
call assert_notequal(screenattr(2,2), screenattr(1,11))
200+
194201
nohl
202+
call clearmatches()
195203
syntax off
196204
set hlsearch&
197205
endfunc

src/testdir/test_popup.vim

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func DummyCompleteFour(findstart, base)
378378
endif
379379
endfunc
380380

381-
:"Test that 'completefunc' works when it's OK.
381+
" Test that 'completefunc' works when it's OK.
382382
func Test_omnifunc_with_check()
383383
new
384384
setlocal omnifunc=DummyCompleteFour
@@ -400,4 +400,30 @@ func Test_omnifunc_with_check()
400400
q!
401401
endfunc
402402

403+
function UndoComplete()
404+
call complete(1, ['January', 'February', 'March',
405+
\ 'April', 'May', 'June', 'July', 'August', 'September',
406+
\ 'October', 'November', 'December'])
407+
return ''
408+
endfunc
409+
410+
" Test that no undo item is created when no completion is inserted
411+
func Test_complete_no_undo()
412+
set completeopt=menu,preview,noinsert,noselect
413+
inoremap <Right> <C-R>=UndoComplete()<CR>
414+
new
415+
call feedkeys("ixxx\<CR>\<CR>yyy\<Esc>k", 'xt')
416+
call feedkeys("iaaa\<Esc>0", 'xt')
417+
call assert_equal('aaa', getline(2))
418+
call feedkeys("i\<Right>\<Esc>", 'xt')
419+
call assert_equal('aaa', getline(2))
420+
call feedkeys("u", 'xt')
421+
call assert_equal('', getline(2))
422+
423+
iunmap <Right>
424+
set completeopt&
425+
q!
426+
endfunc
427+
428+
403429
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
41,
784+
/**/
785+
40,
782786
/**/
783787
39,
784788
/**/

0 commit comments

Comments
 (0)