From 4baeb96c1bb66c845b4bc58482df4e601485eec3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Mar 2022 04:43:51 +0800 Subject: vim-patch:8.2.4638: superfluous check if a redraw is needed for 'cursorline' Problem: Superfluous check if a redraw is needed for 'cursorline'. Solution: Remove check_redraw_cursorline(). (closes vim/vim#10030, closes vim/vim#10029) https://github.com/vim/vim/commit/3e559cd88486ffab6b6fb4e0921b4600d137a617 redraw_after_callback() is N/A. Omits changes that just revert code from patch 8.2.4630. --- test/functional/ui/highlight_spec.lua | 83 +++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'test/functional') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 559738ddab..2053901857 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1266,6 +1266,49 @@ describe('CursorLine and CursorLineNr highlights', function() end) end) +describe('CursorColumn highlight', function() + before_each(clear) + it('is updated if cursor is moved from timer', function() + local screen = Screen.new(50, 8) + screen:set_default_attr_ids({ + [1] = {background = Screen.colors.Gray90}, -- CursorColumn + [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + }) + screen:attach() + exec([[ + call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) + set cursorcolumn + call cursor(4, 5) + + func Func(timer) + call cursor(1, 1) + endfunc + + call timer_start(300, 'Func') + ]]) + screen:expect({grid = [[ + aaaa{1:a} | + bbbb{1:b} | + cccc{1:c} | + dddd^d | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]], timeout = 100}) + screen:expect({grid = [[ + ^aaaaa | + {1:b}bbbb | + {1:c}cccc | + {1:d}dddd | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]}) + end) +end) + describe('ColorColumn highlight', function() local screen @@ -1570,6 +1613,46 @@ describe("'number' and 'relativenumber' highlight", function() | ]]) end) + + it('relative number highlight is updated if cursor is moved from timer', function() + local screen = Screen.new(50, 8) + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.Brown}, -- LineNr + [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + }) + screen:attach() + exec([[ + call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) + set relativenumber + call cursor(4, 1) + + func Func(timer) + call cursor(1, 1) + endfunc + + call timer_start(300, 'Func') + ]]) + screen:expect({grid = [[ + {1: 3 }aaaaa | + {1: 2 }bbbbb | + {1: 1 }ccccc | + {1: 0 }^ddddd | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]], timeout = 100}) + screen:expect({grid = [[ + {1: 0 }^aaaaa | + {1: 1 }bbbbb | + {1: 2 }ccccc | + {1: 3 }ddddd | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]}) + end) end) describe("'winhighlight' highlight", function() -- cgit From ab02b28b4e14ecd22facab9377ea71aff2ffdfdb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Mar 2022 05:10:15 +0800 Subject: vim-patch:8.2.4630: 'cursorline' not always updated with 'culopt' is "screenline" Problem: 'cursorline' not always updated with 'cursorlineopt' is "screenline". Solution: Call check_redraw_cursorline() more often. (closes vim/vim#10013) https://github.com/vim/vim/commit/bf269ed0b0bd8414eea7bea17465b2738a9a2b55 Code was reverted in patch 8.2.4638, so this just ports the test. --- test/functional/ui/highlight_spec.lua | 59 +++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 10 deletions(-) (limited to 'test/functional') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 2053901857..bf52d9f9b4 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -937,17 +937,18 @@ describe('CursorLine and CursorLineNr highlights', function() [2] = {foreground = Screen.colors.Yellow}; [3] = {foreground = Screen.colors.Red, background = Screen.colors.Green}; [4] = {foreground = Screen.colors.Green, background = Screen.colors.Red}; + [5] = {bold = true}, -- ModeMsg }) screen:attach() - feed_command('set wrap cursorline cursorlineopt=screenline') - feed_command('set showbreak=>>>') - feed_command('highlight clear NonText') - feed_command('highlight clear CursorLine') - feed_command('highlight NonText guifg=Yellow gui=NONE') - feed_command('highlight LineNr guifg=Red guibg=Green gui=NONE') - feed_command('highlight CursorLine guifg=Black guibg=White gui=NONE') - feed_command('highlight CursorLineNr guifg=Green guibg=Red gui=NONE') + command('set wrap cursorline cursorlineopt=screenline') + command('set showbreak=>>>') + command('highlight clear NonText') + command('highlight clear CursorLine') + command('highlight NonText guifg=Yellow gui=NONE') + command('highlight LineNr guifg=Red guibg=Green gui=NONE') + command('highlight CursorLine guifg=Black guibg=White gui=NONE') + command('highlight CursorLineNr guifg=Green guibg=Red gui=NONE') feed('30iøo30ia') @@ -977,7 +978,7 @@ describe('CursorLine and CursorLineNr highlights', function() ]]) -- CursorLineNr should not apply to line number when 'cursorlineopt' does not contain "number" - feed_command('set relativenumber numberwidth=2') + command('set relativenumber numberwidth=2') screen:expect([[ {3:0 }{1:øøøøøøøøøøøø^øøøøøø}| {3: }{2:>>>}øøøøøøøøøøøø | @@ -987,7 +988,7 @@ describe('CursorLine and CursorLineNr highlights', function() ]]) -- CursorLineNr should apply to line number when 'cursorlineopt' contains "number" - feed_command('set cursorlineopt+=number') + command('set cursorlineopt+=number') screen:expect([[ {4:0 }{1:øøøøøøøøøøøø^øøøøøø}| {3: }{2:>>>}øøøøøøøøøøøø | @@ -1019,6 +1020,44 @@ describe('CursorLine and CursorLineNr highlights', function() {3: }{2:>>>}{1:aaaaaaaaa^aaa }| | ]]) + + -- updated in Insert mode + feed('I') + screen:expect([[ + {3:1 }øøøøøøøøøøøøøøøøøø| + {3: }{2:>>>}øøøøøøøøøøøø | + {4:0 }{1:^aaaaaaaaaaaaaaaaaa}| + {3: }{2:>>>}aaaaaaaaaaaa | + {5:-- INSERT --} | + ]]) + + feed('gg') + screen:expect([[ + {4:0 }{1:^øøøøøøøøøøøøøøøøøø}| + {3: }{2:>>>}øøøøøøøøøøøø | + {3:1 }aaaaaaaaaaaaaaaaaa| + {3: }{2:>>>}aaaaaaaaaaaa | + | + ]]) + + command('inoremap call cursor(1, 1)') + feed('A') + screen:expect([[ + {4:0 }øøøøøøøøøøøøøøøøøø| + {3: }{2:>>>}{1:øøøøøøøøøøøø^ }| + {3:1 }aaaaaaaaaaaaaaaaaa| + {3: }{2:>>>}aaaaaaaaaaaa | + {5:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + {4:0 }{1:^øøøøøøøøøøøøøøøøøø}| + {3: }{2:>>>}øøøøøøøøøøøø | + {3:1 }aaaaaaaaaaaaaaaaaa| + {3: }{2:>>>}aaaaaaaaaaaa | + {5:-- INSERT --} | + ]]) end) it('always updated. vim-patch:8.1.0849', function() -- cgit