To: vim-dev@vim.org Subject: Patch 5.5.067 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.067 Problem: With 'hlsearch' set, the pattern "\>" doesn't highlight the first match in a line. (Benji Fisher) Solution: Fix highlighting an empty match. Also highlight the first character in an empty line for "$". Files: src/screen.c *** ../vim-5.5.66/src/screen.c Wed Dec 1 20:19:07 1999 --- src/screen.c Thu Dec 9 13:04:48 1999 *************** *** 1323,1333 **** reg_ic = search_hl_ic; for (;;) { ! if (*matchp != NUL && vim_regexec(search_hl_prog, matchp, TRUE)) { search_hl_start = search_hl_prog->startp[0]; search_hl_end = search_hl_prog->endp[0]; ! if (search_hl_end <= ptr) /* match before leftcol */ { /* For an empty match and with Vi-compatible searching, * continue searching on the next character. */ --- 1323,1336 ---- reg_ic = search_hl_ic; for (;;) { ! if (vim_regexec(search_hl_prog, matchp, matchp == line)) { search_hl_start = search_hl_prog->startp[0]; search_hl_end = search_hl_prog->endp[0]; ! /* If match ends before leftcol: Find next match. */ ! if (search_hl_start < ptr ! && search_hl_end <= ptr ! && *search_hl_end != NUL) { /* For an empty match and with Vi-compatible searching, * continue searching on the next character. */ *************** *** 1338,1343 **** --- 1341,1354 ---- matchp = search_hl_end; continue; } + /* Highlight one character for an empty match. */ + if (search_hl_start == search_hl_end) + { + if (*search_hl_start == NUL && search_hl_start > line) + --search_hl_start; + else + ++search_hl_end; + } if (search_hl_start < ptr) /* match at leftcol */ search_attr = search_hl_attr; } *************** *** 1457,1463 **** * match starts at the current position */ if (search_hl_start != search_hl_end) continue; ! ++search_hl_end; /* try again after empty match */ } } break; --- 1468,1481 ---- * match starts at the current position */ if (search_hl_start != search_hl_end) continue; ! /* highlight empty match, try again after it */ ! ++search_hl_end; ! if (*search_hl_start == NUL ! && search_hl_start > line) ! { ! --search_hl_start; ! continue; ! } } } break; *************** *** 1635,1674 **** */ if (c == NUL) { ! if (area_attr) { - /* invert at least one char, used for Visual and empty line or - * highlight match at end of line. If it's beyond the last - * char on the screen, just overwrite that one (tricky!) */ - if (vcol == fromcol) - { #ifdef RIGHTLEFT ! if (wp->w_p_rl) { ! if (col < 0) ! { ! ++screenp; ! ++col; ! } } ! else #endif { ! if (col >= Columns) ! { ! --screenp; ! --col; ! } } ! *screenp = ' '; ! *(screenp + Columns) = char_attr; #ifdef RIGHTLEFT ! if (wp->w_p_rl) ! --col; ! else #endif ! ++col; ! } } SCREEN_LINE(screen_row, col, TRUE, wp->w_p_rl); --- 1653,1694 ---- */ if (c == NUL) { ! /* invert at least one char, used for Visual and empty line or ! * highlight match at end of line. If it's beyond the last ! * char on the screen, just overwrite that one (tricky!) */ ! if ((area_attr && vcol == fromcol) ! #ifdef EXTRA_SEARCH ! /* highlight 'hlsearch' match in empty line */ ! || (search_attr && *line == NUL && wp->w_leftcol == 0) ! #endif ! ) { #ifdef RIGHTLEFT ! if (wp->w_p_rl) ! { ! if (col < 0) { ! ++screenp; ! ++col; } ! } ! else #endif + { + if (col >= Columns) { ! --screenp; ! --col; } ! } ! *screenp = ' '; ! *(screenp + Columns) = char_attr; #ifdef RIGHTLEFT ! if (wp->w_p_rl) ! --col; ! else #endif ! ++col; } SCREEN_LINE(screen_row, col, TRUE, wp->w_p_rl); *** ../vim-5.5.66/src/version.c Wed Dec 8 16:23:15 1999 --- src/version.c Thu Dec 9 13:07:10 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 67, -- FATHER: Who are you? PRINCE: I'm ... your son ... FATHER: Not you. LAUNCELOT: I'm ... er ... Sir Launcelot, sir. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /