To: vim_dev@googlegroups.com Subject: Patch 8.0.0040 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0040 (after 8.0.0033) Problem: Whole line highlighting with matchaddpos() does not work. Solution: Check for zero length. (Hirohito Higashi) Files: src/screen.c, src/testdir/test_match.vim *** ../vim-8.0.0039/src/screen.c 2016-10-15 14:56:25.868257421 +0200 --- src/screen.c 2016-10-16 14:28:48.026766302 +0200 *************** *** 7773,7778 **** --- 7773,7782 ---- } } + /* + * 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,7835 **** colnr_T mincol) /* minimal column for a match */ { int i; ! int bot = -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) continue; if (pos->lnum == lnum) { ! if (shl->lnum == lnum) { ! /* partially sort positions by column numbers ! * on the same line */ ! if (pos->col < posmatch->pos[bot].col) { llpos_T tmp = *pos; ! *pos = posmatch->pos[bot]; ! posmatch->pos[bot] = tmp; } } else ! { ! bot = i; ! shl->lnum = lnum; ! } } } posmatch->cur = 0; ! if (shl->lnum == lnum && bot >= 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; 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; } ! return FALSE; } #endif --- 7785,7836 ---- colnr_T mincol) /* minimal column for a match */ { int i; ! int found = -1; for (i = posmatch->cur; i < MAXPOSMATCH; i++) { llpos_T *pos = &posmatch->pos[i]; if (pos->lnum == 0) break; ! if (pos->len == 0 && pos->col < mincol) continue; if (pos->lnum == lnum) { ! if (found >= 0) { ! /* 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[found]; ! posmatch->pos[found] = tmp; } } else ! found = i; } } posmatch->cur = 0; ! if (found >= 0) { ! 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 = found + 1; ! return 1; } ! return 0; } #endif *** ../vim-8.0.0039/src/testdir/test_match.vim 2016-10-15 14:56:25.868257421 +0200 --- src/testdir/test_match.vim 2016-10-16 14:16:10.376350417 +0200 *************** *** 191,197 **** --- 191,205 ---- call assert_equal(screenattr(2,2), screenattr(1,7)) 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 + call clearmatches() syntax off set hlsearch& endfunc *** ../vim-8.0.0039/src/version.c 2016-10-15 20:46:13.580656069 +0200 --- src/version.c 2016-10-16 14:30:29.174020816 +0200 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 40, /**/ -- It is illegal for anyone to give lighted cigars to dogs, cats, and other domesticated animal kept as pets. [real standing law in Illinois, United States of America] /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///