diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-10-04 19:35:04 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-10-16 00:15:09 +0200 |
commit | ee94eecbd4ce9ec3b4371bbe1a2b3cc24cf315d4 (patch) | |
tree | 24237923bdbb093dee5d3454e27c37de8b0c303e | |
parent | 8fd092f3ff15bf70f84ec0d716c5aaa2c7379fa1 (diff) | |
download | rneovim-ee94eecbd4ce9ec3b4371bbe1a2b3cc24cf315d4.tar.gz rneovim-ee94eecbd4ce9ec3b4371bbe1a2b3cc24cf315d4.tar.bz2 rneovim-ee94eecbd4ce9ec3b4371bbe1a2b3cc24cf315d4.zip |
vim-patch:8.1.0448: cursorline not removed when using 'cursorbind'
Problem: Cursorline not removed when using 'cursorbind'. (Justin Keyes)
Solution: Store the last cursor line per window. (closes vim/vim#3488)
https://github.com/vim/vim/commit/4a5abbd6138240d109278fe1f0b45489d22f712d
-rw-r--r-- | src/nvim/buffer_defs.h | 8 | ||||
-rw-r--r-- | src/nvim/move.c | 16 | ||||
-rw-r--r-- | src/nvim/testdir/test_diffmode.vim | 27 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 65 |
4 files changed, 100 insertions, 16 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 9ff62a80af..e86eaf010f 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -983,9 +983,11 @@ struct window_S { used to try to stay in the same column for up/down cursor motions. */ - int w_set_curswant; /* If set, then update w_curswant the next - time through cursupdate() to the - current virtual column */ + int w_set_curswant; // If set, then update w_curswant the next + // time through cursupdate() to the + // current virtual column + + linenr_T w_last_cursorline; ///< where last 'cursorline' was drawn // the next seven are used to update the visual part char w_old_visual_mode; ///< last known VIsual_mode diff --git a/src/nvim/move.c b/src/nvim/move.c index 442e5d6dff..320f7b7d98 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -96,11 +96,9 @@ static void comp_botline(win_T *wp) set_empty_rows(wp, done); } -static linenr_T last_cursorline = 0; - void reset_cursorline(void) { - last_cursorline = 0; + curwin->w_last_cursorline = 0; } // Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is set. @@ -114,17 +112,17 @@ static void redraw_for_cursorline(win_T *wp) redraw_win_later(wp, VALID); } if (wp->w_p_cul) { - if (wp->w_redr_type <= VALID && last_cursorline != 0) { - // "last_cursorline" may be set for another window, worst case - // we redraw too much. This is optimized for moving the cursor - // around in the same window. - redrawWinline(wp, last_cursorline, false); + if (wp->w_redr_type <= VALID && wp->w_last_cursorline != 0) { + // "w_last_cursorline" may be outdated, worst case we redraw + // too much. This is optimized for moving the cursor around in + // the current window. + redrawWinline(wp, wp->w_last_cursorline, false); redrawWinline(wp, wp->w_cursor.lnum, false); redraw_win_later(wp, VALID); } else { redraw_win_later(wp, SOME_VALID); } - last_cursorline = wp->w_cursor.lnum; + wp->w_last_cursorline = wp->w_cursor.lnum; } } } diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 90fd34d93e..afe289b262 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -588,3 +588,30 @@ func Test_diff_lastline() bwipe! bwipe! endfunc + +func Test_diff_with_cursorline() + if !CanRunVimInTerminal() + return + endif + + call writefile([ + \ 'hi CursorLine ctermbg=red ctermfg=white', + \ 'set cursorline', + \ 'call setline(1, ["foo","foo","foo","bar"])', + \ 'vnew', + \ 'call setline(1, ["bee","foo","foo","baz"])', + \ 'windo diffthis', + \ '2wincmd w', + \ ], 'Xtest_diff_cursorline') + let buf = RunVimInTerminal('-S Xtest_diff_cursorline', {}) + + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_01', {}) + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_02', {}) + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_03', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('Xtest_diff_cursorline') +endfunc diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 7f3bf3e97b..4a792c665c 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -677,6 +677,7 @@ end) describe('CursorLine highlight', function() before_each(clear) + it('overridden by Error, ColorColumn if fg not set', function() local screen = Screen.new(50,5) screen:set_default_attr_ids({ @@ -690,9 +691,9 @@ describe('CursorLine highlight', function() }) screen:attach() - feed_command('filetype on') - feed_command('syntax on') - feed_command('set cursorline ft=json') + command('filetype on') + command('syntax on') + command('set cursorline ft=json') feed('i{<cr>"a" : abc // 10;<cr>}<cr><esc>') screen:expect([[ {1:{} | @@ -702,7 +703,7 @@ describe('CursorLine highlight', function() | ]]) - feed_command('set colorcolumn=3') + command('set colorcolumn=3') feed('i <esc>') screen:expect([[ {1:{} {7: } | @@ -712,6 +713,62 @@ describe('CursorLine highlight', function() | ]]) end) + + it('with split-windows in diff-mode', function() + local screen = Screen.new(50,12) + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [2] = {bold = true, background = Screen.colors.Red}, + [3] = {background = Screen.colors.LightMagenta}, + [4] = {reverse = true}, + [5] = {background = Screen.colors.LightBlue}, + [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, + [7] = {background = Screen.colors.Red, foreground = Screen.colors.White}, + [8] = {bold = true, foreground = Screen.colors.Blue1}, + [9] = {bold = true, reverse = true}, + [10] = {bold = true}, + }) + screen:attach() + + command('hi CursorLine ctermbg=red ctermfg=white guibg=red guifg=white') + command('set cursorline') + feed('iline 1 some text<cr>line 2 more text<cr>extra line!<cr>extra line!<cr>last line ...<cr>') + feed('<esc>gg') + command('vsplit') + command('enew') + feed('iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>') + feed('<esc>gg') + command('windo diffthis') + screen:expect([[ + {1: }{7:line 1 some text }{4:│}{1: }{7:^line 1 some text }| + {1: }{3:line 2 mo}{2:Re text!}{3: }{4:│}{1: }{3:line 2 mo}{2:re text}{3: }| + {1: }{5:extra line! }{4:│}{1: }{6:----------------------}| + {1: }extra line! {4:│}{1: }extra line! | + {1: }extra line! {4:│}{1: }extra line! | + {1: }last line ... {4:│}{1: }last line ... | + {1: } {4:│}{1: } | + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {4:[No Name] [+] }{9:[No Name] [+] }| + | + ]]) + feed('jjjjj') + screen:expect([[ + {1: }line 1 some text {4:│}{1: }line 1 some text | + {1: }{3:line 2 mo}{2:Re text!}{3: }{4:│}{1: }{3:line 2 mo}{2:re text}{3: }| + {1: }{5:extra line! }{4:│}{1: }{6:----------------------}| + {1: }extra line! {4:│}{1: }extra line! | + {1: }extra line! {4:│}{1: }extra line! | + {1: }last line ... {4:│}{1: }last line ... | + {1: }{7: }{4:│}{1: }{7:^ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {4:[No Name] [+] }{9:[No Name] [+] }| + | + ]]) + end) end) |