mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 19:48:32 +00:00
Merge #8921 'highlight: Fix after-EOL matches at cursor'
This commit is contained in:
@@ -3912,23 +3912,16 @@ win_line (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* At end of the text line.
|
// At end of the text line.
|
||||||
*/
|
//
|
||||||
if (c == NUL) {
|
if (c == NUL) {
|
||||||
if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol
|
// Highlight 'cursorcolumn' & 'colorcolumn' past end of the line.
|
||||||
&& lnum == wp->w_cursor.lnum) {
|
if (wp->w_p_wrap) {
|
||||||
/* highlight last char after line */
|
|
||||||
--col;
|
|
||||||
--off;
|
|
||||||
--vcol;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Highlight 'cursorcolumn' & 'colorcolumn' past end of the line. */
|
|
||||||
if (wp->w_p_wrap)
|
|
||||||
v = wp->w_skipcol;
|
v = wp->w_skipcol;
|
||||||
else
|
} else {
|
||||||
v = wp->w_leftcol;
|
v = wp->w_leftcol;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if line ends before left margin */
|
/* check if line ends before left margin */
|
||||||
if (vcol < v + col - win_col_off(wp))
|
if (vcol < v + col - win_col_off(wp))
|
||||||
|
@@ -4,7 +4,6 @@ function! Test_hlsearch()
|
|||||||
new
|
new
|
||||||
call setline(1, repeat(['aaa'], 10))
|
call setline(1, repeat(['aaa'], 10))
|
||||||
set hlsearch nolazyredraw
|
set hlsearch nolazyredraw
|
||||||
let r=[]
|
|
||||||
" redraw is needed to make hlsearch highlight the matches
|
" redraw is needed to make hlsearch highlight the matches
|
||||||
exe "normal! /aaa\<CR>" | redraw
|
exe "normal! /aaa\<CR>" | redraw
|
||||||
let r1 = screenattr(1, 1)
|
let r1 = screenattr(1, 1)
|
||||||
@@ -32,3 +31,16 @@ function! Test_hlsearch()
|
|||||||
call getchar(1)
|
call getchar(1)
|
||||||
enew!
|
enew!
|
||||||
endfunction
|
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
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
|
local command = helpers.command
|
||||||
local feed_command = helpers.feed_command
|
local feed_command = helpers.feed_command
|
||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
@@ -93,6 +94,59 @@ describe('search highlighting', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
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()
|
it('is preserved during :terminal activity', function()
|
||||||
if iswin() then
|
if iswin() then
|
||||||
feed([[:terminal for /L \%I in (1,1,5000) do @(echo xxx & echo xxx & echo xxx)<cr>]])
|
feed([[:terminal for /L \%I in (1,1,5000) do @(echo xxx & echo xxx & echo xxx)<cr>]])
|
||||||
|
Reference in New Issue
Block a user