diff options
| author | Luuk van Baal <luukvbaal@gmail.com> | 2024-04-10 11:42:46 +0200 |
|---|---|---|
| committer | Luuk van Baal <luukvbaal@gmail.com> | 2024-05-02 15:57:06 +0200 |
| commit | 037ea6e786b5d05f4a8965e4c2ba6aa60ec7c01a (patch) | |
| tree | d59f33ff739409f1a280d2c3f9b8140a814c9e38 /test/functional/ui | |
| parent | 7b14eb543d43344e2498335dc93a68d200469516 (diff) | |
| download | rneovim-037ea6e786b5d05f4a8965e4c2ba6aa60ec7c01a.tar.gz rneovim-037ea6e786b5d05f4a8965e4c2ba6aa60ec7c01a.tar.bz2 rneovim-037ea6e786b5d05f4a8965e4c2ba6aa60ec7c01a.zip | |
feat(api): add nvim__redraw for more granular redrawing
Experimental and subject to future changes.
Add a way to redraw certain elements that are not redrawn while Nvim is waiting
for input, or currently have no API to do so. This API covers all that can be
done with the :redraw* commands, in addition to the following new features:
- Immediately move the cursor to a (non-current) window.
- Target a specific window or buffer to mark for redraw.
- Mark a buffer range for redraw (replaces nvim__buf_redraw_range()).
- Redraw the 'statuscolumn'.
Diffstat (limited to 'test/functional/ui')
| -rw-r--r-- | test/functional/ui/cmdline_spec.lua | 4 | ||||
| -rw-r--r-- | test/functional/ui/inccommand_spec.lua | 6 | ||||
| -rw-r--r-- | test/functional/ui/statuscolumn_spec.lua | 53 |
3 files changed, 61 insertions, 2 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index b3ec5f7535..6edfb4a49c 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -827,14 +827,14 @@ local function test_cmdline(linegrid) ]]) end) - -- Needs new API - pending('does not move cursor to curwin #20309', function() + it('does not move cursor to curwin #20309', function() local win = api.nvim_get_current_win() command('norm icmdlinewin') command('new') command('norm icurwin') feed(':') api.nvim_win_set_cursor(win, { 1, 7 }) + api.nvim__redraw({ win = win, cursor = true }) screen:expect { grid = [[ curwin | diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6bcfae2eee..c11e009fef 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2594,6 +2594,12 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() {2:[Preview] }| :%s/foo/ZZZ^ | ]]) + + -- Also with nvim__redraw() + command('call timer_start(10, {-> nvim__redraw(#{flush:1})}, {"repeat":-1})') + command('call timer_start(10, {-> nvim__redraw(#{statusline:1})}, {"repeat":-1})') + sleep(20) -- Allow some timer activity. + screen:expect_unchanged() end) it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function() diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index cce9cca2ca..9a8629018f 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -918,4 +918,57 @@ describe('statuscolumn', function() | ]]) end) + + it('forces a rebuild with nvim__redraw', function() + screen:try_resize(40, 4) + -- Current window + command([[ + let g:insert = v:false + set nonu stc=%{g:insert?'insert':''} + vsplit + au InsertEnter * let g:insert = v:true | call nvim__redraw(#{statuscolumn:1, win:0}) + au InsertLeave * let g:insert = v:false | call nvim__redraw(#{statuscolumn:1, win:0}) + ]]) + feed('i') + screen:expect({ + grid = [[ + {8:insert}^aaaaa │aaaaa | + {8:insert}aaaaa │aaaaa | + {3:[No Name] [+] }{2:[No Name] [+] }| + {5:-- INSERT --} | + ]], + }) + feed('<esc>') + screen:expect({ + grid = [[ + ^aaaaa │aaaaa | + aaaaa │aaaaa | + {3:[No Name] [+] }{2:[No Name] [+] }| + | + ]], + }) + -- All windows + command([[ + au! InsertEnter * let g:insert = v:true | call nvim__redraw(#{statuscolumn:1}) + au! InsertLeave * let g:insert = v:false | call nvim__redraw(#{statuscolumn:1}) + ]]) + feed('i') + screen:expect({ + grid = [[ + {8:insert}^aaaaa │{8:insert}aaaaa | + {8:insert}aaaaa │{8:insert}aaaaa | + {3:[No Name] [+] }{2:[No Name] [+] }| + {5:-- INSERT --} | + ]], + }) + feed('<esc>') + screen:expect({ + grid = [[ + ^aaaaa │aaaaa | + aaaaa │aaaaa | + {3:[No Name] [+] }{2:[No Name] [+] }| + | + ]], + }) + end) end) |