mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0040
Problem: Whole line highlighting with matchaddpos() does not work.
Solution: Check for zero length. (Hirohito Higashi)
8507747600
This commit is contained in:
parent
0e99d29169
commit
63c46c1106
@ -877,13 +877,13 @@ struct frame_S {
|
|||||||
* match functions there is a different pattern for each window.
|
* match functions there is a different pattern for each window.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
regmmatch_T rm; /* points to the regexp program; contains last found
|
regmmatch_T rm; // points to the regexp program; contains last found
|
||||||
match (may continue in next line) */
|
// match (may continue in next line)
|
||||||
buf_T *buf; /* the buffer to search for a match */
|
buf_T *buf; // the buffer to search for a match
|
||||||
linenr_T lnum; /* the line to search for a match */
|
linenr_T lnum; // the line to search for a match
|
||||||
int attr; /* attributes to be used for a match */
|
int attr; // attributes to be used for a match
|
||||||
int attr_cur; /* attributes currently active in win_line() */
|
int attr_cur; // attributes currently active in win_line()
|
||||||
linenr_T first_lnum; /* first lnum to search for multi-line pat */
|
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
|
colnr_T endcol; // in win_line() points to char where HL ends
|
||||||
bool is_addpos; // position specified directly by matchaddpos()
|
bool is_addpos; // position specified directly by matchaddpos()
|
||||||
|
@ -5698,6 +5698,8 @@ next_search_hl (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If there is a match fill "shl" and return one.
|
||||||
|
/// Return zero otherwise.
|
||||||
static int
|
static int
|
||||||
next_search_hl_pos(
|
next_search_hl_pos(
|
||||||
match_T *shl, // points to a match
|
match_T *shl, // points to a match
|
||||||
@ -5707,7 +5709,7 @@ next_search_hl_pos(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int bot = -1;
|
int found = -1;
|
||||||
|
|
||||||
shl->lnum = 0;
|
shl->lnum = 0;
|
||||||
for (i = posmatch->cur; i < MAXPOSMATCH; i++) {
|
for (i = posmatch->cur; i < MAXPOSMATCH; i++) {
|
||||||
@ -5716,41 +5718,41 @@ next_search_hl_pos(
|
|||||||
if (pos->lnum == 0) {
|
if (pos->lnum == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pos->col + pos->len - 1 <= mincol) {
|
if (pos->len == 0 && pos->col < mincol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pos->lnum == lnum) {
|
if (pos->lnum == lnum) {
|
||||||
if (bot != -1) {
|
if (found >= 0) {
|
||||||
// partially sort positions by column numbers
|
// if this match comes before the one at "found" then swap
|
||||||
// on the same line
|
// them
|
||||||
if (pos->col < posmatch->pos[bot].col) {
|
if (pos->col < posmatch->pos[found].col) {
|
||||||
llpos_T tmp = *pos;
|
llpos_T tmp = *pos;
|
||||||
|
|
||||||
*pos = posmatch->pos[bot];
|
*pos = posmatch->pos[found];
|
||||||
posmatch->pos[bot] = tmp;
|
posmatch->pos[found] = tmp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bot = i;
|
found = i;
|
||||||
shl->lnum = lnum;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
posmatch->cur = 0;
|
posmatch->cur = 0;
|
||||||
if (bot != -1) {
|
if (found >= 0) {
|
||||||
colnr_T start = posmatch->pos[bot].col == 0
|
colnr_T start = posmatch->pos[found].col == 0
|
||||||
? 0: posmatch->pos[bot].col - 1;
|
? 0: posmatch->pos[found].col - 1;
|
||||||
colnr_T end = posmatch->pos[bot].col == 0
|
colnr_T end = posmatch->pos[found].col == 0
|
||||||
? MAXCOL : start + posmatch->pos[bot].len;
|
? MAXCOL : start + posmatch->pos[found].len;
|
||||||
|
|
||||||
|
shl->lnum = lnum;
|
||||||
shl->rm.startpos[0].lnum = 0;
|
shl->rm.startpos[0].lnum = 0;
|
||||||
shl->rm.startpos[0].col = start;
|
shl->rm.startpos[0].col = start;
|
||||||
shl->rm.endpos[0].lnum = 0;
|
shl->rm.endpos[0].lnum = 0;
|
||||||
shl->rm.endpos[0].col = end;
|
shl->rm.endpos[0].col = end;
|
||||||
shl->is_addpos = true;
|
shl->is_addpos = true;
|
||||||
posmatch->cur = bot + 1;
|
posmatch->cur = found + 1;
|
||||||
return true;
|
return 1;
|
||||||
}
|
}
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screen_start_highlight(int attr)
|
static void screen_start_highlight(int attr)
|
||||||
|
@ -191,7 +191,15 @@ func Test_matchaddpos()
|
|||||||
call assert_equal(screenattr(2,2), screenattr(1,7))
|
call assert_equal(screenattr(2,2), screenattr(1,7))
|
||||||
call assert_notequal(screenattr(2,2), screenattr(1,8))
|
call assert_notequal(screenattr(2,2), screenattr(1,8))
|
||||||
|
|
||||||
|
call clearmatches()
|
||||||
|
call matchaddpos('Error', [[1], [2,2]])
|
||||||
|
redraw!
|
||||||
|
call assert_equal(screenattr(2,2), screenattr(1,1))
|
||||||
|
call assert_equal(screenattr(2,2), screenattr(1,10))
|
||||||
|
call assert_notequal(screenattr(2,2), screenattr(1,11))
|
||||||
|
|
||||||
nohl
|
nohl
|
||||||
|
call clearmatches()
|
||||||
syntax off
|
syntax off
|
||||||
set hlsearch&
|
set hlsearch&
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user