diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-09-04 07:05:20 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-09-04 07:05:20 +0200 |
commit | 90519107f2423f0ef71d2db821af32a3e33e23d6 (patch) | |
tree | 71caf1d34fac072c1c92480569a120eee7c0c612 | |
parent | 7ff63fcdc0ba1ce2b8500641f3742d5ada68d496 (diff) | |
parent | 2694fa759f72b9d923be5e2108110685a1583faf (diff) | |
download | rneovim-90519107f2423f0ef71d2db821af32a3e33e23d6.tar.gz rneovim-90519107f2423f0ef71d2db821af32a3e33e23d6.tar.bz2 rneovim-90519107f2423f0ef71d2db821af32a3e33e23d6.zip |
Merge #8921 'highlight: Fix after-EOL matches at cursor'
-rw-r--r-- | src/nvim/screen.c | 21 | ||||
-rw-r--r-- | src/nvim/testdir/test_hlsearch.vim | 14 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 54 |
3 files changed, 74 insertions, 15 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 91840026a5..884fef69d1 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3912,23 +3912,16 @@ win_line ( } } - /* - * At end of the text line. - */ + // + // At end of the text line. + // if (c == NUL) { - if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol - && lnum == wp->w_cursor.lnum) { - /* highlight last char after line */ - --col; - --off; - --vcol; - } - - /* Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. */ - if (wp->w_p_wrap) + // Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. + if (wp->w_p_wrap) { v = wp->w_skipcol; - else + } else { v = wp->w_leftcol; + } /* check if line ends before left margin */ if (vcol < v + col - win_col_off(wp)) diff --git a/src/nvim/testdir/test_hlsearch.vim b/src/nvim/testdir/test_hlsearch.vim index 066fdd0250..1fc7b04f88 100644 --- a/src/nvim/testdir/test_hlsearch.vim +++ b/src/nvim/testdir/test_hlsearch.vim @@ -4,7 +4,6 @@ function! Test_hlsearch() new call setline(1, repeat(['aaa'], 10)) set hlsearch nolazyredraw - let r=[] " redraw is needed to make hlsearch highlight the matches exe "normal! /aaa\<CR>" | redraw let r1 = screenattr(1, 1) @@ -32,3 +31,16 @@ function! Test_hlsearch() call getchar(1) enew! endfunction + +func Test_hlsearch_eol_highlight() + new + call append(1, repeat([''], 9)) + set hlsearch nolazyredraw + exe "normal! /$\<CR>" | redraw + let attr = screenattr(1, 1) + for row in range(2, 10) + call assert_equal(attr, screenattr(row, 1), 'in line ' . row) + endfor + set nohlsearch + bwipe! +endfunc diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 168080a092..b535092ab9 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local command = helpers.command local feed_command = helpers.feed_command local eq = helpers.eq local eval = helpers.eval @@ -93,6 +94,59 @@ describe('search highlighting', function() ]]) end) + it('highlights after EOL', function() + insert("\n\n\n\n\n\n") + + feed("gg/^<cr>") + screen:expect([[ + {2: } | + {2:^ } | + {2: } | + {2: } | + {2: } | + {2: } | + /^ | + ]]) + + -- Test that highlights are preserved after moving the cursor. + feed("j") + screen:expect([[ + {2: } | + {2: } | + {2:^ } | + {2: } | + {2: } | + {2: } | + /^ | + ]]) + + -- Repeat the test in rightleft mode. + command("nohlsearch") + command("set rightleft") + feed("gg/^<cr>") + + screen:expect([[ + {2: }| + {2:^ }| + {2: }| + {2: }| + {2: }| + {2: }| + ^/ | + ]]) + + feed("j") + screen:expect([[ + {2: }| + {2: }| + {2:^ }| + {2: }| + {2: }| + {2: }| + ^/ | + ]]) + end) + it('is preserved during :terminal activity', function() if iswin() then feed([[:terminal for /L \%I in (1,1,5000) do @(echo xxx & echo xxx & echo xxx)<cr>]]) |