diff options
author | Michael Ennen <mike.ennen@gmail.com> | 2016-12-06 17:21:12 -0700 |
---|---|---|
committer | Michael Ennen <mike.ennen@gmail.com> | 2016-12-06 22:57:30 -0700 |
commit | 0e99d291699dc5548f891340a4abb1541041b854 (patch) | |
tree | 5e2c15ee05f81d08f4b1a00afa497e440b7d61ba | |
parent | c5d2e442a34e090ed3e9294c4d1d51b3c23d8d24 (diff) | |
download | rneovim-0e99d291699dc5548f891340a4abb1541041b854.tar.gz rneovim-0e99d291699dc5548f891340a4abb1541041b854.tar.bz2 rneovim-0e99d291699dc5548f891340a4abb1541041b854.zip |
vim-patch:8.0.0033
Problem: Cannot use overlapping positions with matchaddpos().
Solution: Check end of match. (Ozaki Kiichi) Add a test (Hirohito Higashi)
https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 16 | ||||
-rw-r--r-- | src/nvim/testdir/test_match.vim | 10 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 65ce07a172..1de74e089e 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -884,7 +884,7 @@ typedef struct { int attr; /* attributes to be used for a match */ int attr_cur; /* attributes currently active in win_line() */ linenr_T first_lnum; /* first lnum to search for multi-line pat */ - colnr_T startcol; /* in win_line() points to char where HL starts */ + colnr_T startcol; // in win_line() points to char where HL starts colnr_T endcol; // in win_line() points to char where HL ends bool is_addpos; // position specified directly by matchaddpos() proftime_T tm; // for a time limit diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2b6005b484..ac8d14efb1 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5563,7 +5563,7 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum) // in progress n = 0; while (shl->first_lnum < lnum && (shl->rm.regprog != NULL - || (cur != NULL && pos_inprogress))) { + || (cur != NULL && pos_inprogress))) { next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n, shl == &search_hl ? NULL : cur); pos_inprogress = !(cur == NULL || cur->pos.cur == 0); @@ -5711,20 +5711,22 @@ next_search_hl_pos( shl->lnum = 0; for (i = posmatch->cur; i < MAXPOSMATCH; i++) { - if (posmatch->pos[i].lnum == 0) { + llpos_T *pos = &posmatch->pos[i]; + + if (pos->lnum == 0) { break; } - if (posmatch->pos[i].col < mincol) { + if (pos->col + pos->len - 1 <= mincol) { continue; } - if (posmatch->pos[i].lnum == lnum) { + if (pos->lnum == lnum) { if (bot != -1) { // partially sort positions by column numbers // on the same line - if (posmatch->pos[i].col < posmatch->pos[bot].col) { - llpos_T tmp = posmatch->pos[i]; + if (pos->col < posmatch->pos[bot].col) { + llpos_T tmp = *pos; - posmatch->pos[i] = posmatch->pos[bot]; + *pos = posmatch->pos[bot]; posmatch->pos[bot] = tmp; } } else { diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim index ce06143bad..d176bf9a87 100644 --- a/src/nvim/testdir/test_match.vim +++ b/src/nvim/testdir/test_match.vim @@ -181,6 +181,16 @@ func Test_matchaddpos() redraw! call assert_equal(screenattr(2,2), screenattr(1,6)) + " Check overlapping pos + call clearmatches() + call setline(1, ['1234567890', 'NH']) + call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]]) + redraw! + call assert_notequal(screenattr(2,2), 0) + call assert_equal(screenattr(2,2), screenattr(1,5)) + call assert_equal(screenattr(2,2), screenattr(1,7)) + call assert_notequal(screenattr(2,2), screenattr(1,8)) + nohl syntax off set hlsearch& |