summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-10-16 14:35:48 +0200
committerBram Moolenaar <Bram@vim.org>2016-10-16 14:35:48 +0200
commit8507747600bddfd6a68aed057840856bf5548e61 (patch)
tree896cf0dc5549bf62849d79a11ba2df379a5644c5 /src/screen.c
parent156919f99afd1ac11d19d4270afbc1afb7245640 (diff)
downloadvim-git-8507747600bddfd6a68aed057840856bf5548e61.tar.gz
patch 8.0.0040v8.0.0040
Problem: Whole line highlighting with matchaddpos() does not work. Solution: Check for zero length. (Hirohito Higashi)
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/screen.c b/src/screen.c
index 0889db91d..78f89ebf6 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -7773,6 +7773,10 @@ next_search_hl(
}
}
+/*
+ * If there is a match fill "shl" and return one.
+ * Return zero otherwise.
+ */
static int
next_search_hl_pos(
match_T *shl, /* points to a match */
@@ -7781,55 +7785,52 @@ next_search_hl_pos(
colnr_T mincol) /* minimal column for a match */
{
int i;
- int bot = -1;
+ int found = -1;
- shl->lnum = 0;
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
{
llpos_T *pos = &posmatch->pos[i];
if (pos->lnum == 0)
break;
- if (pos->col + pos->len - 1 <= mincol)
+ if (pos->len == 0 && pos->col < mincol)
continue;
if (pos->lnum == lnum)
{
- if (shl->lnum == lnum)
+ if (found >= 0)
{
- /* partially sort positions by column numbers
- * on the same line */
- if (pos->col < posmatch->pos[bot].col)
+ /* if this match comes before the one at "found" then swap
+ * them */
+ if (pos->col < posmatch->pos[found].col)
{
llpos_T tmp = *pos;
- *pos = posmatch->pos[bot];
- posmatch->pos[bot] = tmp;
+ *pos = posmatch->pos[found];
+ posmatch->pos[found] = tmp;
}
}
else
- {
- bot = i;
- shl->lnum = lnum;
- }
+ found = i;
}
}
posmatch->cur = 0;
- if (shl->lnum == lnum && bot >= 0)
+ if (found >= 0)
{
- colnr_T start = posmatch->pos[bot].col == 0
- ? 0 : posmatch->pos[bot].col - 1;
- colnr_T end = posmatch->pos[bot].col == 0
- ? MAXCOL : start + posmatch->pos[bot].len;
+ colnr_T start = posmatch->pos[found].col == 0
+ ? 0 : posmatch->pos[found].col - 1;
+ colnr_T end = posmatch->pos[found].col == 0
+ ? MAXCOL : start + posmatch->pos[found].len;
+ shl->lnum = lnum;
shl->rm.startpos[0].lnum = 0;
shl->rm.startpos[0].col = start;
shl->rm.endpos[0].lnum = 0;
shl->rm.endpos[0].col = end;
shl->is_addpos = TRUE;
- posmatch->cur = bot + 1;
- return TRUE;
+ posmatch->cur = found + 1;
+ return 1;
}
- return FALSE;
+ return 0;
}
#endif