From 64fa75a86a9e2e301e884e21911d71688fc8f122 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Thu, 2 Feb 2023 10:35:51 +0100 Subject: fix(column): estimate 'statuscolumn' width appropriately Problem: The 'statuscolumn' width is being estimated without the proper context. In particular, this resulted in the fact that a custom fold column could be included in the estimated `number_width()`, and doubly added when actually drawing the statuscolumn due to `win_col_off()` also adding the `'foldcolumn'` width. Resulting in a status column that is `'foldcolumn'` cells wider than necessary. Solution: Estimate 'statuscolumn' width in `get_statuscol_str()` when a buffer's line count has changed. --- test/functional/ui/statuscolumn_spec.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index ae3b95fb0f..3233e6cd19 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -439,7 +439,7 @@ describe('statuscolumn', function() vim.api.nvim_buf_set_extmark(0, ns, 7, 0, { virt_lines_leftcol = true, virt_lines = {{{"virt", ""}}} }) ]]) - feed('lh') -- force update wcol/row + feed('lh') -- force update cursor row screen:expect([[ 4 aaaaa | 5 aaaaa | @@ -458,5 +458,24 @@ describe('statuscolumn', function() ]]) command('set stc=') -- also for the default sign column screen:expect_unchanged() + -- 'statuscolumn' is not too wide with custom (bogus) fold column + command([[set stc=%{foldlevel(v:lnum)>0?repeat('-',foldlevel(v:lnum)):''}%=%l\ ]]) + feed('Gd10Ggg') + screen:expect([[ + 1 ^aaaaa | + 2 aaaaa | + 3 aaaaa | + 4 aaaaa | + 5 aaaaa | + 6 aaaaa | + 7 aaaaa | + virt | + ---------8 aaaaa | + virt | + ---------9 aaaaa | + ~ | + ~ | + | + ]]) end) end) -- cgit From 08fb3b5309dee79585f3eec2450636966cbb01b4 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 31 Jan 2023 00:52:34 +0100 Subject: perf(column): only build fold/sign column when present in 'statuscolumn' Problem: The fold and sign column is built and stored regardless of whether the corresponding item is present in 'statuscolumn'. Solution: Since the 'statuscolumn' parses itself, we can defer building the columns until the corresponding item is actually encountered. --- test/functional/ui/statuscolumn_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 3233e6cd19..287686cf37 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -456,7 +456,7 @@ describe('statuscolumn', function() 14 aaaaa | | ]]) - command('set stc=') -- also for the default sign column + command('set stc=') -- also for the default fold column screen:expect_unchanged() -- 'statuscolumn' is not too wide with custom (bogus) fold column command([[set stc=%{foldlevel(v:lnum)>0?repeat('-',foldlevel(v:lnum)):''}%=%l\ ]]) -- cgit From 228684d2fbb6262f761b2b5d7001033bd69880c1 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sun, 5 Feb 2023 23:49:43 +0000 Subject: fix(decoration): don't show signcolumn for non-sign_text extmark (#22135) Fixes: #22127 --- test/functional/ui/decorations_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 489c33d8b1..6ed32a8cd4 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2109,6 +2109,20 @@ l5 | ]]} end) + + it('does not set signcolumn for signs without text', function() + screen:try_resize(20, 3) + meths.win_set_option(0, 'signcolumn', 'auto') + insert(example_text) + feed 'gg' + meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) + screen:expect{grid=[[ + ^l1 | + l2 | + | + ]]} + end) + end) describe('decorations: virt_text', function() -- cgit From 9437800d280385c018a99aa0fbe9043e4d7715aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Feb 2023 18:44:06 +0800 Subject: vim-patch:9.0.1298: inserting register on the cmdline does not trigger incsearch Problem: Inserting a register on the command line does not trigger incsearch or update hlsearch. Solution: Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate and handle it correctly. (Ken Takata, closes vim/vim#11960) https://github.com/vim/vim/commit/c4b7dec38292fe1cfad7aa5f244031fc6f7c7a09 Co-authored-by: K.Takata --- test/functional/ui/searchhl_spec.lua | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 18bbb56a61..404cc6d043 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -10,7 +10,6 @@ local testprg = helpers.testprg describe('search highlighting', function() local screen - local colors = Screen.colors before_each(function() clear() @@ -18,9 +17,9 @@ describe('search highlighting', function() screen:attach() screen:set_default_attr_ids( { [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {background = colors.Yellow}, -- Search + [2] = {background = Screen.colors.Yellow}, -- Search [3] = {reverse = true}, - [4] = {foreground = colors.Red}, -- Message + [4] = {foreground = Screen.colors.Red}, -- Message [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded }) end) @@ -498,6 +497,20 @@ describe('search highlighting', function() {1:~ }│{1:~ }| //^ | ]]) + feed('') + + -- incsearch works after c_CTRL-R_CTRL-R + command('let @" = "file"') + feed('/"') + screen:expect([[ + the first line │the first line | + in a little {3:file} │in a little {2:file} | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /file^ | + ]]) end) it('works with incsearch and offset', function() @@ -572,12 +585,12 @@ describe('search highlighting', function() it('works with matchadd and syntax', function() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; - [2] = {background = colors.Yellow}; + [2] = {background = Screen.colors.Yellow}; [3] = {reverse = true}; - [4] = {foreground = colors.Red}; - [5] = {bold = true, background = colors.Green}; - [6] = {italic = true, background = colors.Magenta}; - [7] = {bold = true, background = colors.Yellow}; + [4] = {foreground = Screen.colors.Red}; + [5] = {bold = true, background = Screen.colors.Green}; + [6] = {italic = true, background = Screen.colors.Magenta}; + [7] = {bold = true, background = Screen.colors.Yellow}; [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray}; } feed_command('set hlsearch') -- cgit From c2375efe56b3918f83ee143f48fb7a763fa50289 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Feb 2023 17:32:49 +0800 Subject: fix(ui): make sure screen is valid after resizing Problem: When not inside an Ex command, screen_resize() calls update_screen(), which calls screenclear() and set the screen as valid. However, when inside an Ex command, redrawing is postponed so update_screen() screen doesn't do anything, and the screen is still invalid after the resize, causing ui_comp_raw_line() to be no-op until update_screen() is called on the main loop. Solution: Restore the call to screenclear() inside screen_resize() so that the screen is invalid after screen_resize(). Since screenclear() changes redraw type from UPD_CLEAR to UPD_NOT_VALID, it is called at most once for each resize, so this shouldn't change how much code is run in the common (not inside an Ex command) case. --- test/functional/ui/screen_basic_spec.lua | 81 ++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 3bd2289a73..439021ad87 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -61,6 +61,7 @@ local function screen_tests(linegrid) [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia}, [6] = {bold = true, foreground = Screen.colors.Fuchsia}, [7] = {bold = true, foreground = Screen.colors.SeaGreen}, + [8] = {foreground = Screen.colors.White, background = Screen.colors.Red}, } ) end) @@ -866,12 +867,9 @@ local function screen_tests(linegrid) end) describe('resize', function() - before_each(function() + it('rebuilds the whole screen', function() screen:try_resize(25, 5) feed('iresize') - end) - - it('rebuilds the whole screen', function() screen:expect([[ resize^ | {0:~ }| @@ -882,6 +880,7 @@ local function screen_tests(linegrid) end) it('has minimum width/height values', function() + feed('iresize') screen:try_resize(1, 1) screen:expect([[ resize^ | @@ -896,7 +895,8 @@ local function screen_tests(linegrid) end) it('VimResized autocommand does not cause invalid UI events #20692 #20759', function() - feed('') + screen:try_resize(25, 5) + feed('iresize') command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) @@ -919,6 +919,77 @@ local function screen_tests(linegrid) ]]) eq(29, meths.get_var('echospace')) end) + + it('messages from the same Ex command as resize are visible #22225', function() + feed(':set columns=20 | call') + screen:expect([[ + | + | + | + | + | + | + | + | + | + {1: }| + {8:E471: Argument requi}| + {8:red} | + {7:Press ENTER or type }| + {7:command to continue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(':set columns=0') + screen:expect([[ + | + | + | + | + | + {1: }| + {8:E594: Need a}| + {8:t least 12 c}| + {8:olumns: colu}| + {8:mns=0} | + {7:Press ENTER }| + {7:or type comm}| + {7:and to conti}| + {7:nue}^ | + ]]) + feed('') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) end) describe('press enter', function() -- cgit From 53968082675cd3b8d1809e53a47c0311b7347ef9 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:52:22 +0100 Subject: fix(folds): cursorline highlight is not always applied on closed folds (#22242) Problem: The cursorline highlight logic checks for `w_cursor.lnum` which may be different from the line number passed to `win_line()` even when the cursor is actually on that line. Solution: Update cursor line highlight logic to check for the line number of the start of a closed fold if necessary. --- test/functional/ui/fold_spec.lua | 132 ++++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 44 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 46a478c1ea..420a4654f8 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -10,6 +10,7 @@ local meths = helpers.meths local exec = helpers.exec local exec_lua = helpers.exec_lua local assert_alive = helpers.assert_alive +local poke_eventloop = helpers.poke_eventloop local content1 = [[ @@ -90,10 +91,10 @@ describe("folded lines", function() end) it("highlights with CursorLineFold when 'cursorline' is set", function() - command("set cursorline foldcolumn=2 foldmethod=marker") + command("set number cursorline foldcolumn=2") command("hi link CursorLineFold Search") insert(content1) - feed("zf3j") + feed("ggzf3jj") if multigrid then screen:expect([[ ## grid 1 @@ -106,26 +107,26 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {7: }in his cave. | - {6: }{12:^ }| + {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| {1:~ }| ## grid 3 | ]]) else screen:expect([[ - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {7: }in his cave. | - {6: }{12:^ }| - {1:~ }| - | + {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | ]]) end feed("k") @@ -141,28 +142,36 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {6: }{12:^in his cave. }| - {7: } | + {6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| {1:~ }| ## grid 3 | ]]) else screen:expect([[ - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {6: }{12:^in his cave. }| - {7: } | - {1:~ }| - | + {6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | ]]) end + -- CursorLine is applied correctly with screenrow motions #22232 + feed("jgk") + poke_eventloop() + screen:expect_unchanged() + -- CursorLine is applied correctly when closing a fold when cursor is not at fold start + feed("zo4Gzc") + poke_eventloop() + screen:expect_unchanged() command("set cursorlineopt=line") if multigrid then screen:expect([[ @@ -176,26 +185,61 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {7: }{12:^in his cave. }| - {7: } | + {7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| {1:~ }| ## grid 3 | ]]) else screen:expect([[ - {7: }This is a | - {7: }valid English | - {7: }sentence composed by | - {7: }an exhausted developer | - {7: }{12:^in his cave. }| - {7: } | - {1:~ }| - | + {7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + command("set relativenumber cursorlineopt=number") + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | ]]) end end) -- cgit From 46a87a5d2bac598fed0870f0d3c926087f95d30f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Feb 2023 05:19:04 -0500 Subject: refactor(api): VALIDATE macros #22187 Problem: - API validation involves too much boilerplate. - API validation errors are not consistently worded. Solution: Introduce some macros. Currently these are clumsy, but they at least help with consistency and avoid some nesting. --- test/functional/ui/bufhl_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 46bfae8de2..76baf2cddb 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -751,8 +751,8 @@ describe('Buffer highlighting', function() it('validates contents', function() -- this used to leak memory - eq('Chunk is not an array', pcall_err(set_virtual_text, id1, 0, {"texty"}, {})) - eq('Chunk is not an array', pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {})) + eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {"texty"}, {})) + eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {})) end) it('can be retrieved', function() -- cgit From 3a6a7add57d2ac141f474b54659bbbf596b76059 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 14 Feb 2023 18:26:22 +0800 Subject: test: remove unused field ext_float (#22243) --- test/functional/ui/screen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 3b9cce0e6f..a059fb5b89 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -214,7 +214,7 @@ function Screen:attach(options, session) -- simplify test code by doing the same. self._options.rgb = true end - if self._options.ext_multigrid or self._options.ext_float then + if self._options.ext_multigrid then self._options.ext_linegrid = true end end -- cgit From 39f8aaeb815c2e31cffec12ef36ad4f25df91602 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 24 Jan 2020 09:48:58 +0100 Subject: fix(status): handle unprintable chars in the statusline --- test/functional/ui/multibyte_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index d4e237bcb4..9f413f8bff 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -158,6 +158,7 @@ describe('multibyte rendering: statusline', function() screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {bold = true, reverse = true}, + [3] = {background = Screen.colors.Red, foreground = Screen.colors.Gray100}; }) screen:attach() command('set laststatus=2') @@ -220,4 +221,27 @@ describe('multibyte rendering: statusline', function() | ]]} end) + + it('unprintable chars in filename with default stl', function() + command("file 🧑‍💻") + -- TODO: this is wrong but avoids a crash + screen:expect{grid=[[ + ^ | + {1:~ }| + {2:🧑�💻 }| + | + ]]} + end) + + it('unprintable chars in filename with custom stl', function() + command('set statusline=xx%#ErrorMsg#%f%##yy') + command("file 🧑‍💻") + -- TODO: this is also wrong but also avoids a crash + screen:expect{grid=[[ + ^ | + {1:~ }| + {2:xx}{3:🧑<200d>💻}{2:yy }| + | + ]]} + end) end) -- cgit From 556f8646c01d1751cf39fe4df9c622899dceab9d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Feb 2023 14:19:28 -0500 Subject: refactor(api): consistent VALIDATE messages #22262 Problem: Validation messages are not consistently formatted. - Parameter names sometimes are NOT quoted. - Descriptive names (non-parameters) sometimes ARE quoted. Solution: Always quote the `name` value passed to a VALIDATE macro _unless_ the value has whitespace. --- test/functional/ui/bufhl_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 76baf2cddb..418294ac07 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -751,8 +751,8 @@ describe('Buffer highlighting', function() it('validates contents', function() -- this used to leak memory - eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {"texty"}, {})) - eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {})) + eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {"texty"}, {})) + eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {})) end) it('can be retrieved', function() -- cgit From 05faa8f30ad770d4e4ead41cec601ccced8fb97f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 15 Feb 2023 07:26:55 +0800 Subject: test: make expect_unchanged() less confusing (#22255) Problem: The sleep before collecting the initial screen state is confusing and may lead to unexpected success if it comes after a blocking RPC call. Solution: Remove that sleep and add an "intermediate" argument. --- test/functional/ui/fold_spec.lua | 9 ++------- test/functional/ui/inccommand_spec.lua | 3 ++- test/functional/ui/screen.lua | 12 ++++++++---- test/functional/ui/searchhl_spec.lua | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 420a4654f8..c8a3397a86 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -10,7 +10,6 @@ local meths = helpers.meths local exec = helpers.exec local exec_lua = helpers.exec_lua local assert_alive = helpers.assert_alive -local poke_eventloop = helpers.poke_eventloop local content1 = [[ @@ -30,8 +29,6 @@ describe("folded lines", function() local function with_ext_multigrid(multigrid) local screen before_each(function() - clear() - command('hi VertSplit gui=reverse') screen = Screen.new(45, 8) screen:attach({rgb=true, ext_multigrid=multigrid}) screen:set_default_attr_ids({ @@ -166,12 +163,10 @@ describe("folded lines", function() end -- CursorLine is applied correctly with screenrow motions #22232 feed("jgk") - poke_eventloop() - screen:expect_unchanged() + screen:expect_unchanged(true) -- CursorLine is applied correctly when closing a fold when cursor is not at fold start feed("zo4Gzc") - poke_eventloop() - screen:expect_unchanged() + screen:expect_unchanged(true) command("set cursorlineopt=line") if multigrid then screen:expect([[ diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6fbf9b72c8..96634be327 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2886,7 +2886,8 @@ it(':substitute with inccommand during :terminal activity', function() feed('gg') feed(':%s/foo/ZZZ') sleep(20) -- Allow some terminal activity. - helpers.poke_eventloop() + poke_eventloop() + screen:sleep(0) screen:expect_unchanged() end) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index a059fb5b89..7760f26fca 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -470,15 +470,19 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end, expected) end -function Screen:expect_unchanged(waittime_ms, ignore_attrs, request_cb) +function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs) waittime_ms = waittime_ms and waittime_ms or 100 -- Collect the current screen state. - self:sleep(0, request_cb) local kwargs = self:get_snapshot(nil, ignore_attrs) - -- Check that screen state does not change. - kwargs.unchanged = true + if intermediate then + kwargs.intermediate = true + else + kwargs.unchanged = true + end + kwargs.timeout = waittime_ms + -- Check that screen state does not change. self:expect(kwargs) end diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 404cc6d043..916a5eb537 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -317,6 +317,7 @@ describe('search highlighting', function() ]]) feed('/foo') helpers.poke_eventloop() + screen:sleep(0) screen:expect_unchanged() end) -- cgit From 9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 09:27:10 +0800 Subject: test: make {MATCH:} behave less unexpectedly in screen:expect() Include the rest of the line and allow multiple {MATCH:} patterns. --- test/functional/ui/bufhl_spec.lua | 2 +- test/functional/ui/messages_spec.lua | 4 ++-- test/functional/ui/screen.lua | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 418294ac07..adec0770de 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -303,7 +303,7 @@ describe('Buffer highlighting', function() {1:~ }| {1:~ }| {1:~ }| - 2 change3; before #3 {MATCH:.*}| + 2 changes; before #3 {MATCH:.*}| ]]} command('undo') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 3052a74f38..212d3aee7d 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1322,7 +1322,7 @@ describe('ui/ext_messages', function() {1:~ }type :q{5:} to exit {1: }| {1:~ }type :help{5:} for help {1: }| {1:~ }| - {1:~ }type :help news{5:} to see changes in v{MATCH:%d+%.%d+}| + {1:~{MATCH: +}}type :help news{5:} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}| {1:~ }| {MATCH:.*}| {MATCH:.*}| @@ -1378,7 +1378,7 @@ describe('ui/ext_messages', function() type :q{5:} to exit | type :help{5:} for help | | - type :help news{5:} to see changes in v{MATCH:%d+%.%d+}| + {MATCH: +}type :help news{5:} to see changes in v{MATCH:%d+%.%d+ +}| | {MATCH:.*}| {MATCH:.*}| diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 7760f26fca..14ce050578 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -75,6 +75,7 @@ local busted = require('busted') local deepcopy = helpers.deepcopy local shallowcopy = helpers.shallowcopy local concat_tables = helpers.concat_tables +local pesc = helpers.pesc local run_session = helpers.run_session local eq = helpers.eq local dedent = helpers.dedent @@ -257,7 +258,7 @@ local ext_keys = { -- grid: Expected screen state (string). Each line represents a screen -- row. Last character of each row (typically "|") is stripped. -- Common indentation is stripped. --- "{MATCH:x}|" lines are matched against Lua pattern `x`. +-- "{MATCH:x}" in a line is matched against Lua pattern `x`. -- attr_ids: Expected text attributes. Screen rows are transformed according -- to this table, as follows: each substring S composed of -- characters having the same attributes will be substituted by @@ -382,8 +383,20 @@ function Screen:expect(expected, attr_ids, ...) end for i, row in ipairs(expected_rows) do msg_expected_rows[i] = row - local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil) - if row ~= actual_rows[i] and (not m or not (actual_rows[i] and actual_rows[i]:match(m))) then + local pat = nil + if actual_rows[i] and row ~= actual_rows[i] then + local after = row + while true do + local s, e, m = after:find('{MATCH:(.-)}') + if not s then + pat = pat and (pat .. pesc(after)) + break + end + pat = (pat or '') .. pesc(after:sub(1, s - 1)) .. m + after = after:sub(e + 1) + end + end + if row ~= actual_rows[i] and (not pat or not actual_rows[i]:match(pat)) then msg_expected_rows[i] = '*' .. msg_expected_rows[i] if i <= #actual_rows then actual_rows[i] = '*' .. actual_rows[i] -- cgit From 524e1a06432ed7a88c1e183d81812dd48dc18cfb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 23 Feb 2023 16:15:04 +0800 Subject: fix(highlight): avoid ORing underline flags (#22372) When combining attributes use the one that takes priority. For :highlight command use the last one specified. For API use a hard-coded order same as the order in docs. --- test/functional/ui/decorations_spec.lua | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6ed32a8cd4..4759d68200 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1045,6 +1045,83 @@ end]] end) + it('underline attribute with higher priority takes effect #22371', function() + screen:try_resize(50, 3) + insert('aaabbbaaa') + exec([[ + hi TestUL gui=underline guifg=Blue + hi TestUC gui=undercurl guisp=Red + hi TestBold gui=bold + ]]) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; + [1] = {underline = true, foreground = Screen.colors.Blue}; + [2] = {undercurl = true, special = Screen.colors.Red}; + [3] = {underline = true, foreground = Screen.colors.Blue, special = Screen.colors.Red}; + [4] = {undercurl = true, foreground = Screen.colors.Blue, special = Screen.colors.Red}; + [5] = {bold = true, underline = true, foreground = Screen.colors.Blue}; + [6] = {bold = true, undercurl = true, special = Screen.colors.Red}; + }) + + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) + screen:expect([[ + {1:aaa}{4:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) + screen:expect([[ + {2:aaa}{3:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) + screen:expect([[ + {1:aaa}{3:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) + screen:expect([[ + {2:aaa}{4:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + + -- When only one highlight group has an underline attribute, it should always take effect. + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) + screen:expect([[ + {1:aaa}{5:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) + screen:expect_unchanged(true) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) + screen:expect([[ + {2:aaa}{6:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) + screen:expect_unchanged(true) + end) + end) describe('decorations: virtual lines', function() -- cgit From 9a271f6afd7a9b1c17d694b57ee1f489496000aa Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Tue, 28 Feb 2023 03:19:58 +0100 Subject: fix(column): cmdwin cursor is offset with 'statuscolumn' (#22445) --- test/functional/ui/statuscolumn_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 287686cf37..f997546c7c 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -478,4 +478,24 @@ describe('statuscolumn', function() | ]]) end) + + it('works with cmdwin', function() + feed(':set stc=%lq:k$') + screen:expect([[ + 7 aaaaa | + 8 aaaaa | + 9 aaaaa | + 10aaaaa | + [No Name] [+] | + :1set stc=%^l | + :2 | + ~ | + ~ | + ~ | + ~ | + ~ | + [Command Line] | + : | + ]]) + end) end) -- cgit From d66832c76d6fce1627c33ae60a1b8efec1e32bdd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Mar 2023 20:16:57 +0800 Subject: test(ui): wait for another success with failure after success Problem: In a success-failure-success situation, if minimal timeout is reached between the failure and the second success, the session is stopped without waiting for the second success, causing the test to fail. Solution: Wait for another success if a failure is seen after a success. Ref #22155 #22464 --- test/functional/ui/screen.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 14ce050578..e5a449fa66 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -557,6 +557,7 @@ function Screen:_wait(check, flags) self._session:stop() end elseif success_seen and #args > 0 then + success_seen = false failure_after_success = true -- print(inspect(args)) end -- cgit From b7d59649acf43c76cc72b25c04bcae926a40b4fe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Mar 2023 12:23:04 +0800 Subject: fix(redraw): get the line again after evaluating something --- test/functional/ui/statuscolumn_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index f997546c7c..08b5d1913b 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -375,6 +375,28 @@ describe('statuscolumn', function() {1:wrapped 1 9}aaaaaaaa | | ]]) + -- Also test virt_lines at the end of buffer + exec_lua([[ + local ns = vim.api.nvim_create_namespace("ns") + vim.api.nvim_buf_set_extmark(0, ns, 15, 0, { virt_lines = {{{"END", ""}}} }) + ]]) + feed('Gzz') + screen:expect([[ + {1:buffer 0 13}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 13}aaaaaaaaa | + {1:buffer 0 14}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 14}aaaaaaaaa | + {1:buffer 0 15}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 15}aaaaaaaaa | + {4:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:wrapped 1 16}{5:aaaaaaaaa }| + {1:virtual-1 16}END | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) end) it("works with 'statuscolumn' clicks", function() -- cgit From e389b189021cb6b72cfd7583ce6fb5d8d3346d45 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 6 Mar 2023 07:52:11 +0800 Subject: vim-patch:9.0.1385: g'Esc is considered an error (#22544) Problem: g'Esc is considered an error. Solution: Make g'Esc silently abandon the command. (closes vim/vim#12110) https://github.com/vim/vim/commit/f86dea8119f3141e3d2c680219036d1511101f9b --- test/functional/ui/mode_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua index cf4eb034e0..e870d6f25f 100644 --- a/test/functional/ui/mode_spec.lua +++ b/test/functional/ui/mode_spec.lua @@ -44,7 +44,10 @@ describe('ui mode_change event', function() {0:~ }| | ]], mode="normal"} + end) + -- oldtest: Test_mouse_shape_after_failed_change() + it('is restored to Normal mode after failed "c"', function() screen:try_resize(50, 4) command('set nomodifiable') @@ -65,6 +68,25 @@ describe('ui mode_change event', function() ]], mode="normal"} end) + -- oldtest: Test_mouse_shape_after_cancelling_gr() + it('is restored to Normal mode after cancelling "gr"', function() + feed('gr') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]], mode="replace"} + + feed('') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + | + ]], mode="normal"} + end) + it('works in insert mode', function() feed('i') screen:expect{grid=[[ -- cgit From bf4eada2c83f5402fc56370fd22af11029a4a3aa Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Tue, 7 Mar 2023 01:45:08 +0100 Subject: fix(column): issues with 'statuscolumn' width (#22542) Problem: 'statuscolumn' width can be incorrect when toggling 'number' or setting 'statuscolumn'. Solution: Make sure the width is reset and re-estimated when 'statuscolumn' and 'number' are set. (When 'relativenumber' is set this already happens because it always changes "nrwidth_line_count".) --- test/functional/ui/statuscolumn_spec.lua | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 08b5d1913b..dfbdbb4898 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -520,4 +520,42 @@ describe('statuscolumn', function() : | ]]) end) + + it("has correct width when toggling '(relative)number'", function() + screen:try_resize(screen._width, 6) + command('call setline(1, repeat(["aaaaa"], 100))') + command('set relativenumber') + command([[set stc=%{!&nu&&!&rnu?'':&rnu?v:relnum?v:relnum:&nu?v:lnum:'0':v:lnum}]]) + screen:expect([[ + 1 aaaaa | + 8 ^aaaaa | + 1 aaaaa | + 2 aaaaa | + 3 aaaaa | + | + ]]) + -- width correctly estimated with "w_nrwidth_line_count" when setting 'stc' + command([[set stc=%{!&nu&&!&rnu?'':&rnu?v:relnum?v:relnum:&nu?v:lnum:'0':v:lnum}]]) + screen:expect_unchanged() + -- zero width when disabling 'number' + command('set norelativenumber nonumber') + screen:expect([[ + aaaaa | + ^aaaaa | + aaaaa | + aaaaa | + aaaaa | + | + ]]) + -- width correctly estimated with "w_nrwidth_line_count" when setting 'nu' + command('set number') + screen:expect([[ + 7 aaaaa | + 8 ^aaaaa | + 9 aaaaa | + 10 aaaaa | + 11 aaaaa | + | + ]]) + end) end) -- cgit From 1fb585a9db32ddfa563328a4ffb18b6f1e1dec1e Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Mon, 6 Mar 2023 16:50:27 +0100 Subject: test(statusline): UI elements are not redrawn on K_EVENT unnecessarily --- test/functional/ui/statusline_spec.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 1c184ff27d..c59ade0e31 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -10,6 +10,7 @@ local meths = helpers.meths local exec = helpers.exec local exec_lua = helpers.exec_lua local eval = helpers.eval +local sleep = helpers.sleep describe('statusline clicks', function() local screen @@ -589,3 +590,35 @@ it('showcmdloc=statusline does not show if statusline is too narrow', function() feed('1234') screen:expect_unchanged() end) + +it('K_EVENT does not trigger a statusline redraw unnecessarily', function() + clear() + local screen = Screen.new(40, 8) + screen:attach() + -- does not redraw on vim.schedule (#17937) + command([[ + set laststatus=2 + let g:counter = 0 + func Status() + let g:counter += 1 + lua vim.schedule(function() end) + return g:counter + endfunc + set statusline=%!Status() + ]]) + sleep(50) + eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter')) + -- also in insert mode + feed('i') + sleep(50) + eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter')) + -- does not redraw on timer call (#14303) + command([[ + let g:counter = 0 + func Timer(timer) + endfunc + call timer_start(1, 'Timer', {'repeat': 100}) + ]]) + sleep(50) + eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter')) +end) -- cgit From 8cb5b995b6e4d86035e6950d92c0c68ab4e46787 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Mar 2023 10:05:47 +0800 Subject: vim-patch:9.0.1397: highlight for popupmenu kind and extra cannot be set (#22619) Problem: Highlight for popupmenu kind and extra cannot be set. Solution: Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel highlight groups and use them. (Gianmaria Bajo, closes vim/vim#12114) https://github.com/vim/vim/commit/6a7c7749204b256e779c245b1e999bf852ad7b64 Co-authored-by: Gianmaria Bajo --- test/functional/ui/cursor_spec.lua | 4 +-- test/functional/ui/popupmenu_spec.lua | 62 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index e261f0dfab..7e28caea04 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -212,10 +212,10 @@ describe('ui/cursor', function() if m.blinkwait then m.blinkwait = 700 end end if m.hl_id then - m.hl_id = 60 + m.hl_id = 64 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 62 end + if m.id_lm then m.id_lm = 66 end end -- Assert the new expectation. diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index c681453294..944319c443 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3490,6 +3490,68 @@ describe('builtin popupmenu', function() pasted | ]]) end) + + describe('"kind" and "menu"', function() + before_each(function() + screen:try_resize(30, 8) + exec([[ + func CompleteFunc( findstart, base ) + if a:findstart + return 0 + endif + return { + \ 'words': [ + \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', }, + \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, + \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', }, + \]} + endfunc + set completeopt=menu + set completefunc=CompleteFunc + ]]) + end) + + -- oldtest: Test_pum_highlights_default() + it('default highlight groups', function() + feed('iaw') + screen:expect([[ + aword1^ | + {s:aword1 W extra text 1 }{1: }| + {n:aword2 W extra text 2 }{1: }| + {n:aword3 W extra text 3 }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- }{5:match 1 of 3} | + ]]) + end) + + -- oldtest: Test_pum_highlights_custom() + it('custom highlight groups', function() + exec([[ + hi PmenuKind guifg=Red guibg=Magenta + hi PmenuKindSel guifg=Red guibg=Grey + hi PmenuExtra guifg=White guibg=Magenta + hi PmenuExtraSel guifg=Black guibg=Grey + ]]) + local attrs = screen:get_default_attr_ids() + attrs.kn = {foreground = Screen.colors.Red, background = Screen.colors.Magenta} + attrs.ks = {foreground = Screen.colors.Red, background = Screen.colors.Grey} + attrs.xn = {foreground = Screen.colors.White, background = Screen.colors.Magenta} + attrs.xs = {foreground = Screen.colors.Black, background = Screen.colors.Grey} + feed('iaw') + screen:expect([[ + aword1^ | + {s:aword1 }{ks:W }{xs:extra text 1 }{1: }| + {n:aword2 }{kn:W }{xn:extra text 2 }{1: }| + {n:aword3 }{kn:W }{xn:extra text 3 }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- }{5:match 1 of 3} | + ]], attrs) + end) + end) end) describe('builtin popupmenu with ui/ext_multigrid', function() -- cgit From 9d574f8dd7248a4cf8dcbe615f3058d34efb7ac3 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Mar 2023 22:56:16 +0100 Subject: ci: bump to windows 2022 Skip failing funcitonaltests. Use jobstart() instead termopen() for oldtests to prevent CI freezing. --- test/functional/ui/output_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 223844405e..954431d689 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -54,6 +54,7 @@ describe("shell command :!", function() it("throttles shell-command output greater than ~10KB", function() skip(is_os('openbsd'), 'FIXME #10804') + skip(is_os('win')) child_session.feed_data((":!%s REP 30001 foo\n"):format(testprg('shell-test'))) -- If we observe any line starting with a dot, then throttling occurred. -- cgit From 1c4b3d41b538078234282cfba74e5cf07c42c916 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Mar 2023 10:40:27 +0800 Subject: fix(sleep): correct cursor placement (#22639) Just setcursor_mayforce(true) is enough as Nvim uses msg_grid. --- test/functional/ui/float_spec.lua | 274 +++++++++++++++++++++++++++++++++++++- 1 file changed, 273 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6759510ad1..6e67ec1f24 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8909,7 +8909,6 @@ describe('float window', function() ]], win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; }} - else screen:expect{grid=[[ ^ | @@ -8952,6 +8951,279 @@ describe('float window', function() test_float_move_close('autocmd BufWinLeave * ++once redraw') end) end) + + it(':sleep cursor placement #22639', function() + local float_opts = {relative = 'editor', row = 1, col = 1, width = 4, height = 3} + local win = meths.open_win(meths.create_buf(false, false), true, float_opts) + feed('iabcd') + feed(':sleep 100') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100^ | + ## grid 4 + {1:ab }| + {1:cd }| + {2:~ }| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{1:ab }{0: }| + {0:~}{1:cd }{0: }| + {0:~}{2:~ }{0: }| + {0:~ }| + {0:~ }| + :sleep 100^ | + ]]} + end + + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100 | + ## grid 4 + {1:ab }| + {1:c^d }| + {2:~ }| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{1:ab }{0: }| + {0:~}{1:c^d }{0: }| + {0:~}{2:~ }{0: }| + {0:~ }| + {0:~ }| + :sleep 100 | + ]]} + end + feed('') + screen:expect_unchanged() + + meths.win_set_config(win, {border = 'single'}) + feed(':sleep 100') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100^ | + ## grid 4 + {5:┌────┐}| + {5:│}{1:ab }{5:│}| + {5:│}{1:cd }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌────┐}{0: }| + {0:~}{5:│}{1:ab }{5:│}{0: }| + {0:~}{5:│}{1:cd }{5:│}{0: }| + {0:~}{5:│}{2:~ }{5:│}{0: }| + {0:~}{5:└────┘}{0: }| + :sleep 100^ | + ]]} + end + + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100 | + ## grid 4 + {5:┌────┐}| + {5:│}{1:ab }{5:│}| + {5:│}{1:c^d }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌────┐}{0: }| + {0:~}{5:│}{1:ab }{5:│}{0: }| + {0:~}{5:│}{1:c^d }{5:│}{0: }| + {0:~}{5:│}{2:~ }{5:│}{0: }| + {0:~}{5:└────┘}{0: }| + :sleep 100 | + ]]} + end + feed('') + screen:expect_unchanged() + + command('setlocal winbar=foo') + feed(':sleep 100') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100^ | + ## grid 4 + {5:┌────┐}| + {5:│}{3:foo }{5:│}| + {5:│}{1:ab }{5:│}| + {5:│}{1:cd }{5:│}| + {5:└────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌────┐}{0: }| + {0:~}{5:│}{3:foo }{5:│}{0: }| + {0:~}{5:│}{1:ab }{5:│}{0: }| + {0:~}{5:│}{1:cd }{5:│}{0: }| + {0:~}{5:└────┘}{0: }| + :sleep 100^ | + ]]} + end + + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :sleep 100 | + ## grid 4 + {5:┌────┐}| + {5:│}{3:foo }{5:│}| + {5:│}{1:ab }{5:│}| + {5:│}{1:c^d }{5:│}| + {5:└────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌────┐}{0: }| + {0:~}{5:│}{3:foo }{5:│}{0: }| + {0:~}{5:│}{1:ab }{5:│}{0: }| + {0:~}{5:│}{1:c^d }{5:│}{0: }| + {0:~}{5:└────┘}{0: }| + :sleep 100 | + ]]} + end + feed('') + screen:expect_unchanged() + end) end describe('with ext_multigrid', function() -- cgit From 172227a44642b67ec8af5b438e5373a3daf61fdb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Mar 2023 12:10:27 +0800 Subject: fix(screen): correctly draw background and eob with 'rightleft' (#22640) --- test/functional/ui/float_spec.lua | 49 +++++++++++++++++++++++++++++++++++ test/functional/ui/highlight_spec.lua | 16 ++++++++++++ 2 files changed, 65 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6e67ec1f24..4e691512c1 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -9224,6 +9224,55 @@ describe('float window', function() feed('') screen:expect_unchanged() end) + + it('with rightleft and border #22640', function() + local float_opts = {relative='editor', width=5, height=3, row=1, col=1, border='single'} + meths.open_win(meths.create_buf(false, false), true, float_opts) + command('setlocal rightleft') + feed('iabcdef') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:┌─────┐}| + {5:│}{1: cba}{5:│}| + {5:│}{1: ^fed}{5:│}| + {5:│}{2: ~}{5:│}| + {5:└─────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌─────┐}{0: }| + {0:~}{5:│}{1: cba}{5:│}{0: }| + {0:~}{5:│}{1: ^fed}{5:│}{0: }| + {0:~}{5:│}{2: ~}{5:│}{0: }| + {0:~}{5:└─────┘}{0: }| + | + ]]} + end + end) end describe('with ext_multigrid', function() diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 288c2a214f..2bbc29b78f 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1812,6 +1812,22 @@ describe("'winhighlight' highlight", function() ]]) end) + it('works for background color in rightleft window in vsplit #22640', function() + screen:try_resize(40, 6) + insert('aa') + command('setlocal rightleft') + command('botright vsplit') + command('setlocal winhl=Normal:Background1') + screen:expect([[ + aa│{1: ^aa}| + {0: ~}│{2: ~}| + {0: ~}│{2: ~}| + {0: ~}│{2: ~}| + {4:[No Name] [+] }{3:[No Name] [+] }| + | + ]]) + end) + it('handles undefined groups', function() command("set winhl=Normal:Background1") screen:expect([[ -- cgit From 314f20a44fdfdc382b0ce9d124290d3e7d702d42 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Mar 2023 15:41:39 +0800 Subject: test: use a wider screen in the rightleft winhl test (#22641) With a wide screen this actually previously caused an overflow. --- test/functional/ui/highlight_spec.lua | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 2bbc29b78f..d5e0eefb41 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1812,19 +1812,28 @@ describe("'winhighlight' highlight", function() ]]) end) - it('works for background color in rightleft window in vsplit #22640', function() - screen:try_resize(40, 6) + it('works for background color in rightleft window #22640', function() + -- Use a wide screen to also check that this doesn't overflow linebuf_attr. + screen:try_resize(80, 6) insert('aa') command('setlocal rightleft') - command('botright vsplit') command('setlocal winhl=Normal:Background1') screen:expect([[ - aa│{1: ^aa}| - {0: ~}│{2: ~}| - {0: ~}│{2: ~}| - {0: ~}│{2: ~}| - {4:[No Name] [+] }{3:[No Name] [+] }| - | + {1: ^aa}| + {2: ~}| + {2: ~}| + {2: ~}| + {2: ~}| + | + ]]) + command('botright vsplit') + screen:expect([[ + {1: aa│ ^aa}| + {2: ~}{1:│}{2: ~}| + {2: ~}{1:│}{2: ~}| + {2: ~}{1:│}{2: ~}| + {4:[No Name] [+] }{3:[No Name] [+] }| + | ]]) end) -- cgit From 846a056744bf458d4376cd7638c94f7c82862046 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 9 Mar 2023 11:45:20 +0100 Subject: refactor(redraw): make cursor position redraw use the "redraw later" pattern --- test/functional/ui/messages_spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 212d3aee7d..db45e80dae 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -474,8 +474,7 @@ describe('ui/ext_messages', function() ]], msg_history={{ content = {{ "stuff" }}, kind = "echomsg", - }}, showmode={{ "-- INSERT --", 3 }}, - messages={{ + }}, messages={{ content = {{ "Press ENTER or type command to continue", 4}}, kind = "return_prompt" }}} -- cgit From fd2ece278b0941ec6673489e88868120e86b834a Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Sun, 12 Mar 2023 23:58:46 +0100 Subject: feat(ui): add scroll_delta to win_viewport event #19270 scroll_delta contains how much the top line of a window moved since the last time win_viewport was emitted. It is expected to be used to implement smooth scrolling. For this purpose it only counts "virtual" or "displayed" so folds should count as one line. Because of this it adds extra information that cannot be computed from the topline parameter. Fixes #19227 --- test/functional/ui/cmdline_spec.lua | 4 +- test/functional/ui/float_spec.lua | 169 +++++++++++++++++----------------- test/functional/ui/multigrid_spec.lua | 91 ++++++++++++++---- test/functional/ui/screen.lua | 9 +- test/functional/ui/searchhl_spec.lua | 4 +- 5 files changed, 167 insertions(+), 110 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 1c9ac7f7ba..a9469bdf2d 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1241,7 +1241,7 @@ describe('cmdheight=0', function() {1:~ }| ## grid 3 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} feed '/p' @@ -1261,7 +1261,7 @@ describe('cmdheight=0', function() ## grid 3 /p^ | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} end) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 4e691512c1..62e8221e87 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1433,8 +1433,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1476,8 +1476,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1519,8 +1519,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1562,8 +1562,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1606,8 +1606,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1647,8 +1647,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1688,8 +1688,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1731,8 +1731,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1781,8 +1781,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1868,8 +1868,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1911,8 +1911,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1954,8 +1954,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1997,8 +1997,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2048,8 +2048,8 @@ describe('float window', function() ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 0, 0, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2106,8 +2106,8 @@ describe('float window', function() ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 0, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2165,8 +2165,8 @@ describe('float window', function() [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 }, [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2618,7 +2618,8 @@ describe('float window', function() curline = 0, curcol = 3, linecount = 2, - win = { id = 1000 } + sum_scroll_delta = 0, + win = { id = 1000 }, }, [4] = { topline = 0, @@ -2626,6 +2627,7 @@ describe('float window', function() curline = 0, curcol = 3, linecount = 2, + sum_scroll_delta = 0, win = { id = 1001 } }, [5] = { @@ -2634,6 +2636,7 @@ describe('float window', function() curline = 0, curcol = 0, linecount = 1, + sum_scroll_delta = 0, win = { id = 1002 } } }} @@ -7149,8 +7152,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'press', '', 5, 0, 0) @@ -7179,8 +7182,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'drag', '', 5, 1, 2) @@ -7209,8 +7212,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7279,8 +7282,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'press', '', 5, 1, 1) @@ -7311,8 +7314,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'drag', '', 5, 2, 3) @@ -7343,8 +7346,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7413,8 +7416,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'press', '', 5, 1, 0) @@ -7444,8 +7447,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} meths.input_mouse('left', 'drag', '', 5, 2, 2) @@ -7475,8 +7478,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8228,8 +8231,8 @@ describe('float window', function() ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8285,10 +8288,10 @@ describe('float window', function() [5] = { { id = 1002 }, "NW", 1, 3, 8, true }; [6] = { { id = 1003 }, "NW", 1, 4, 10, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8333,8 +8336,8 @@ describe('float window', function() ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8390,10 +8393,10 @@ describe('float window', function() [5] = { { id = 1002 }, "NW", 1, 4, 10, true }; [6] = { { id = 1003 }, "NW", 1, 3, 8, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8453,10 +8456,10 @@ describe('float window', function() [5] = {{id = 1002}, "NW", 1, 2, 6, true, 50}; [6] = {{id = 1003}, "NW", 1, 3, 7, true, 40}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8502,8 +8505,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8549,8 +8552,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 0, 4, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8604,8 +8607,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8658,8 +8661,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8701,7 +8704,7 @@ describe('float window', function() {0:~ }| ## grid 3 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8756,8 +8759,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8816,8 +8819,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8865,8 +8868,8 @@ describe('float window', function() ]], float_pos={ [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8907,7 +8910,7 @@ describe('float window', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 71adeb42a4..2525314b8e 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -2127,7 +2127,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1} + [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} }} insert([[ Lorem ipsum dolor sit amet, consectetur @@ -2162,7 +2162,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11}, + [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, }} @@ -2187,7 +2187,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 9, curline = 7, curcol = 0, linecount = 11}, + [2] = {win = {id = 1000}, topline = 2, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 2}, }} command("split") @@ -2211,8 +2211,8 @@ describe('ext_multigrid', function() reprehenderit in voluptate velit esse cillum | ^dolore eu fugiat nulla pariatur. Excepteur sint | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11}, - [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 7, curcol = 0, linecount = 11}, + [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 5}, }} feed("b") @@ -2236,8 +2236,8 @@ describe('ext_multigrid', function() reprehenderit in voluptate velit esse ^cillum | dolore eu fugiat nulla pariatur. Excepteur sint | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11}, - [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 6, curcol = 38, linecount = 11}, + [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 6, curcol = 38, linecount = 11, sum_scroll_delta = 5}, }} feed("2k") @@ -2261,8 +2261,8 @@ describe('ext_multigrid', function() ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11}, - [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11}, + [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, }} -- handles non-current window @@ -2287,8 +2287,59 @@ describe('ext_multigrid', function() ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11}, - [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11}, + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, + }} + + -- sum_scroll_delta works with folds + feed('zfj') + screen:expect{grid=[[ + ## grid 1 + [4:------------------------------------------------]| + [4:------------------------------------------------]| + [4:------------------------------------------------]| + {11:[No Name] [+] }| + [2:------------------------------------------------]| + [2:------------------------------------------------]| + {12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet, consectetur | + adipisicing elit, sed do eiusmod tempor | + ## grid 3 + | + ## grid 4 + {13:^+-- 2 lines: exercitation ullamco laboris nisi }| + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = {id = 1001}, topline = 4, botline = 9, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, + }} + + feed('') + screen:expect{grid=[[ + ## grid 1 + [4:------------------------------------------------]| + [4:------------------------------------------------]| + [4:------------------------------------------------]| + {11:[No Name] [+] }| + [2:------------------------------------------------]| + [2:------------------------------------------------]| + {12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet, consectetur | + adipisicing elit, sed do eiusmod tempor | + ## grid 3 + | + ## grid 4 + ^reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = {id = 1001}, topline = 6, botline = 10, curline = 6, curcol = 0, linecount = 11, sum_scroll_delta = 5}, }} end) @@ -2314,7 +2365,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1} + [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} }} insert([[ Lorem ipsum dolor sit amet, consectetur @@ -2349,7 +2400,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11}, + [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, }} meths.input_mouse('left', 'press', '', 1,5, 1) @@ -2376,7 +2427,7 @@ describe('ext_multigrid', function() ## grid 3 {7:-- VISUAL --} | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11}, + [2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11, sum_scroll_delta = 6}, }} end) @@ -2414,8 +2465,8 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} -- XXX: hack to get notifications. Could use next_msg() also. @@ -2459,8 +2510,8 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} eq({}, win_pos) @@ -2497,8 +2548,8 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} eq({}, win_pos) end) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index e5a449fa66..f5ae9c8e89 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -803,14 +803,17 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height) self.float_pos[grid] = nil end -function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount) +function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount, scroll_delta) + -- accumulate scroll delta + local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta or 0 self.win_viewport[grid] = { win = win, topline = topline, botline = botline, curline = curline, curcol = curcol, - linecount = linecount + linecount = linecount, + sum_scroll_delta = scroll_delta + last_scroll_delta } end @@ -1348,7 +1351,7 @@ local function fmt_ext_state(name, state) for k,v in pairs(state) do str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol..", linecount = "..v.linecount.."};\n") + ..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n") end return str .. "}" elseif name == "float_pos" then diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 916a5eb537..3c8dceb8cb 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -52,7 +52,7 @@ describe('search highlighting', function() {1:~ }| /text^ | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2, sum_scroll_delta = 0}; }} end) @@ -616,7 +616,7 @@ describe('search highlighting', function() {1:~ }| {4:search hit BOTTOM, continuing at TOP} | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2, sum_scroll_delta = 0}; }} -- check highlights work also in folds -- cgit From 5aec6114693dea442023857e071bf6f90c8c109a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Mar 2023 08:14:02 +0800 Subject: test(float_spec): add missing sum_scroll_delta #22648 --- test/functional/ui/float_spec.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 62e8221e87..bae83537e5 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8986,8 +8986,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9028,8 +9028,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9075,8 +9075,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9119,8 +9119,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9166,8 +9166,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9210,8 +9210,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9261,8 +9261,8 @@ describe('float window', function() ]], float_pos={ [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2}; + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ -- cgit From 3e8955094a615f2a805350050bc1703a294b1b85 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 14 Mar 2023 02:12:26 +0100 Subject: test: re-bundle cat on windows (#21255) The builtin cat was removed in 4bc9229ecbec514e9a87cfc4be88ea27a971e9a1 as it is not used during runtime but only for tests. However, it is a very small and useful utility program that we need for a lot of our tests, so there's no harm in bundling it, and it helps us avoid complicating our build system by having two versions of neovim (neovim for users and neovim for testing). Also skip tests if "grep" or "sleep" isn't available. --- test/functional/ui/messages_spec.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index db45e80dae..a92b55ae5d 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -16,6 +16,8 @@ local poke_eventloop = helpers.poke_eventloop local assert_alive = helpers.assert_alive local is_os = helpers.is_os local is_ci = helpers.is_ci +local funcs = helpers.funcs +local skip = helpers.skip describe('ui/ext_messages', function() local screen @@ -1916,6 +1918,7 @@ aliquip ex ea commodo consequat.]]) end) it('with :!cmd does not crash on resize', function() + skip(funcs.executable('sleep') == 0, 'missing "sleep" command') feed(':!sleep 1') screen:expect{grid=[[ | -- cgit From 0f1e2b6686694d878795fa090d4a08ba0f8acb4d Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 13 Mar 2023 20:38:21 +0100 Subject: fix(screen): redraw the ruler for a current floating window Semi-regression. The "ruler" behavior for a floating window was never really specified but in practice followed the users cursor movements in normal mode in a focused float, which seems like a reasonable behavior to now specify. --- test/functional/ui/float_spec.lua | 92 +++++++++++++++++++++++++++++++++++++++ test/functional/ui/screen.lua | 2 +- 2 files changed, 93 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index bae83537e5..5916c8e238 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -2184,6 +2184,98 @@ describe('float window', function() end end) + it('show ruler of current floating window', function() + command 'set ruler' + local buf = meths.create_buf(false, false) + meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ', + 'abb acc '}) + meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5}) + feed 'gg' + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + 1,1 All | + ## grid 5 + {1:^aaa aab }| + {1:abb acc }| + {2:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {1:^aaa aab } | + {0:~ }{1:abb acc }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + 1,1 All | + ]]} + end + + feed 'w' + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + 1,5 All | + ## grid 5 + {1:aaa ^aab }| + {1:abb acc }| + {2:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {1:aaa ^aab } | + {0:~ }{1:abb acc }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + 1,5 All | + ]]} + end + end) + it('can have minimum size', function() insert("the background text") local buf = meths.create_buf(false, true) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f5ae9c8e89..83424d3bea 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1351,7 +1351,7 @@ local function fmt_ext_state(name, state) for k,v in pairs(state) do str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n") + ..", curcol = "..v.curcol..", linecount = "..v.linecount..", sum_scroll_delta = "..v.sum_scroll_delta.."};\n") end return str .. "}" elseif name == "float_pos" then -- cgit From eb3fcf652bbcab01cd6d55a0e2c120c09cbe69d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Mar 2023 21:19:34 +0800 Subject: vim-patch:9.0.0194: cursor displayed in wrong position after removing text prop (#22706) Problem: Cursor displayed in wrong position after removing text prop. (Ben Jackson) Solution: Invalidate the cursor position. (closes vim/vim#10898) https://github.com/vim/vim/commit/326c5d36e7cb8526330565109c17b4a13ff790ae Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4759d68200..d03d2f1374 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1247,6 +1247,7 @@ if (h->n_buckets < new_n_buckets) { // expand ]]} meths.buf_clear_namespace(0, ns, 0, -1) + -- Cursor should be drawn on the correct line. #22704 screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | khkey_t *new_keys = (khkey_t *) | @@ -1254,8 +1255,8 @@ if (h->n_buckets < new_n_buckets) { // expand hkey_t)); | h->keys = new_keys; | if (kh_is_map && val_size) { | - char *new_vals = {3:krealloc}( h->vals_buf, new_n_| - buck^ets * val_size); | + ^char *new_vals = {3:krealloc}( h->vals_buf, new_n_| + buckets * val_size); | h->vals_buf = new_vals; | } | } | @@ -1263,7 +1264,6 @@ if (h->n_buckets < new_n_buckets) { // expand ]]} end) - it('works with text at the beginning of the buffer', function() insert(example_text) feed 'gg' -- cgit From 8bdcc91dc8ae1d7a0734945935300e002eb879c1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Mar 2023 16:50:22 +0800 Subject: test(highlight_spec): fix warning in Visual highlight test (#22719) Problem: Warning in Visual highlight test. Solution: Don't move cursor back and forth. --- test/functional/ui/highlight_spec.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index d5e0eefb41..dce886ac91 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -376,7 +376,6 @@ describe('highlight', function() -- Vertical cursor: highlights char-at-cursor. #8983 command('set guicursor=a:block-blinkon175') - feed('gg$vhhh') screen:expect([[ line1 foo{1:^ bar} | | -- cgit From 8916669d50243f6d4cdfb9480ef1b4e7ccdcfbb6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Mar 2023 19:06:24 +0800 Subject: test(statuscolumn_spec): remove unnecessary feed('lh') It is no longer needed after #22706. --- test/functional/ui/statuscolumn_spec.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index dfbdbb4898..d9385ef221 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -461,7 +461,6 @@ describe('statuscolumn', function() vim.api.nvim_buf_set_extmark(0, ns, 7, 0, { virt_lines_leftcol = true, virt_lines = {{{"virt", ""}}} }) ]]) - feed('lh') -- force update cursor row screen:expect([[ 4 aaaaa | 5 aaaaa | -- cgit From 204a8b17c8ebab1619cc47a920a06dcc348d75f7 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Sat, 18 Mar 2023 12:44:44 +0100 Subject: fix(column): rebuild status column when sign column is invalidated (#22690) * fix(column): rebuild status column when sign column is invalidated Problem: When implementing a custom sign column through `'statuscolumn'`, the status column is not properly rebuilt when the sign column width changes. Solution: Force a rebuild of the status column when the sign column width is invalidated. * test(column): 'statuscolumn' has correct width when (un)placing signs --- test/functional/ui/statuscolumn_spec.lua | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index d9385ef221..0a253455ad 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -557,4 +557,40 @@ describe('statuscolumn', function() | ]]) end) + + it("has correct width with custom sign column when (un)placing signs", function() + screen:try_resize(screen._width, 6) + exec_lua([[ + vim.cmd.norm('gg') + vim.o.signcolumn = 'no' + vim.fn.sign_define('sign', { text = 'ss' }) + _G.StatusCol = function() + local s = vim.fn.sign_getplaced(1)[1].signs + local sign = '' + if #s > 0 then + sign = vim.v.lnum == 5 and 'ss' or ' ' + end + return vim.v.lnum .. '%=' .. sign + end + vim.o.statuscolumn = "%!v:lua.StatusCol()" + vim.fn.sign_place(0, '', 'sign', 1, { lnum = 5 }) + ]]) + screen:expect([[ + 1 ^aaaaa | + 2 aaaaa | + 3 aaaaa | + 4 aaaaa | + 5 ssaaaaa | + | + ]]) + command('sign unplace 1') + screen:expect([[ + 1 ^aaaaa | + 2 aaaaa | + 3 aaaaa | + 4 aaaaa | + 5 aaaaa | + | + ]]) + end) end) -- cgit From 3b28fb4cd9e1ef877968b4ffabf4d6b1cb17aa07 Mon Sep 17 00:00:00 2001 From: Patrick McFarland Date: Tue, 14 Mar 2023 13:21:53 -0400 Subject: fix(float): remove -1 in height clamp Problem: Clamp for height in floating windows enforced no more than editor height - 1, disallowing full editor height floating windows when using cmdheight=0 Solution: Clamp to full height, removing the -1. Tested to give the intended results with cmdheight=0, 1, or more than 1. This also inadvertently fixes a rendering error with cmdheight >1 where the bottom border would be overlapped by the cmdline. --- test/functional/ui/float_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 5916c8e238..32f28dce26 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -2015,7 +2015,7 @@ describe('float window', function() it('terminates border on edge of viewport when window extends past viewport', function() local buf = meths.create_buf(false, false) - meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single"}) + meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2046,7 +2046,7 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 0, true } + [4] = { { id = 1001 }, "NW", 1, 0, 0, true, 201 } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; @@ -2058,8 +2058,8 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:│}{2:~ }{5:│}| {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| {5:└──────────────────────────────────────┘}| - | ]]} end end) @@ -3723,9 +3723,9 @@ describe('float window', function() ]], float_pos=expected_pos} else screen:expect([[ - {1:very } | - {0:~ }{1:^float }{0: }| - | + {1:such } | + {0:~ }{1:very }{0: }| + ^ | ]]) end -- cgit From fe9cbcb3a5c82932ecfb8f49d07e98a1fc2b31e5 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sat, 25 Mar 2023 18:58:48 +0200 Subject: feat(api): nvim_exec2(), deprecate nvim_exec() #19032 Problem: The signature of nvim_exec() is not extensible per ":help api-contract". Solution: Introduce nvim_exec2() and deprecate nvim_exec(). --- test/functional/ui/cmdline_highlight_spec.lua | 8 ++++---- test/functional/ui/messages_spec.lua | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index eb5de693bd..d6c8408f04 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -362,7 +362,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec('messages', true)) + eq('', meths.exec2('messages', { output = true }).output) end) it('silences :echon', function() set_color_cb('Echoning') @@ -377,7 +377,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec('messages', true)) + eq('', meths.exec2('messages', { output = true }).output) end) it('silences :echomsg', function() set_color_cb('Echomsging') @@ -392,7 +392,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec('messages', true)) + eq('', meths.exec2('messages', { output = true }).output) end) it('does the right thing when throwing', function() set_color_cb('Throwing') @@ -858,7 +858,7 @@ describe('Ex commands coloring', function() ]]) feed('') eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: empty buffer', - meths.exec('messages', true)) + meths.exec2('messages', { output = true }).output) end) it('errors out when failing to get callback', function() meths.set_var('Nvim_color_cmdline', 42) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a92b55ae5d..81602ef92e 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -986,7 +986,7 @@ describe('ui/builtin messages', function() -- screen size doesn't affect internal output #10285 eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', - meths.exec("hi ErrorMsg", true)) + meths.exec2("hi ErrorMsg", { output = true }).output) end) it(':syntax list langGroup output', function() @@ -1025,7 +1025,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim match /\ Date: Sun, 26 Mar 2023 10:49:32 +0800 Subject: test: use exec_capture() in more places (#22787) Problem: Using `meths.exec2("code", { output = true })` is too verbose. Solution: Use exec_capture() in more places. --- test/functional/ui/cmdline_highlight_spec.lua | 9 +++++---- test/functional/ui/messages_spec.lua | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index d6c8408f04..783246c6e4 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -7,6 +7,7 @@ local clear = helpers.clear local meths = helpers.meths local funcs = helpers.funcs local source = helpers.source +local exec_capture = helpers.exec_capture local dedent = helpers.dedent local command = helpers.command local curbufmeths = helpers.curbufmeths @@ -362,7 +363,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec2('messages', { output = true }).output) + eq('', exec_capture('messages')) end) it('silences :echon', function() set_color_cb('Echoning') @@ -377,7 +378,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec2('messages', { output = true }).output) + eq('', exec_capture('messages')) end) it('silences :echomsg', function() set_color_cb('Echomsging') @@ -392,7 +393,7 @@ describe('Command-line coloring', function() {EOB:~ }| :e^ | ]]) - eq('', meths.exec2('messages', { output = true }).output) + eq('', exec_capture('messages')) end) it('does the right thing when throwing', function() set_color_cb('Throwing') @@ -858,7 +859,7 @@ describe('Ex commands coloring', function() ]]) feed('') eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: empty buffer', - meths.exec2('messages', { output = true }).output) + exec_capture('messages')) end) it('errors out when failing to get callback', function() meths.set_var('Nvim_color_cmdline', 42) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 81602ef92e..5220f3fa89 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -10,6 +10,7 @@ local async_meths = helpers.async_meths local test_build_dir = helpers.test_build_dir local nvim_prog = helpers.nvim_prog local exec = helpers.exec +local exec_capture = helpers.exec_capture local exc_exec = helpers.exc_exec local exec_lua = helpers.exec_lua local poke_eventloop = helpers.poke_eventloop @@ -986,7 +987,7 @@ describe('ui/builtin messages', function() -- screen size doesn't affect internal output #10285 eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', - meths.exec2("hi ErrorMsg", { output = true }).output) + exec_capture("hi ErrorMsg")) end) it(':syntax list langGroup output', function() @@ -1025,7 +1026,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim match /\ Date: Sat, 1 Apr 2023 03:55:43 +0200 Subject: fix(ui): recording change doesn't trigger statusline redraw --- test/functional/ui/statusline_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index c59ade0e31..ffd45a59a3 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -622,3 +622,17 @@ it('K_EVENT does not trigger a statusline redraw unnecessarily', function() sleep(50) eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter')) end) + +it('statusline is redrawn on recording state change #22683', function() + clear() + local screen = Screen.new(40, 4) + screen:attach() + command('set ls=2 stl=%{repeat(reg_recording(),5)}') + feed('qQ') + screen:expect([[ + ^ | + ~ | + QQQQQ | + recording @Q | + ]]) +end) -- cgit From 2a10f64e254375e77e1c5a6aeae3cd65cd122afb Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 25 Mar 2023 02:24:24 +0100 Subject: feat(extmarks): extend nvim_buf_get_extmarks() Problem: Can not get all extmarks in a buffer. Properties are missing from the details array. Solution: Allow getting all extmarks in a buffer by supplying a -1 "ns_id". Add missing properties to the details array. --- test/functional/ui/bufhl_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index adec0770de..5263fb4c24 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -766,6 +766,7 @@ describe('Buffer highlighting', function() -- an existing virtual text. We might add a prioritation system. set_virtual_text(id1, 0, s1, {}) eq({{1, 0, 0, { + ns_id = 1, priority = 0, virt_text = s1, -- other details @@ -778,6 +779,7 @@ describe('Buffer highlighting', function() local lastline = line_count() set_virtual_text(id1, line_count(), s2, {}) eq({{3, lastline, 0, { + ns_id = 1, priority = 0, virt_text = s2, -- other details -- cgit From c8a28b847e2b814b44fe77b46f7f4564ab59f0ac Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 1 Apr 2023 03:11:56 +0200 Subject: fix(ui): ruler is not redrawn in cmdline with redrawstatus --- test/functional/ui/statusline_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index ffd45a59a3..8e301dc70c 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -636,3 +636,20 @@ it('statusline is redrawn on recording state change #22683', function() recording @Q | ]]) end) + +it('ruler is redrawn in cmdline with redrawstatus #22804', function() + clear() + local screen = Screen.new(40, 2) + screen:attach() + command([[ + let g:n = 'initial value' + set ls=1 ru ruf=%{g:n} + redraw + let g:n = 'other value' + redrawstatus + ]]) + screen:expect([[ + ^ | + other value | + ]]) +end) -- cgit From 269dd747b6e61842856031ca14ac26ee884ede4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 2 Apr 2023 23:01:48 +0800 Subject: refactor(defaults)!: change default 'commentstring' value to empty (#22862) --- test/functional/ui/fold_spec.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index c8a3397a86..96e28c1978 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2032,8 +2032,11 @@ describe("folded lines", function() end) it('multibyte fold markers work #20438', function() - meths.win_set_option(0, 'foldmethod', 'marker') - meths.win_set_option(0, 'foldmarker', '«,»') + exec([[ + setlocal foldmethod=marker + setlocal foldmarker=«,» + setlocal commentstring=/*%s*/ + ]]) insert([[ bbbbb bbbbb -- cgit From 34ac75b32927328a0c691c5bda987c0fdb5ce9eb Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 5 Apr 2023 17:19:53 +0100 Subject: refactor: rename local API alias from a to api Problem: Codebase inconsistently binds vim.api onto a or api. Solution: Use api everywhere. a as an identifier is too short to have at the module level. --- test/functional/ui/decorations_spec.lua | 52 ++++++++++++++++----------------- test/functional/ui/float_spec.lua | 12 ++++---- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index d03d2f1374..80e5b6230e 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -47,15 +47,15 @@ describe('decorations providers', function() local function setup_provider(code) return exec_lua ([[ - local a = vim.api - _G.ns1 = a.nvim_create_namespace "ns1" + local api = vim.api + _G.ns1 = api.nvim_create_namespace "ns1" ]] .. (code or [[ beamtrace = {} local function on_do(kind, ...) table.insert(beamtrace, {kind, ...}) end ]]) .. [[ - a.nvim_set_decoration_provider(_G.ns1, { + api.nvim_set_decoration_provider(_G.ns1, { on_start = on_do; on_buf = on_do; on_win = on_do; on_line = on_do; on_end = on_do; _on_spell_nav = on_do; @@ -75,8 +75,8 @@ describe('decorations providers', function() -- rather than append, which used to spin in an infinite loop allocating -- memory until nvim crashed/was killed. setup_provider([[ - local ns2 = a.nvim_create_namespace "ns2" - a.nvim_set_decoration_provider(ns2, {}) + local ns2 = api.nvim_create_namespace "ns2" + api.nvim_set_decoration_provider(ns2, {}) ]]) helpers.assert_alive() end) @@ -132,12 +132,12 @@ describe('decorations providers', function() it('can have single provider', function() insert(mulholland) setup_provider [[ - local hl = a.nvim_get_hl_id_by_name "ErrorMsg" - local test_ns = a.nvim_create_namespace "mulholland" + local hl = api.nvim_get_hl_id_by_name "ErrorMsg" + local test_ns = api.nvim_create_namespace "mulholland" function on_do(event, ...) if event == "line" then local win, buf, line = ... - a.nvim_buf_set_extmark(buf, test_ns, line, line, + api.nvim_buf_set_extmark(buf, test_ns, line, line, { end_line = line, end_col = line+1, hl_group = hl, ephemeral = true @@ -172,11 +172,11 @@ describe('decorations providers', function() ]] setup_provider [[ - local ns = a.nvim_create_namespace "spell" + local ns = api.nvim_create_namespace "spell" beamtrace = {} local function on_do(kind, ...) if kind == 'win' or kind == 'spell' then - a.nvim_buf_set_extmark(0, ns, 0, 0, { + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 2, end_col = 23, spell = true, @@ -330,12 +330,12 @@ describe('decorations providers', function() ]]} exec_lua [[ - local a = vim.api - local thewin = a.nvim_get_current_win() - local ns2 = a.nvim_create_namespace 'ns2' - a.nvim_set_decoration_provider (ns2, { + local api = vim.api + local thewin = api.nvim_get_current_win() + local ns2 = api.nvim_create_namespace 'ns2' + api.nvim_set_decoration_provider (ns2, { on_win = function (_, win, buf) - a.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2) + api.nvim_set_hl_ns_fast(win == thewin and _G.ns1 or ns2) end; }) ]] @@ -436,12 +436,12 @@ describe('decorations providers', function() it('can have virtual text', function() insert(mulholland) setup_provider [[ - local hl = a.nvim_get_hl_id_by_name "ErrorMsg" - local test_ns = a.nvim_create_namespace "mulholland" + local hl = api.nvim_get_hl_id_by_name "ErrorMsg" + local test_ns = api.nvim_create_namespace "mulholland" function on_do(event, ...) if event == "line" then local win, buf, line = ... - a.nvim_buf_set_extmark(buf, test_ns, line, 0, { + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { virt_text = {{'+', 'ErrorMsg'}}; virt_text_pos='overlay'; ephemeral = true; @@ -465,12 +465,12 @@ describe('decorations providers', function() it('can have virtual text of the style: right_align', function() insert(mulholland) setup_provider [[ - local hl = a.nvim_get_hl_id_by_name "ErrorMsg" - local test_ns = a.nvim_create_namespace "mulholland" + local hl = api.nvim_get_hl_id_by_name "ErrorMsg" + local test_ns = api.nvim_create_namespace "mulholland" function on_do(event, ...) if event == "line" then local win, buf, line = ... - a.nvim_buf_set_extmark(buf, test_ns, line, 0, { + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}}; virt_text_pos='right_align'; ephemeral = true; @@ -494,12 +494,12 @@ describe('decorations providers', function() it('can highlight beyond EOL', function() insert(mulholland) setup_provider [[ - local test_ns = a.nvim_create_namespace "veberod" + local test_ns = api.nvim_create_namespace "veberod" function on_do(event, ...) if event == "line" then local win, buf, line = ... - if string.find(a.nvim_buf_get_lines(buf, line, line+1, true)[1], "buf") then - a.nvim_buf_set_extmark(buf, test_ns, line, 0, { + if string.find(api.nvim_buf_get_lines(buf, line, line+1, true)[1], "buf") then + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { end_line = line+1; hl_group = 'DiffAdd'; hl_eol = true; @@ -534,9 +534,9 @@ describe('decorations providers', function() local function on_do(kind, winid, bufnr, topline, botline_guess) if kind == 'win' then if topline < 100 and botline_guess > 100 then - vim.api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' }) + api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' }) else - vim.api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1) + api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1) end end end diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 32f28dce26..4612ffe56f 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -65,20 +65,20 @@ describe('float window', function() it('closed immediately by autocmd #11383', function() eq('Window was closed immediately', pcall_err(exec_lua, [[ - local a = vim.api + local api = vim.api local function crashes(contents) - local buf = a.nvim_create_buf(false, true) - local floatwin = a.nvim_open_win(buf, true, { + local buf = api.nvim_create_buf(false, true) + local floatwin = api.nvim_open_win(buf, true, { relative = 'cursor'; style = 'minimal'; row = 0; col = 0; height = #contents; width = 10; }) - a.nvim_buf_set_lines(buf, 0, -1, true, contents) + api.nvim_buf_set_lines(buf, 0, -1, true, contents) local winnr = vim.fn.win_id2win(floatwin) - a.nvim_command('wincmd p') - a.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c') + api.nvim_command('wincmd p') + api.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c') return buf, floatwin end crashes{'foo'} -- cgit From 0f42aa1f2a860ce6d72a825b397fe09c875613b5 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 6 Apr 2023 10:03:37 +0200 Subject: fix(highlight): use winhl=Foo:Bar even when Bar is empty fixes #22906 --- test/functional/ui/float_spec.lua | 47 +++++++++++++++++++++++++++++++++++ test/functional/ui/highlight_spec.lua | 17 +++++++++++++ 2 files changed, 64 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 32f28dce26..890678e363 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -4935,6 +4935,53 @@ describe('float window', function() end) end) + it("can use Normal as background", function() + local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf,0,-1,true,{"here", "float"}) + local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + meths.set_option_value('winhl', 'Normal:Normal', {win=win}) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + here | + float | + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }here {0: }| + {0:~ }float {0: }| + {0:~ }| + {0:~ }| + | + ]]} + end + end) + describe("handles :wincmd", function() local win local expected_pos diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index dce886ac91..fedfaca7ba 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2432,6 +2432,23 @@ describe("'winhighlight' highlight", function() | ]]} end) + + it('can link to empty highlight group', function() + command 'hi NormalNC guibg=Red' -- czerwone time + command 'set winhl=NormalNC:Normal' + command 'split' + + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {3:[No Name] }| + | + {0:~ }| + {4:[No Name] }| + | + ]]} + end) end) describe('highlight namespaces', function() -- cgit From 73060f00dd84b2fcfaed74ba061644975707c225 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Apr 2023 09:29:12 +0800 Subject: test: improve editor/fold_spec.lua and editor/put_spec.lua (#22916) - Close and open a new window each time so that window options have their default values in each test. - Change feed_command() to command() as the latter is faster. --- test/functional/ui/fold_spec.lua | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 96e28c1978..a99b77f707 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -4,7 +4,6 @@ local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq local command = helpers.command local feed_command = helpers.feed_command local insert = helpers.insert -local expect = helpers.expect local funcs = helpers.funcs local meths = helpers.meths local exec = helpers.exec @@ -2023,29 +2022,4 @@ describe("folded lines", function() describe('without ext_multigrid', function() with_ext_multigrid(false) end) - - it('no folds remains if :delete makes buffer empty #19671', function() - funcs.setline(1, {'foo', 'bar', 'baz'}) - command('2,3fold') - command('%delete') - eq(0, funcs.foldlevel(1)) - end) - - it('multibyte fold markers work #20438', function() - exec([[ - setlocal foldmethod=marker - setlocal foldmarker=«,» - setlocal commentstring=/*%s*/ - ]]) - insert([[ - bbbbb - bbbbb - bbbbb]]) - feed('zfgg') - expect([[ - bbbbb/*«*/ - bbbbb - bbbbb/*»*/]]) - eq(1, funcs.foldlevel(1)) - end) end) -- cgit From 3c724fe1f3efae0d00b43e381523ea2ec7229328 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Mon, 10 Apr 2023 02:39:27 +0200 Subject: fix(column): 'statuscolumn' not drawn after virt_lines with "n" in 'cpo' (#22967) Problem: The 'statuscolumn' is not drawn and the line itself is drawn at an offset to the rest of the buffer after virt_lines if 'cpoptions' includes "n". Solution: Make sure 'statuscolumn' is drawn. --- test/functional/ui/statuscolumn_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 0a253455ad..83c49e56a0 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -397,6 +397,29 @@ describe('statuscolumn', function() {0:~ }| | ]]) + -- Also test virt_lines when 'cpoptions' includes "n" + exec_lua([[ + vim.opt.cpoptions:append("n") + local ns = vim.api.nvim_create_namespace("ns") + vim.api.nvim_buf_set_extmark(0, ns, 14, 0, { virt_lines = {{{"virt_line1", ""}}} }) + vim.api.nvim_buf_set_extmark(0, ns, 14, 0, { virt_lines = {{{"virt_line2", ""}}} }) + ]]) + screen:expect([[ + {1:buffer 0 13}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaa | + {1:buffer 0 14}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaa | + {1:buffer 0 15}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaa | + {1:virtual-2 15}virt_line1 | + {1:virtual-2 15}virt_line2 | + {1:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {5:aaaaaaaaa }| + {1:virtual-1 16}END | + {0:~ }| + {0:~ }| + | + ]]) end) it("works with 'statuscolumn' clicks", function() -- cgit From da979ae04b7a8c56586ed0233957600ad6af99f0 Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Sun, 2 Apr 2023 23:01:10 +0600 Subject: fix(api): do not re-apply win_config.style when missing --- test/functional/ui/float_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 32f28dce26..6d9197e1df 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -432,6 +432,25 @@ describe('float window', function() assert_alive() end) + it("should re-apply 'style' when present", function() + local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local float_win = meths.open_win(0, true, float_opts) + meths.win_set_option(float_win, 'number', true) + float_opts.row = 2 + meths.win_set_config(float_win, float_opts) + eq(false, meths.win_get_option(float_win, 'number')) + end) + + it("should not re-apply 'style' when missing", function() + local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local float_win = meths.open_win(0, true, float_opts) + meths.win_set_option(float_win, 'number', true) + float_opts.row = 2 + float_opts.style = nil + meths.win_set_config(float_win, float_opts) + eq(true, meths.win_get_option(float_win, 'number')) + end) + it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function() meths.set_option('splitkeep', 'screen') local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} -- cgit From dcaf2073369c672655722472aa4e7bcba7757f4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 11 Apr 2023 16:51:31 +0800 Subject: fix(highlight): combine ColorColumn with low-priority CursorLine (#23017) --- test/functional/ui/highlight_spec.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index fedfaca7ba..89b503141b 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1411,10 +1411,10 @@ describe('ColorColumn highlight', function() [3] = {foreground = Screen.colors.Brown}, -- LineNr [4] = {foreground = Screen.colors.Brown, bold = true}, -- CursorLineNr [5] = {foreground = Screen.colors.Blue, bold = true}, -- NonText - -- NonText and ColorColumn [6] = {foreground = Screen.colors.Blue, background = Screen.colors.LightRed, bold = true}, [7] = {reverse = true, bold = true}, -- StatusLine [8] = {reverse = true}, -- StatusLineNC + [9] = {background = Screen.colors.Grey90, foreground = Screen.colors.Red}, }) screen:attach() end) @@ -1500,6 +1500,25 @@ describe('ColorColumn highlight', function() | ]]) end) + + it('is combined with low-priority CursorLine highlight #23016', function() + screen:try_resize(40, 2) + command('set colorcolumn=30 cursorline') + screen:expect([[ + {2:^ }{1: }{2: }| + | + ]]) + command('hi clear ColorColumn') + screen:expect([[ + {2:^ }| + | + ]]) + command('hi ColorColumn guifg=Red') + screen:expect([[ + {2:^ }{9: }{2: }| + | + ]]) + end) end) describe("MsgSeparator highlight and msgsep fillchar", function() -- cgit From aab95ec67e4d80e63cc5c5acc42f3832e76e0781 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:18:54 +0200 Subject: test: avoid name collisions with Xtest directory (#23019) --- test/functional/ui/messages_spec.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 5220f3fa89..1a7fe26d26 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -22,6 +22,7 @@ local skip = helpers.skip describe('ui/ext_messages', function() local screen + local fname = 'Xtest_functional_ui_messages_spec' before_each(function() clear() @@ -41,7 +42,7 @@ describe('ui/ext_messages', function() }) end) after_each(function() - os.remove('Xtest') + os.remove(fname) end) it('msg_clear follows msg_show kind of confirm', function() @@ -126,7 +127,7 @@ describe('ui/ext_messages', function() feed('nq') -- kind=wmsg (editing readonly file) - command('write Xtest') + command('write ' .. fname) command('set readonly nohls') feed('G$x') screen:expect{grid=[[ @@ -912,9 +913,9 @@ stack traceback: end) it('does not truncate messages', function() - command('write Xtest') + command('write '.. fname) screen:expect({messages={ - {content = { { '"Xtest" [New] 0L, 0B written' } }, kind = "" } + {content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = "" } }}) end) end) -- cgit From cdc028e97d9808c21e26fffe2d282b6517eaffc0 Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Wed, 12 Apr 2023 17:40:58 +0200 Subject: fix(column): add truncated width during estimation for 'statuscolumn' Problem: Estimated 'statuscolumn' width estimated is not properly used, executing the `w_redr_statuscol` path unnecessarily. Solution: Adjust `w_nrwidth` and 'statuscolumn' width before anything is actually drawn in a `win_update()`. --- test/functional/ui/statuscolumn_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 83c49e56a0..a2fe875e65 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -616,4 +616,17 @@ describe('statuscolumn', function() | ]]) end) + + it("is only evaluated twice, once to estimate and once to draw", function() + command([[ + let g:stcnr = 0 + func! Stc() + let g:stcnr += 1 + return '12345' + endfunc + set stc=%!Stc() + norm ggdG + ]]) + eq(2, eval('g:stcnr')) + end) end) -- cgit From 80f6d55521cd25e7746e34b899be5532ea88c09b Mon Sep 17 00:00:00 2001 From: quintik <28828855+quintik@users.noreply.github.com> Date: Thu, 13 Apr 2023 06:17:05 -0400 Subject: test(winbar_spec): properly update winbar when 'showcmdloc' is "statusline" Co-authored-by: zeertzjq Co-authored-by: Luuk van Baal --- test/functional/ui/winbar_spec.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index ece27ec3ff..970f9c3d76 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -114,6 +114,41 @@ describe('winbar', function() {2:[No Name] [No Name] }| | ]]) + -- 'showcmdloc' "statusline" should not interfere with winbar redrawing #23030 + command('set showcmd showcmdloc=statusline') + feed('w') + feed('') + screen:expect([[ + {6:Set Up The Bars }│{6:Set Up The Bars }| + │ | + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│{5:Set Up The Bars }| + {3:~ }│^ | + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] ^W }| + {3:~ }│{6:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) + feed('wW') + screen:expect([[ + {6:Set Up The Bars }│{6:Set Up The Bars }| + │ | + {3:~ }│{3:~ }| + {3:~ }│{2:[No Name] }| + {3:~ }│{5:Set Up The Bars }| + {3:~ }│^ | + {3:~ }│{3:~ }| + {3:~ }│{4:[No Name] }| + {3:~ }│{6:Set Up The Bars }| + {3:~ }│ | + {3:~ }│{3:~ }| + {2:[No Name] [No Name] }| + | + ]]) end) it('works when switching value of \'winbar\'', function() -- cgit From 7095f8ff9d9ce3519abe34a3da4c8f4bdc3fc865 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 17 Apr 2023 17:32:32 +0100 Subject: vim-patch:9.0.1461: ruler not drawn correctly when using 'rulerformat' Problem: Ruler not drawn correctly when using 'rulerformat'. Solution: Adjust formatting depending on whether the ruler is drawn in the statusline or the command line. (Sean Dewar, closes vim/vim#12246) https://github.com/vim/vim/commit/fc8a601c3251c0388a88c1235b18c529385f7196 This issue was made apparent after neovim/neovim@0f1e2b6, as `showmode()` calls `win_redr_ruler()` with `curwin` now if it's floating, rather than the last window if there's no statusline (which usually already shares its right side with that of the editor). Co-authored-by: Sean Dewar --- test/functional/ui/float_spec.lua | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 3203b187cc..0e1842d087 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -2295,6 +2295,51 @@ describe('float window', function() end end) + it("correct ruler position in current float with 'rulerformat' set", function() + command 'set ruler rulerformat=fish:<><' + meths.open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + fish:<>< | + ## grid 4 + {1:^ }| + {2:~ }| + {2:~ }| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {1:^ } | + {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + fish:<>< | + ]]} + end + end) + it('can have minimum size', function() insert("the background text") local buf = meths.create_buf(false, true) -- cgit From 65dd3c1180cef5ec15a46bd278ab3a0cb1c3460d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 10 Apr 2023 21:40:35 +0100 Subject: fix(ruler): show ruler of curwin with no statusline in cmdline Problem: After neovim/neovim@846a056, only the ruler for current floating or last window without a statusline is drawn in the cmdline. This means that if the current window is not one of these, but has no statusline, its ruler will not be drawn anymore. Solution: Make `showmode()` draw the ruler of the current window or the last window in the cmdline if it has no statusline. This also maintains the previously restored floating window case (`float->w_status_height` should be 0). This behaviour should again match Vim, but without the overdraw it seems to do to achieve the same effect; it calls `showmode()` to draw the ruler for the last window without a statusline, then may draw over it in `showruler()` (which is now `show_cursor_info_later()` in Nvim) to show the ruler for the current window..? It's very confusing. Also update the logic in `win_redr_ruler()` to mirror the check done in `showmode()`, so that the ruler doesn't potentially draw over the long ins-completion mode message in some cases. --- test/functional/ui/float_spec.lua | 115 +++++++++++++++++++++++++++++++++ test/functional/ui/statusline_spec.lua | 59 +++++++++++++++++ 2 files changed, 174 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 0e1842d087..e2fe0a2df5 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -2340,6 +2340,121 @@ describe('float window', function() end end) + it('does not show ruler of not-last current float during ins-completion', function() + screen:try_resize(50,9) + command 'set ruler showmode' + meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0}) + meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5}) + feed 'w' + neq('', meths.win_get_config(0).relative) + neq(funcs.winnr '$', funcs.winnr()) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [3:--------------------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + 0,0-1 All | + ## grid 4 + {1: }| + {2:~ }| + {2:~ }| + ## grid 5 + {1:^ }| + {2:~ }| + {2:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {1: } {1:^ } | + {2:~ }{0: }{2:~ }{0: }| + {2:~ }{0: }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + 0,0-1 All | + ]]} + end + feed 'i' + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [3:--------------------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} | + ## grid 4 + {1: }| + {2:~ }| + {2:~ }| + ## grid 5 + {1:^ }| + {2:~ }| + {2:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {1: } {1:^ } | + {2:~ }{0: }{2:~ }{0: }| + {2:~ }{0: }{2:~ }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} | + ]]} + end + end) + it('can have minimum size', function() insert("the background text") local buf = meths.create_buf(false, true) diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 8e301dc70c..c41d4983a7 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -653,3 +653,62 @@ it('ruler is redrawn in cmdline with redrawstatus #22804', function() other value | ]]) end) + +it("shows correct ruler in cmdline with no statusline", function() + clear() + local screen = Screen.new(30, 8) + screen:set_default_attr_ids { + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {bold = true, reverse = true}, -- StatusLine + [3] = {reverse = true}, -- StatusLineNC + } + screen:attach() + -- Use long ruler to check 'ruler' with 'rulerformat' set has correct width. + command [[ + set ruler rulerformat=%{winnr()}longlonglong ls=0 winwidth=10 + split + wincmd b + vsplit + wincmd t + wincmd | + mode + ]] + -- Window 1 is current. It has a statusline, so cmdline should show the + -- last window's ruler, which has no statusline. + command '1wincmd w' + screen:expect [[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] 1longlonglong }| + │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + 3longlonglong | + ]] + -- Window 2 is current. It has no statusline, so cmdline should show its + -- ruler instead. + command '2wincmd w' + screen:expect [[ + | + {1:~ }| + {1:~ }| + {3:[No Name] 1longlonglong }| + ^ │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + 2longlonglong | + ]] + -- Window 3 is current. Cmdline should again show its ruler. + command '3wincmd w' + screen:expect [[ + | + {1:~ }| + {1:~ }| + {3:[No Name] 1longlonglong }| + │^ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + 3longlonglong | + ]] +end) -- cgit From 84a4319545ad280d48a41e4cafaf0622c4278a16 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 18 Apr 2023 02:00:49 +0200 Subject: fix(mouse): cmdline click registered as statuscolumn (#23163) --- test/functional/ui/statuscolumn_spec.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index a2fe875e65..0eec693182 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -457,6 +457,9 @@ describe('statuscolumn', function() -- Check that statusline click doesn't register as statuscolumn click meths.input_mouse('right', 'press', '', 0, 12, 0) eq('', eval("g:testvar")) + -- Check that cmdline click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 13, 0) + eq('', eval("g:testvar")) end) it('click labels do not leak memory', function() -- cgit From d799456a6b4d9f3000a4a4adb8b71ddee96351b9 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 18 Apr 2023 03:20:18 +0200 Subject: test(column): statuscolumn is rebuild when signs are (un)placed --- test/functional/ui/statuscolumn_spec.lua | 60 ++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 0eec693182..886e264a5f 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -15,6 +15,7 @@ describe('statuscolumn', function() clear('--cmd', 'set number nuw=1 | call setline(1, repeat(["aaaaa"], 16)) | norm GM') screen = Screen.new() screen:attach() + exec_lua('ns = vim.api.nvim_create_namespace("")') end) it("fails with invalid 'statuscolumn'", function() @@ -352,7 +353,6 @@ describe('statuscolumn', function() ]]) -- Status column is re-evaluated for virt_lines, buffer line, and wrapped line exec_lua([[ - local ns = vim.api.nvim_create_namespace("ns") vim.api.nvim_buf_set_extmark(0, ns, 5, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above", ""}}} }) vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_lines = {{{"virt_line", ""}}} }) @@ -377,7 +377,6 @@ describe('statuscolumn', function() ]]) -- Also test virt_lines at the end of buffer exec_lua([[ - local ns = vim.api.nvim_create_namespace("ns") vim.api.nvim_buf_set_extmark(0, ns, 15, 0, { virt_lines = {{{"END", ""}}} }) ]]) feed('Gzz') @@ -400,7 +399,6 @@ describe('statuscolumn', function() -- Also test virt_lines when 'cpoptions' includes "n" exec_lua([[ vim.opt.cpoptions:append("n") - local ns = vim.api.nvim_create_namespace("ns") vim.api.nvim_buf_set_extmark(0, ns, 14, 0, { virt_lines = {{{"virt_line1", ""}}} }) vim.api.nvim_buf_set_extmark(0, ns, 14, 0, { virt_lines = {{{"virt_line2", ""}}} }) ]]) @@ -481,7 +479,6 @@ describe('statuscolumn', function() for _ = 0,8 do command('norm zfjzo') end -- 'statuscolumn' is not drawn for `virt_lines_leftcol` lines exec_lua([[ - local ns = vim.api.nvim_create_namespace("ns") vim.api.nvim_buf_set_extmark(0, ns, 6, 0, { virt_lines_leftcol = true, virt_lines = {{{"virt", ""}}} }) vim.api.nvim_buf_set_extmark(0, ns, 7, 0, { @@ -585,37 +582,70 @@ describe('statuscolumn', function() end) it("has correct width with custom sign column when (un)placing signs", function() - screen:try_resize(screen._width, 6) + screen:try_resize(screen._width, 3) exec_lua([[ vim.cmd.norm('gg') vim.o.signcolumn = 'no' vim.fn.sign_define('sign', { text = 'ss' }) _G.StatusCol = function() local s = vim.fn.sign_getplaced(1)[1].signs + local es = vim.api.nvim_buf_get_extmarks(0, ns, 0, -1, {type = "sign"}) local sign = '' - if #s > 0 then - sign = vim.v.lnum == 5 and 'ss' or ' ' + local signs = #s + #es + if signs > 0 then + sign = (vim.v.lnum == 2 and 'ss' or ' '):rep(signs) end return vim.v.lnum .. '%=' .. sign end vim.o.statuscolumn = "%!v:lua.StatusCol()" - vim.fn.sign_place(0, '', 'sign', 1, { lnum = 5 }) ]]) + command('sign place 1 line=2 name=sign') + screen:expect([[ + 1 ^aaaaa | + 2 ssaaaaa | + | + ]]) + command('sign place 2 line=2 name=sign') + screen:expect([[ + 1 ^aaaaa | + 2 ssssaaaaa | + | + ]]) + command('sign unplace 2') screen:expect([[ 1 ^aaaaa | - 2 aaaaa | - 3 aaaaa | - 4 aaaaa | - 5 ssaaaaa | + 2 ssaaaaa | | ]]) command('sign unplace 1') screen:expect([[ 1 ^aaaaa | 2 aaaaa | - 3 aaaaa | - 4 aaaaa | - 5 aaaaa | + | + ]]) + -- Also for extmark signs + exec_lua('id1 = vim.api.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text = "ss"})') + screen:expect([[ + 1 ^aaaaa | + 2 ssaaaaa | + | + ]]) + exec_lua('id2 = vim.api.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text = "ss"})') + screen:expect([[ + 1 ^aaaaa | + 2 ssssaaaaa | + | + ]]) + exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id1)") + screen:expect([[ + 1 ^aaaaa | + 2 ssaaaaa | + | + ]]) + exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id2)") + screen:expect([[ + 1 ^aaaaa | + 2 aaaaa | | ]]) end) -- cgit From 44d4f0357341d661a8fa7bd88c244e0ab196a838 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 19 Apr 2023 00:19:26 +0200 Subject: fix(column): rebuild status column when sign column is invalid --- test/functional/ui/statuscolumn_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 886e264a5f..c4b055d289 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -648,6 +648,14 @@ describe('statuscolumn', function() 2 aaaaa | | ]]) + -- In all windows + command('wincmd v | set ls=0') + command('sign place 1 line=2 name=sign') + screen:expect([[ + 1 ^aaaaa │1 aaaaa | + 2 ssaaaaa │2 ssaaaaa | + | + ]]) end) it("is only evaluated twice, once to estimate and once to draw", function() -- cgit From 040d9da5c8f4d56e0482758223ea7bb04dc90cc0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Apr 2023 00:30:52 +0800 Subject: vim-patch:9.0.1476: lines put in non-current window are not displayed (#23265) Problem: Lines put in non-current window are not displayed. (Marius Gedminas) Solution: Don't increment the topline when inserting just above it. (closes vim/vim#12212) https://github.com/vim/vim/commit/e7f05a8780426dc7af247419c6d02d5f1e896689 Co-authored-by: Bram Moolenaar --- test/functional/ui/popupmenu_spec.lua | 103 +++++++++++++++++----------------- 1 file changed, 51 insertions(+), 52 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 944319c443..cfcf83ba42 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1372,11 +1372,11 @@ describe('builtin popupmenu', function() U{n: qui }{s: }eniam, quis nostrud | e{n: officia }{s: }co laboris nisi ut aliquip ex | {4:[No}{n: deserunt }{s: }{4: }| - L{n: mollit }{s: }sit amet, consectetur | - a{n: anim }{s: }sed do eiusmod tempor | - i{n: id }{s: }re et dolore magna aliqua. | - U{n: est }{s: }eniam, quis nostrud | - e{n: laborum }{c: }co laboris nisi ut aliquip ex | + Est{n: mollit }{s: } | + L{n: anim }{s: }sit amet, consectetur | + a{n: id }{s: }sed do eiusmod tempor | + i{n: est }{s: }re et dolore magna aliqua. | + U{n: laborum }{c: }eniam, quis nostrud | {3:[No}{s: Est }{c: }{3: }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1390,11 +1390,11 @@ describe('builtin popupmenu', function() U{n: qui }{s: }eniam, quis nostrud | e{n: officia }{s: }co laboris nisi ut aliquip ex | {4:[No}{n: deserunt }{s: }{4: }| - U{n: mollit }{s: }eniam, quis nostrud | - e{n: anim }{s: }co laboris nisi ut aliquip ex | - e{n: id }{s: }at. Duis aute irure dolor in | - r{n: est }{s: }oluptate velit esse cillum | - d{n: laborum }{c: }ulla pariatur. Excepteur sint | + i{n: mollit }{s: }re et dolore magna aliqua. | + U{n: anim }{s: }eniam, quis nostrud | + e{n: id }{s: }co laboris nisi ut aliquip ex | + e{n: est }{s: }at. Duis aute irure dolor in | + r{n: laborum }{c: }oluptate velit esse cillum | {3:[No}{s: Est }{c: }{3: }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1408,11 +1408,11 @@ describe('builtin popupmenu', function() U{n: enim }veniam, quis nostrud | e{n: exercitation }mco laboris nisi ut aliquip ex | {4:[No}{n: ex }{4: }| - U{n: ea }veniam, quis nostrud | - e{n: esse }mco laboris nisi ut aliquip ex | - e{n: eu }uat. Duis aute irure dolor in | - r{s: est }voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{n: eu }mco laboris nisi ut aliquip ex | + e{s: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1426,11 +1426,11 @@ describe('builtin popupmenu', function() U{n: enim }veniam, quis nostrud | e{n: exercitation }mco laboris nisi ut aliquip ex | {4:[No}{n: ex }{4: }| - L{n: ea } sit amet, consectetur | - a{n: esse } sed do eiusmod tempor | - i{n: eu }ore et dolore magna aliqua. | - U{s: est }veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | + Est{n: ea } | + L{n: esse } sit amet, consectetur | + a{n: eu } sed do eiusmod tempor | + i{s: est }ore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1444,11 +1444,11 @@ describe('builtin popupmenu', function() Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | {4:[No Name] [+] }| + Est es | Lorem ipsum dolor sit amet, consectetur | adipisicing elit, sed do eiusmod tempor | incididunt ut labore et dolore magna aliqua. | Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1462,11 +1462,11 @@ describe('builtin popupmenu', function() Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | {4:[No Name] [+] }| + incididunt ut labore et dolore magna aliqua. | Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1480,11 +1480,11 @@ describe('builtin popupmenu', function() U{n: enim }veniam, quis nostrud | e{n: exercitation }mco laboris nisi ut aliquip ex | {4:[No}{n: ex }{4: }| - U{n: ea }veniam, quis nostrud | - e{n: esse }mco laboris nisi ut aliquip ex | - e{n: eu }uat. Duis aute irure dolor in | - r{s: est }voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{n: eu }mco laboris nisi ut aliquip ex | + e{s: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) @@ -1498,11 +1498,11 @@ describe('builtin popupmenu', function() U{n: enim }veniam, quis nostrud | e{n: exercitation }mco laboris nisi ut aliquip ex | {4:[No}{n: ex }{4: }| - U{n: ea }veniam, quis nostrud | - e{n: esse }mco laboris nisi ut aliquip ex | - e{s: eu }uat. Duis aute irure dolor in | - r{n: est }voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{s: eu }mco laboris nisi ut aliquip ex | + e{n: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | ]]) @@ -1516,16 +1516,15 @@ describe('builtin popupmenu', function() U{n: enim }veniam, quis nostrud | e{n: exercitation }mco laboris nisi ut aliquip ex | {4:[No}{n: ex }{4: }| - r{n: ea }voluptate velit esse cillum | - d{n: esse }nulla pariatur. Excepteur sint | - o{s: eu }t non proident, sunt in culpa | - q{n: est }unt mollit anim id est | - laborum. | + e{n: ea }uat. Duis aute irure dolor in | + r{n: esse }voluptate velit esse cillum | + d{s: eu }nulla pariatur. Excepteur sint | + o{n: est }t non proident, sunt in culpa | + qui officia deserunt mollit anim id est | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | ]]) - funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) screen:expect([[ Est eu^ | @@ -1535,11 +1534,11 @@ describe('builtin popupmenu', function() {n: eo }iam, quis nostrud | {n: eu } laboris nisi ut aliquip ex | {4:[N}{n: ey }{4: }| - {n: eå }uptate velit esse cillum | - {n: eä }la pariatur. Excepteur sint | - {n: eö }on proident, sunt in culpa | + {n: eå }. Duis aute irure dolor in | + {n: eä }uptate velit esse cillum | + {n: eö }la pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | - laborum. | {3:[No Name] [+] }| {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} | ]]) @@ -1553,11 +1552,11 @@ describe('builtin popupmenu', function() {n: eo } veniam, quis nostrud | {n: eu }amco laboris nisi ut aliquip ex | {4:[N}{n: ey }{4: }| - {n: eå } voluptate velit esse cillum | - {n: eä } nulla pariatur. Excepteur sint | - {n: eö }at non proident, sunt in culpa | + {n: eå }quat. Duis aute irure dolor in | + {n: eä } voluptate velit esse cillum | + {n: eö } nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | - laborum. | {3:[No Name] [+] }| {2:-- INSERT --} | ]]) @@ -1571,11 +1570,11 @@ describe('builtin popupmenu', function() {n: eo } veniam, quis nostrud | {n: eu }amco laboris nisi ut aliquip ex | {4:[N}{n: ey }{4: }| - {n: eå } voluptate velit esse cillum | - {n: eä } nulla pariatur. Excepteur sint | - {n: eö }at non proident, sunt in culpa | + {n: eå }quat. Duis aute irure dolor in | + {n: eä } voluptate velit esse cillum | + {n: eö } nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | - laborum. | {3:[No Name] [+] }| {2:-- INSERT --} | ]]) @@ -1589,11 +1588,11 @@ describe('builtin popupmenu', function() Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | {4:[No Name] [+] }| + ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | dolore eu fugiat nulla pariatur. Excepteur sint | occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | - laborum. | {3:[No Name] [+] }| {2:-- INSERT --} | ]]) @@ -1607,11 +1606,11 @@ describe('builtin popupmenu', function() Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | {4:[No Name] [+] }| + ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | dolore eu fugiat nulla pariatur. Excepteur sint | occaecat cupidatat non proident, sunt in culpa | qui officia deserunt mollit anim id est | - laborum. | {3:[No Name] [+] }| {2:-- INSERT --} | ]]) -- cgit From c1331a65dd12dd1128db5fb136a77218ef7376f1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 24 Apr 2023 09:26:10 +0800 Subject: fix(pum): show right-click menu above cmdline area (#23298) --- test/functional/ui/popupmenu_spec.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index cfcf83ba42..53ef60bc89 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3259,16 +3259,16 @@ describe('builtin popupmenu', function() :let g:menustr = 'bar' | ]]) eq('bar', meths.get_var('menustr')) - feed('<20,1>') + feed('<20,2>') screen:expect([[ ^popup menu test | {1:~ }| + {1:~ }| {1:~ }{n: foo }{1: }| {1:~ }{n: bar }{1: }| - {1:~ }{n: baz }{1: }| - :let g:menustr = 'bar' | + :let g:menustr = 'b{n: baz } | ]]) - feed('<22,4>') + feed('<22,5>') screen:expect([[ ^popup menu test | {1:~ }| @@ -3675,7 +3675,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function() {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 2, 19, false, 100}}}) + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 2, 19, false, 250}}}) meths.input_mouse('left', 'press', '', 4, 2, 2) screen:expect({grid=[[ ## grid 1 @@ -3716,7 +3716,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function() {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) meths.input_mouse('right', 'drag', '', 2, 3, 6) screen:expect({grid=[[ ## grid 1 @@ -3738,7 +3738,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function() {n: foo }| {n: bar }| {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) meths.input_mouse('right', 'release', '', 2, 1, 6) screen:expect({grid=[[ ## grid 1 @@ -3780,7 +3780,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function() {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) eq(true, screen.options.mousemoveevent) meths.input_mouse('move', '', '', 2, 3, 6) screen:expect({grid=[[ @@ -3803,7 +3803,7 @@ describe('builtin popupmenu with ui/ext_multigrid', function() {n: foo }| {n: bar }| {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 100}}}) + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) eq(true, screen.options.mousemoveevent) meths.input_mouse('left', 'press', '', 2, 2, 6) screen:expect({grid=[[ -- cgit From a4b2400804355e99813f39a6b38d8f38667f8bdd Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 25 Apr 2023 05:05:04 +0200 Subject: fix(statusline): also allow right click when 'mousemodel' is "popup*" (#23258) Problem: The 'statusline'-format ui elements do not receive right click events when "mousemodel" is "popup*" Solution: Do not draw popupmenu and handle click event instead. --- test/functional/ui/mouse_spec.lua | 10 - test/functional/ui/statuscolumn_spec.lua | 82 ++++---- test/functional/ui/statusline_spec.lua | 348 ++++++++++++++++--------------- 3 files changed, 219 insertions(+), 221 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index f705678bd5..c7f6861c12 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1840,16 +1840,6 @@ describe('ui/mouse/input', function() eq({2, 9}, meths.win_get_cursor(0)) eq('', funcs.getreg('"')) - -- Try clicking on the status line - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 9}) - feed('vee') - meths.input_mouse('right', 'press', '', 0, 5, 1) - meths.input_mouse('right', 'release', '', 0, 5, 1) - feed('') - eq({1, 9}, meths.win_get_cursor(0)) - eq('ran away', funcs.getreg('"')) - -- Try clicking outside the window funcs.setreg('"', '') meths.win_set_cursor(0, {2, 1}) diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index c4b055d289..3b41d3684a 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -9,6 +9,8 @@ local feed = helpers.feed local meths = helpers.meths local pcall_err = helpers.pcall_err +local mousemodels = { "extend", "popup", "popup_setpos" } + describe('statuscolumn', function() local screen before_each(function() @@ -420,45 +422,47 @@ describe('statuscolumn', function() ]]) end) - it("works with 'statuscolumn' clicks", function() - command('set mousemodel=extend') - command([[ - function! MyClickFunc(minwid, clicks, button, mods) - let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) - if a:mods !=# ' ' - let g:testvar ..= '(' .. a:mods .. ')' - endif - endfunction - set stc=%0@MyClickFunc@%=%l%T - ]]) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 2 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 3 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 4 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 1 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 2 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 3 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 4 r 7', eval("g:testvar")) - command('set laststatus=2 winbar=%f') - command('let g:testvar=""') - -- Check that winbar click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 0, 0) - eq('', eval("g:testvar")) - -- Check that statusline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 12, 0) - eq('', eval("g:testvar")) - -- Check that cmdline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 13, 0) - eq('', eval("g:testvar")) - end) + for _, model in ipairs(mousemodels) do + it("works with 'statuscolumn' clicks with mousemodel=" .. model, function() + command('set mousemodel=' .. model) + command([[ + function! MyClickFunc(minwid, clicks, button, mods) + let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) + if a:mods !=# ' ' + let g:testvar ..= '(' .. a:mods .. ')' + endif + endfunction + set stc=%0@MyClickFunc@%=%l%T + ]]) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 1 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 2 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 3 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 4 l 4', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 1 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 2 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 3 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 4 r 7', eval("g:testvar")) + command('set laststatus=2 winbar=%f') + command('let g:testvar=""') + -- Check that winbar click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 0, 0) + eq('', eval("g:testvar")) + -- Check that statusline click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 12, 0) + eq('', eval("g:testvar")) + -- Check that cmdline click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 13, 0) + eq('', eval("g:testvar")) + end) + end it('click labels do not leak memory', function() command([[ diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index c41d4983a7..5ea4eade4e 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -12,178 +12,182 @@ local exec_lua = helpers.exec_lua local eval = helpers.eval local sleep = helpers.sleep -describe('statusline clicks', function() - local screen - - before_each(function() - clear() - screen = Screen.new(40, 8) - screen:attach() - command('set laststatus=2 mousemodel=extend') - exec([=[ - function! MyClickFunc(minwid, clicks, button, mods) - let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button) - if a:mods !=# ' ' - let g:testvar ..= '(' .. a:mods .. ')' - endif - endfunction - ]=]) - end) - - it('works', function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 2 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 3 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 4 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 2 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 3 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 4 r', eval("g:testvar")) - end) - - it('works for winbar', function() - meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 0, 17) - eq('0 1 r', eval("g:testvar")) - end) - - it('works for winbar in floating window', function() - meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5, - border = "single" }) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', - { scope = 'local' }) - meths.input_mouse('left', 'press', '', 0, 2, 23) - eq('0 1 l', eval("g:testvar")) - end) - - it('works when there are multiple windows', function() - command('split') - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 4, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('middle', 'press', '', 0, 3, 17) - eq('0 1 m', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - end) - - it('works with Lua function', function() - exec_lua([[ - function clicky_func(minwid, clicks, button, mods) - vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) - end - ]]) - meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T') - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - end) - - it('ignores unsupported click items', function() - command('tabnew | tabprevious') - meths.set_option('statusline', '%2TNot clicky stuff%T') - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(1, meths.get_current_tabpage().id) - meths.set_option('statusline', '%2XNot clicky stuff%X') - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(2, #meths.list_tabpages()) - end) - - it("right click works when statusline isn't focused #18994", function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 2 r', eval("g:testvar")) - end) - - it("works with modifiers #18994", function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks - meths.input_mouse('left', 'press', 'S', 0, 6, 17) - eq('0 1 l(s )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'S', 0, 6, 17) - eq('0 1 r(s )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'A', 0, 6, 17) - eq('0 1 l( a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'A', 0, 6, 17) - eq('0 1 r( a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'AS', 0, 6, 17) - eq('0 1 l(s a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'AS', 0, 6, 17) - eq('0 1 r(s a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'T', 0, 6, 17) - eq('0 1 l( m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'T', 0, 6, 17) - eq('0 1 r( m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'TS', 0, 6, 17) - eq('0 1 l(s m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'TS', 0, 6, 17) - eq('0 1 r(s m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'C', 0, 6, 17) - eq('0 1 l( c )', eval("g:testvar")) - -- is for tag jump - end) - - it("works for global statusline with vertical splits #19186", function() - command('set laststatus=3') - meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T') - command('vsplit') - screen:expect([[ - ^ │ | - ~ │~ | - ~ │~ | - ~ │~ | - ~ │~ | - ~ │~ | - Clicky stuff Clicky stuff| - | - ]]) - - -- clickable area on the right - meths.input_mouse('left', 'press', '', 0, 6, 35) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 35) - eq('0 1 r', eval("g:testvar")) - - -- clickable area on the left - meths.input_mouse('left', 'press', '', 0, 6, 5) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 5) - eq('0 1 r', eval("g:testvar")) - end) - - it('no memory leak with zero-width click labels', function() - command([[ - let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@' - ]]) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 39) - eq('0 1 r', eval("g:testvar")) - end) - - it('no memory leak with truncated click labels', function() - command([[ - let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '% is for tag jump + end) + + it("works for global statusline with vertical splits #19186", function() + command('set laststatus=3') + meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T') + command('vsplit') + screen:expect([[ + ^ │ | + ~ │~ | + ~ │~ | + ~ │~ | + ~ │~ | + ~ │~ | + Clicky stuff Clicky stuff| + | + ]]) + + -- clickable area on the right + meths.input_mouse('left', 'press', '', 0, 6, 35) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 35) + eq('0 1 r', eval("g:testvar")) + + -- clickable area on the left + meths.input_mouse('left', 'press', '', 0, 6, 5) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 5) + eq('0 1 r', eval("g:testvar")) + end) + + it('no memory leak with zero-width click labels', function() + command([[ + let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@' + ]]) + meths.input_mouse('left', 'press', '', 0, 6, 0) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 39) + eq('0 1 r', eval("g:testvar")) + end) + + it('no memory leak with truncated click labels', function() + command([[ + let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '% Date: Thu, 27 Apr 2023 15:51:44 +0800 Subject: test: fix dependencies between test cases (#23343) Discovered using --shuffle argument of busted. --- test/functional/ui/inccommand_spec.lua | 31 +++++++++++++++++-------------- test/functional/ui/output_spec.lua | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 96634be327..a67db78cbe 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -745,10 +745,11 @@ describe(":substitute, 'inccommand' preserves undo", function() end) describe(":substitute, inccommand=split", function() - local screen = Screen.new(30,15) + local screen before_each(function() clear() + screen = Screen.new(30,15) common_setup(screen, "split", default_text .. default_text) end) @@ -1413,10 +1414,11 @@ describe(":substitute, inccommand=split", function() end) describe("inccommand=nosplit", function() - local screen = Screen.new(20,10) + local screen before_each(function() clear() + screen = Screen.new(20,10) common_setup(screen, "nosplit", default_text .. default_text) end) @@ -1644,11 +1646,12 @@ describe("inccommand=nosplit", function() end) describe(":substitute, 'inccommand' with a failing expression", function() - local screen = Screen.new(20,10) + local screen local cases = { "", "split", "nosplit" } local function refresh(case) clear() + screen = Screen.new(20,10) common_setup(screen, case, default_text) end @@ -2127,9 +2130,10 @@ describe("'inccommand' with 'gdefault'", function() end) describe(":substitute", function() - local screen = Screen.new(30,15) + local screen before_each(function() clear() + screen = Screen.new(30,15) end) it("inccommand=split, highlights multiline substitutions", function() @@ -2335,8 +2339,7 @@ describe(":substitute", function() ]]) end) - it("inccommand=split, substitutions of different length", - function() + it("inccommand=split, substitutions of different length", function() common_setup(screen, "split", "T T123 T2T TTT T090804\nx") feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") @@ -2872,8 +2875,8 @@ it(':substitute with inccommand during :terminal activity', function() return end retry(2, 40000, function() - local screen = Screen.new(30,15) clear() + local screen = Screen.new(30,15) command("set cmdwinheight=3") feed(([[:terminal "%s" REP 5000 xxx]]):format(testprg('shell-test'))) @@ -2893,8 +2896,8 @@ it(':substitute with inccommand during :terminal activity', function() end) it(':substitute with inccommand, timer-induced :redraw #9777', function() - local screen = Screen.new(30,12) clear() + local screen = Screen.new(30,12) command('set cmdwinheight=3') command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})') command('call timer_start(10, {-> execute("redrawstatus")}, {"repeat":-1})') @@ -2920,8 +2923,8 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() end) it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function() - local screen = Screen.new(30,6) clear() + local screen = Screen.new(30,6) common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('hi! link NormalFloat CursorLine') local float_buf = meths.create_buf(false, true) @@ -2950,8 +2953,8 @@ it(':substitute with inccommand, allows :redraw before first separator is typed end) it(':substitute with inccommand, does not crash if range contains invalid marks', function() - local screen = Screen.new(30, 6) clear() + local screen = Screen.new(30, 6) common_setup(screen, 'split', 'test') feed([[:'a,'bs]]) screen:expect([[ @@ -2976,8 +2979,8 @@ it(':substitute with inccommand, does not crash if range contains invalid marks' end) it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function() - local screen = Screen.new(60, 6) clear() + local screen = Screen.new(60, 6) common_setup(screen, 'split', 'test') feed(':ls') screen:expect([[ @@ -3029,8 +3032,8 @@ it(':substitute with inccommand, no unnecessary redraw if preview is not shown', end) it(":substitute doesn't crash with inccommand, if undo is empty #12932", function() - local screen = Screen.new(10,5) clear() + local screen = Screen.new(10,5) command('set undolevels=-1') common_setup(screen, 'split', 'test') feed(':%s/test') @@ -3049,8 +3052,8 @@ it(":substitute doesn't crash with inccommand, if undo is empty #12932", functio end) it(':substitute with inccommand works properly if undo is not synced #20029', function() - local screen = Screen.new(30, 6) clear() + local screen = Screen.new(30, 6) common_setup(screen, 'nosplit', 'foo\nbar\nbaz') meths.set_keymap('x', '', '``>obbbbb asdfV`lljj') @@ -3086,8 +3089,8 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu end) it('long :%s/ with inccommand does not collapse cmdline', function() - local screen = Screen.new(10,5) clear() + local screen = Screen.new(10,5) common_setup(screen) command('set inccommand=nosplit') feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 954431d689..0dd1f0325c 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -15,6 +15,8 @@ local set_shell_powershell = helpers.set_shell_powershell local skip = helpers.skip local is_os = helpers.is_os +clear() -- for has_powershell() + describe("shell command :!", function() local screen before_each(function() -- cgit From a3dfe1bc89a518442503189ca074ee8ab4b8b0d4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 27 Apr 2023 20:19:21 +0800 Subject: fix(pum): position properly with ext_multigrid (#23336) --- test/functional/ui/mouse_spec.lua | 12 + test/functional/ui/popupmenu_spec.lua | 5853 +++++++++++++++++++-------------- 2 files changed, 3316 insertions(+), 2549 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index c7f6861c12..d9b9cf9f1b 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1849,5 +1849,17 @@ describe('ui/mouse/input', function() feed('') eq(2, funcs.winnr()) eq('', funcs.getreg('"')) + + -- Test for right click in visual mode inside the selection with vertical splits + command('wincmd t') + command('rightbelow vsplit') + funcs.setreg('"', '') + meths.win_set_cursor(0, {1, 9}) + feed('vee') + meths.input_mouse('right', 'press', '', 0, 0, 52) + meths.input_mouse('right', 'release', '', 0, 0, 52) + feed('') + eq({1, 9}, meths.win_get_cursor(0)) + eq('ran away', funcs.getreg('"')) end) end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 53ef60bc89..c5e0c10a81 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1023,1869 +1023,11 @@ describe('ui/ext_popupmenu', function() end) end) +describe("builtin popupmenu 'pumblend'", function() + before_each(clear) -describe('builtin popupmenu', function() - local screen - before_each(function() - clear() - screen = Screen.new(32, 20) - screen:attach() - screen:set_default_attr_ids({ - -- popup selected item / scrollbar track - ['s'] = {background = Screen.colors.WebGray}, - -- popup non-selected item - ['n'] = {background = Screen.colors.LightMagenta}, - -- popup scrollbar knob - ['c'] = {background = Screen.colors.Grey0}, - [1] = {bold = true, foreground = Screen.colors.Blue}, - [2] = {bold = true}, - [3] = {reverse = true}, - [4] = {bold = true, reverse = true}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen}, - [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [7] = {background = Screen.colors.Yellow}, -- Search - [8] = {foreground = Screen.colors.Red}, - }) - end) - - it('with preview-window above', function() - feed(':ped4+') - feed('iaa bb cc dd ee ff gg hh ii jj') - feed('') - screen:expect([[ - aa bb cc dd ee ff gg hh ii jj | - aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {3:[No Name] [Preview][+] }| - aa bb cc dd ee ff gg hh ii jj | - aa^ | - {s:aa }{c: }{1: }| - {n:bb }{c: }{1: }| - {n:cc }{c: }{1: }| - {n:dd }{c: }{1: }| - {n:ee }{c: }{1: }| - {n:ff }{c: }{1: }| - {n:gg }{s: }{1: }| - {n:hh }{s: }{4: }| - {2:-- }{5:match 1 of 10} | - ]]) - end) - - it('with preview-window below', function() - feed(':ped4+r') - feed('iaa bb cc dd ee ff gg hh ii jj') - feed('') - screen:expect([[ - aa bb cc dd ee ff gg hh ii jj | - aa^ | - {s:aa }{c: }{1: }| - {n:bb }{c: }{1: }| - {n:cc }{c: }{1: }| - {n:dd }{c: }{1: }| - {n:ee }{c: }{1: }| - {n:ff }{c: }{1: }| - {n:gg }{s: }{1: }| - {n:hh }{s: }{4: }| - aa bb cc dd ee ff gg hh ii jj | - aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {3:[No Name] [Preview][+] }| - {2:-- }{5:match 1 of 10} | - ]]) - end) - - it('with preview-window above and tall and inverted', function() - feed(':ped8+') - feed('iaabbccddee') - feed('ffgghhiijj') - feed('kkllmmnnoo') - feed('') - screen:expect([[ - aa | - bb | - cc | - dd | - {s:aa }{c: }{3:ew][+] }| - {n:bb }{c: } | - {n:cc }{c: } | - {n:dd }{c: } | - {n:ee }{c: } | - {n:ff }{c: } | - {n:gg }{c: } | - {n:hh }{c: } | - {n:ii }{c: } | - {n:jj }{c: } | - {n:kk }{c: } | - {n:ll }{s: } | - {n:mm }{s: } | - aa^ | - {4:[No Name] [+] }| - {2:-- }{5:match 1 of 15} | - ]]) - end) - - it('with preview-window above and short and inverted', function() - feed(':ped4+') - feed('iaabbccddee') - feed('ffgghhiijj') - feed('') - screen:expect([[ - aa | - bb | - cc | - dd | - ee | - ff | - gg | - hh | - {s:aa }{c: }{3:ew][+] }| - {n:bb }{c: } | - {n:cc }{c: } | - {n:dd }{c: } | - {n:ee }{c: } | - {n:ff }{c: } | - {n:gg }{c: } | - {n:hh }{c: } | - {n:ii }{s: } | - aa^ | - {4:[No Name] [+] }| - {2:-- }{5:match 1 of 10} | - ]]) - end) - - it('with preview-window below and inverted', function() - feed(':ped4+r') - feed('iaabbccddee') - feed('ffgghhiijj') - feed('') - screen:expect([[ - {s:aa }{c: } | - {n:bb }{c: } | - {n:cc }{c: } | - {n:dd }{c: } | - {n:ee }{c: } | - {n:ff }{c: } | - {n:gg }{s: } | - {n:hh }{s: } | - aa^ | - {4:[No Name] [+] }| - aa | - bb | - cc | - dd | - ee | - ff | - gg | - hh | - {3:[No Name] [Preview][+] }| - {2:-- }{5:match 1 of 10} | - ]]) - end) - - -- oldtest: Test_pum_with_preview_win() - it('preview window opened during completion', function() - exec([[ - funct Omni_test(findstart, base) - if a:findstart - return col(".") - 1 - endif - return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] - endfunc - set omnifunc=Omni_test - set completeopt+=longest - ]]) - feed('Gi') - screen:expect([[ - ^ | - {n:one }{1: }| - {n:two }{1: }| - {n:three }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- }{8:Back at original} | - ]]) - feed('') - screen:expect([[ - 1info | - | - {1:~ }| - {3:[Scratch] [Preview] }| - one^ | - {s:one }{1: }| - {n:two }{1: }| - {n:three }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4:[No Name] [+] }| - {2:-- }{5:match 1 of 3} | - ]]) - end) - - it('with vsplits', function() - insert('aaa aab aac\n') - feed(':vsplit') - screen:expect([[ - aaa aab aac │aaa aab aac| - ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {4:[No Name] [+] }{3:') - screen:expect([[ - aaa aab aac │aaa aab aac| - bbb aaa^ │bbb aaa | - {1:~ }{s: aaa }{1: }│{1:~ }| - {1:~ }{n: aab }{1: }│{1:~ }| - {1:~ }{n: aac }{1: }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {4:[No Name] [+] }{3:oc a') - screen:expect([[ - aaa aab aac│aaa aab aac | - bbb aaa │bbb aaa | - c aaa │c aaa^ | - {1:~ }│{1:~}{s: aaa }{1: }| - {1:~ }│{1:~}{n: aab }{1: }| - {1:~ }│{1:~}{n: aac }{1: }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {3:') - screen:expect([[ - Est ^ | - L{n: sunt }{s: }sit amet, consectetur | - a{n: in }{s: }sed do eiusmod tempor | - i{n: culpa }{s: }re et dolore magna aliqua. | - U{n: qui }{s: }eniam, quis nostrud | - e{n: officia }{s: }co laboris nisi ut aliquip ex | - {4:[No}{n: deserunt }{s: }{4: }| - Est{n: mollit }{s: } | - L{n: anim }{s: }sit amet, consectetur | - a{n: id }{s: }sed do eiusmod tempor | - i{n: est }{s: }re et dolore magna aliqua. | - U{n: laborum }{c: }eniam, quis nostrud | - {3:[No}{s: Est }{c: }{3: }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - meths.input_mouse('wheel', 'down', '', 0, 9, 40) - screen:expect([[ - Est ^ | - L{n: sunt }{s: }sit amet, consectetur | - a{n: in }{s: }sed do eiusmod tempor | - i{n: culpa }{s: }re et dolore magna aliqua. | - U{n: qui }{s: }eniam, quis nostrud | - e{n: officia }{s: }co laboris nisi ut aliquip ex | - {4:[No}{n: deserunt }{s: }{4: }| - i{n: mollit }{s: }re et dolore magna aliqua. | - U{n: anim }{s: }eniam, quis nostrud | - e{n: id }{s: }co laboris nisi ut aliquip ex | - e{n: est }{s: }at. Duis aute irure dolor in | - r{n: laborum }{c: }oluptate velit esse cillum | - {3:[No}{s: Est }{c: }{3: }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - feed('e') - screen:expect([[ - Est e^ | - L{n: elit } sit amet, consectetur | - a{n: eiusmod } sed do eiusmod tempor | - i{n: et }ore et dolore magna aliqua. | - U{n: enim }veniam, quis nostrud | - e{n: exercitation }mco laboris nisi ut aliquip ex | - {4:[No}{n: ex }{4: }| - i{n: ea }ore et dolore magna aliqua. | - U{n: esse }veniam, quis nostrud | - e{n: eu }mco laboris nisi ut aliquip ex | - e{s: est }uat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - meths.input_mouse('wheel', 'up', '', 0, 9, 40) - screen:expect([[ - Est e^ | - L{n: elit } sit amet, consectetur | - a{n: eiusmod } sed do eiusmod tempor | - i{n: et }ore et dolore magna aliqua. | - U{n: enim }veniam, quis nostrud | - e{n: exercitation }mco laboris nisi ut aliquip ex | - {4:[No}{n: ex }{4: }| - Est{n: ea } | - L{n: esse } sit amet, consectetur | - a{n: eu } sed do eiusmod tempor | - i{s: est }ore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - feed('s') - screen:expect([[ - Est es^ | - L{n: esse } sit amet, consectetur | - a{s: est } sed do eiusmod tempor | - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | - {4:[No Name] [+] }| - Est es | - Lorem ipsum dolor sit amet, consectetur | - adipisicing elit, sed do eiusmod tempor | - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - meths.input_mouse('wheel', 'down', '', 0, 9, 40) - screen:expect([[ - Est es^ | - L{n: esse } sit amet, consectetur | - a{s: est } sed do eiusmod tempor | - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | - {4:[No Name] [+] }| - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | - ea commodo consequat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - feed('') - screen:expect([[ - Est e^ | - L{n: elit } sit amet, consectetur | - a{n: eiusmod } sed do eiusmod tempor | - i{n: et }ore et dolore magna aliqua. | - U{n: enim }veniam, quis nostrud | - e{n: exercitation }mco laboris nisi ut aliquip ex | - {4:[No}{n: ex }{4: }| - i{n: ea }ore et dolore magna aliqua. | - U{n: esse }veniam, quis nostrud | - e{n: eu }mco laboris nisi ut aliquip ex | - e{s: est }uat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | - ]]) - - feed('') - screen:expect([[ - Est eu^ | - L{n: elit } sit amet, consectetur | - a{n: eiusmod } sed do eiusmod tempor | - i{n: et }ore et dolore magna aliqua. | - U{n: enim }veniam, quis nostrud | - e{n: exercitation }mco laboris nisi ut aliquip ex | - {4:[No}{n: ex }{4: }| - i{n: ea }ore et dolore magna aliqua. | - U{n: esse }veniam, quis nostrud | - e{s: eu }mco laboris nisi ut aliquip ex | - e{n: est }uat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | - ]]) - - meths.input_mouse('wheel', 'down', '', 0, 9, 40) - screen:expect([[ - Est eu^ | - L{n: elit } sit amet, consectetur | - a{n: eiusmod } sed do eiusmod tempor | - i{n: et }ore et dolore magna aliqua. | - U{n: enim }veniam, quis nostrud | - e{n: exercitation }mco laboris nisi ut aliquip ex | - {4:[No}{n: ex }{4: }| - e{n: ea }uat. Duis aute irure dolor in | - r{n: esse }voluptate velit esse cillum | - d{s: eu }nulla pariatur. Excepteur sint | - o{n: est }t non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | - ]]) - - funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) - screen:expect([[ - Est eu^ | - {s: ea }t amet, consectetur | - {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor | - {n: ei } et dolore magna aliqua. | - {n: eo }iam, quis nostrud | - {n: eu } laboris nisi ut aliquip ex | - {4:[N}{n: ey }{4: }| - {n: eå }. Duis aute irure dolor in | - {n: eä }uptate velit esse cillum | - {n: eö }la pariatur. Excepteur sint | - occaecat cupidatat non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} | - ]]) - - funcs.complete(4, {'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) - screen:expect([[ - Est eu^ | - {s: ea }r sit amet, consectetur | - {n: eee }, sed do eiusmod tempor | - {n: ei }bore et dolore magna aliqua. | - {n: eo } veniam, quis nostrud | - {n: eu }amco laboris nisi ut aliquip ex | - {4:[N}{n: ey }{4: }| - {n: eå }quat. Duis aute irure dolor in | - {n: eä } voluptate velit esse cillum | - {n: eö } nulla pariatur. Excepteur sint | - occaecat cupidatat non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - Esteee^ | - {n: ea }r sit amet, consectetur | - {s: eee }, sed do eiusmod tempor | - {n: ei }bore et dolore magna aliqua. | - {n: eo } veniam, quis nostrud | - {n: eu }amco laboris nisi ut aliquip ex | - {4:[N}{n: ey }{4: }| - {n: eå }quat. Duis aute irure dolor in | - {n: eä } voluptate velit esse cillum | - {n: eö } nulla pariatur. Excepteur sint | - occaecat cupidatat non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]]) - - funcs.complete(6, {'foo', 'bar'}) - screen:expect([[ - Esteee^ | - Lo{s: foo }sit amet, consectetur | - ad{n: bar }sed do eiusmod tempor | - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | - {4:[No Name] [+] }| - ea commodo consequat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | - occaecat cupidatat non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - Esteefoo^ | - Lorem ipsum dolor sit amet, consectetur | - adipisicing elit, sed do eiusmod tempor | - incididunt ut labore et dolore magna aliqua. | - Ut enim ad minim veniam, quis nostrud | - exercitation ullamco laboris nisi ut aliquip ex | - {4:[No Name] [+] }| - ea commodo consequat. Duis aute irure dolor in | - reprehenderit in voluptate velit esse cillum | - dolore eu fugiat nulla pariatur. Excepteur sint | - occaecat cupidatat non proident, sunt in culpa | - qui officia deserunt mollit anim id est | - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]]) - end) - - it('can be moved due to wrap or resize', function() - feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - some long prefix before the ^ | - {1:~ }{n: word }| - {1:~ }{n: choice}| - {1:~ }{n: text }| - {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - some long prefix before the | - thing^ | - {n:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {s:thing }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - some long prefix before the text| - {1:^~ }{n: word }| - {1:~ }{n: choice}| - {1:~ }{s: text }| - {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - screen:try_resize(30,8) - screen:expect([[ - some long prefix before the | - text^ | - {n:word }{1: }| - {n:choice }{1: }| - {s:text }{1: }| - {n:thing }{1: }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - screen:try_resize(50,8) - screen:expect([[ - some long prefix before the text^ | - {1:~ }{n: word }{1: }| - {1:~ }{n: choice }{1: }| - {1:~ }{s: text }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - screen:try_resize(25,10) - screen:expect([[ - some long prefix before | - the text^ | - {1:~ }{n: word }{1: }| - {1:~ }{n: choice }{1: }| - {1:~ }{s: text }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - screen:try_resize(12,5) - screen:expect([[ - some long | - prefix | - bef{n: word } | - tex{n: }^ | - {2:-- INSERT -} | - ]]) - - -- can't draw the pum, but check we don't crash - screen:try_resize(12,2) - screen:expect([[ - text^ | - {2:-- INSERT -} | - ]]) - - -- but state is preserved, pum reappears - screen:try_resize(20,8) - screen:expect([[ - some long prefix | - before the text^ | - {1:~ }{n: word }{1: }| - {1:~ }{n: choice }{1: }| - {1:~ }{s: text }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) - - it('with VimResized autocmd', function() - feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("autocmd VimResized * redraw!") - command("set linebreak") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - some long prefix before the ^ | - {1:~ }{n: word }| - {1:~ }{n: choice}| - {1:~ }{n: text }| - {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - screen:try_resize(16,10) - screen:expect([[ - some long | - prefix before | - the ^ | - {1:~ }{n: word }| - {1:~ }{n: choice }| - {1:~ }{n: text }| - {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) - - it('with rightleft window', function() - command("set rl wildoptions+=pum") - feed('isome rightleft ') - screen:expect([[ - ^ tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {2:-- INSERT --} | - ]]) - - command("set completeopt+=noinsert,noselect") - funcs.complete(16, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - ^ tfelthgir emos| - {1: }{n: drow}{1: ~}| - {1: }{n: eciohc}{1: ~}| - {1: }{n: txet}{1: ~}| - {1: }{n: gniht}{1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - ^ drow tfelthgir emos| - {1: }{s: drow}{1: ~}| - {1: }{n: eciohc}{1: ~}| - {1: }{n: txet}{1: ~}| - {1: }{n: gniht}{1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - ^ drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {2:-- INSERT --} | - ]]) - - -- not rightleft on the cmdline - feed(':sign ') - screen:expect{grid=[[ - drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - :sign ^ | - ]]} - - feed('') - screen:expect{grid=[[ - drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: }{s: define }{1: ~}| - {1: }{n: jump }{1: ~}| - {1: }{n: list }{1: ~}| - {1: }{n: place }{1: ~}| - {1: }{n: undefine }{1: ~}| - {1: }{n: unplace }{1: ~}| - :sign define^ | - ]]} - end) - - it('with multiline messages', function() - screen:try_resize(40,8) - feed('ixx') - command('imap echoerr "very"\\|echoerr "much"\\|echoerr "error"') - funcs.complete(1, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - xx | - word^ | - {s:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - xx | - word | - {s:word }{1: }| - {4: }| - {6:very} | - {6:much} | - {6:error} | - {5:Press ENTER or type command to continue}^ | - ]]) - - feed('') - screen:expect([[ - xx | - word^ | - {s:word }{1: }| - {n:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - xx | - choice^ | - {n:word }{1: }| - {s:choice }{1: }| - {n:text }{1: }| - {n:thing }{1: }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - command("split") - screen:expect([[ - xx | - choice^ | - {n:word }{1: }| - {s:choice }{4: }| - {n:text } | - {n:thing } | - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]]) - - meths.input_mouse('wheel', 'down', '', 0, 6, 15) - screen:expect{grid=[[ - xx | - choice^ | - {n:word }{1: }| - {s:choice }{4: }| - {n:text } | - {n:thing }{1: }| - {3:[No Name] [+] }| - {2:-- INSERT --} | - ]], unchanged=true} - end) - - it('with kind, menu and abbr attributes', function() - screen:try_resize(40,8) - feed('ixx ') - funcs.complete(4, {{word='wordey', kind= 'x', menu='extrainfo'}, 'thing', {word='secret', abbr='sneaky', menu='bar'}}) - screen:expect([[ - xx wordey^ | - {1:~ }{s: wordey x extrainfo }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }{n: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - xx ^ | - {1:~ }{n: wordey x extrainfo }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }{n: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - xx secret^ | - {1:~ }{n: wordey x extrainfo }{1: }| - {1:~ }{n: thing }{1: }| - {1:~ }{s: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - - feed('') - screen:expect([[ - xx secre^t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) - end) - - it('wildoptions=pum', function() - screen:try_resize(32,10) - command('set wildmenu') - command('set wildoptions=pum') - command('set shellslash') - command("cd test/functional/fixtures/wildpum") - - feed(':sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign ^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign define^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{s: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign list^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{s: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign place^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{s: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign list^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{s: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign jump^ | - ]]) - - -- pressing should end completion and go back to the original match - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign ^ | - ]]) - - -- pressing should select the current match and end completion - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign unplace^ | - ]]) - - -- showing popup menu in different columns in the cmdline - feed('sign define ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: culhl= }{1: }| - {1:~ }{n: icon= }{1: }| - {1:~ }{n: linehl= }{1: }| - {1:~ }{n: numhl= }{1: }| - {1:~ }{n: text= }{1: }| - {1:~ }{n: texthl= }{1: }| - :sign define culhl=^ | - ]]) - - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: culhl= }{1: }| - {1:~ }{n: icon= }{1: }| - {1:~ }{n: linehl= }{1: }| - {1:~ }{n: numhl= }{1: }| - {1:~ }{n: text= }{1: }| - {1:~ }{n: texthl= }{1: }| - :sign define culhl= culhl=^ | - ]]) - - feed('e Xdi') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: XdirA/ }{1: }| - {1:~ }{n: XfileA }{1: }| - :e Xdir/XdirA/^ | - ]]) - - -- Pressing on a directory name should go into that directory - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: XdirB/ }{1: }| - {1:~ }{n: XfileB }{1: }| - :e Xdir/XdirA/XdirB/^ | - ]]) - - -- Pressing on a directory name should go to the parent directory - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: XdirA/ }{1: }| - {1:~ }{n: XfileA }{1: }| - :e Xdir/XdirA/^ | - ]]) - - -- Pressing when the popup menu is displayed should list all the - -- matches and remove the popup menu - feed(':sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - :sign define jump list place und| - efine unplace^ | - ]]) - - -- Pressing after that should move the cursor - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - :sign define jump list place und| - efine unplac^e | - ]]) - feed('') - - -- Pressing when the popup menu is displayed should remove the popup - -- menu - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - :sign define | - define | - :sign define^ | - ]]) - - -- Pressing should open the popup menu with the last entry selected - feed(':sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{s: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign undefine^ | - ]]) - - -- Pressing should close the popup menu and cancel the cmd line - feed(':sign ') - screen:expect([[ - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) - - -- Typing a character when the popup is open, should close the popup - feed(':sign x') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign definex^ | - ]]) - - -- When the popup is open, entering the cmdline window should close the popup - feed('sign ') - screen:expect([[ - | - {3:[No Name] }| - {1::}sign define | - {1::}sign define^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4:[Command Line] }| - :sign define | - ]]) - feed(':q') - - -- After the last popup menu item, should show the original string - feed(':sign u') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign u^ | - ]]) - - -- Use the popup menu for the command name - feed('bu') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {s: bufdo }{1: }| - {n: buffer }{1: }| - {n: buffers }{1: }| - {n: bunload }{1: }| - :bufdo^ | - ]]) - - -- Pressing should remove the popup menu and erase the last character - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign defin^ | - ]]) - - -- Pressing should remove the popup menu and erase the previous word - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign ^ | - ]]) - - -- Pressing should remove the popup menu and erase the entire line - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :^ | - ]]) - - -- Using to cancel the popup menu and then pressing should recall - -- the cmdline from history - feed('sign xyz:sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign xyz^ | - ]]) - - feed('') - - -- Check "list" still works - command('set wildmode=longest,list') - feed(':cn') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - :cn | - cnewer cnoreabbrev | - cnext cnoremap | - cnfile cnoremenu | - :cn^ | - ]]) - feed('s') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - :cn | - cnewer cnoreabbrev | - cnext cnoremap | - cnfile cnoremenu | - :cns^ | - ]]) - - feed('') - command('set wildmode=full') - - -- Tests a directory name contained full-width characters. - feed(':e あいう/') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: 123 }{1: }| - {1:~ }{n: abc }{1: }| - {1:~ }{n: xyz }{1: }| - :e あいう/123^ | - ]]) - feed('') - - -- Pressing should scroll the menu downward - feed(':sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{s: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign undefine^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{s: unplace }{1: }| - :sign unplace^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign ^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign define^ | - ]]) - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{s: unplace }{1: }| - :sign unplace^ | - ]]) - - -- Pressing should scroll the menu upward - feed('sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign ^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{s: unplace }{1: }| - :sign unplace^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{n: define }{1: }| - {1:~ }{s: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign jump^ | - ]]) - feed('') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign define^ | - ]]) - - feed('') - - -- check positioning with multibyte char in pattern - command("e långfile1") - command("sp långfile2") - feed(':b lå') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {4:långfile2 }| - | - {1:~ }| - {1:~ }{s: långfile1 }{1: }| - {3:lå}{n: långfile2 }{3: }| - :b långfile1^ | - ]]) - - -- check doesn't crash on screen resize - screen:try_resize(20,6) - screen:expect([[ - | - {1:~ }| - {4:långfile2 }| - {s: långfile1 } | - {3:lå}{n: långfile2 }{3: }| - :b långfile1^ | - ]]) - - screen:try_resize(50,15) - screen:expect([[ - | - {1:~ }| - {4:långfile2 }| - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: långfile1 }{1: }| - {3:lå}{n: långfile2 }{3: }| - :b långfile1^ | - ]]) - - -- position is calculated correctly with "longest" - feed('') - command('set wildmode=longest:full,full') - feed(':b lå') - screen:expect([[ - | - {1:~ }| - {4:långfile2 }| - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{n: långfile1 }{1: }| - {3:lå}{n: långfile2 }{3: }| - :b långfile^ | - ]]) - - feed('') - command("close") - command('set wildmode=full') - - -- special case: when patterns ends with "/", show menu items aligned - -- after the "/" - feed(':e compdir/') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: file1 }{1: }| - {1:~ }{n: file2 }{1: }| - :e compdir/file1^ | - ]]) - end) - - it('wildoptions=pum with scrolled messages', function() - screen:try_resize(40,10) - command('set wildmenu') - command('set wildoptions=pum') - - feed(':echoerr "fail"|echoerr "error"') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - {6:fail} | - {6:error} | - {5:Press ENTER or type command to continue}^ | - ]]} - - feed(':sign ') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {4: }{n: place }{4: }| - {6:fail} {n: undefine } | - {6:error}{n: unplace } | - :sign define^ | - ]]} - - feed('d') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {4: }| - {6:fail} | - {6:error} | - :sign defined^ | - ]]} - end) - - it('wildoptions=pum and wildmode=longest,full #11622', function() - screen:try_resize(30,8) - command('set wildmenu') - command('set wildoptions=pum') - command('set wildmode=longest,full') - - -- With 'wildmode' set to 'longest,full', completing a match should display - -- the longest match, the wildmenu should not be displayed. - feed(':sign u') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :sign un^ | - ]]} - eq(0, funcs.wildmenumode()) - - -- pressing should display the wildmenu - feed('') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{s: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign undefine^ | - ]]} - eq(1, funcs.wildmenumode()) - - -- pressing second time should select the next entry in the menu - feed('') - screen:expect{grid=[[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }{n: undefine }{1: }| - {1:~ }{s: unplace }{1: }| - :sign unplace^ | - ]]} - end) - - it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function() - screen:try_resize(32, 10) - meths.buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) - command('set wildoptions+=pum') - feed('$') - feed(':sign ') - screen:expect([[ - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaa {s: define } | - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign define^ | - ]]) - end) - - -- oldtest: Test_wildmenu_pum_clear_entries() - it('wildoptions=pum when using Ctrl-E as wildchar vim-patch:9.0.1030', function() - screen:try_resize(30, 10) - exec([[ - set wildoptions=pum - set wildchar= - ]]) - feed(':sign ') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }{s: define }{1: }| - {1:~ }{n: jump }{1: }| - {1:~ }{n: list }{1: }| - {1:~ }{n: place }{1: }| - {1:~ }{n: undefine }{1: }| - {1:~ }{n: unplace }{1: }| - :sign define^ | - ]]) - assert_alive() - end) - - it("'pumblend' RGB-color", function() - screen:try_resize(60,14) + it('RGB-color', function() + local screen = Screen.new(60, 14) screen:set_default_attr_ids({ [1] = {background = Screen.colors.Yellow}, [2] = {bold = true, reverse = true}, @@ -2933,6 +1075,7 @@ describe('builtin popupmenu', function() [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')}, [45] = {background = Screen.colors.WebGray, blend=0}, }) + screen:attach() command('syntax on') command('set mouse=a') command('set pumblend=10') @@ -3081,10 +1224,8 @@ describe('builtin popupmenu', function() ]]) end) - it("'pumblend' 256-color (non-RGB)", function() - screen:detach() - screen = Screen.new(60, 8) - screen:attach({rgb=false, ext_popupmenu=false}) + it('256-color (non-RGB)', function() + local screen = Screen.new(60, 8) screen:set_default_attr_ids({ [1] = {foreground = Screen.colors.Grey0, background = tonumber('0x000007')}, [2] = {foreground = tonumber('0x000055'), background = tonumber('0x000007')}, @@ -3097,6 +1238,7 @@ describe('builtin popupmenu', function() [9] = {bold = true}, [10] = {foreground = tonumber('0x000002')}, }) + screen:attach({rgb=false}) command('set notermguicolors pumblend=10') insert([[ Lorem ipsum dolor sit amet, consectetur @@ -3117,713 +1259,3326 @@ describe('builtin popupmenu', function() {9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} | ]]) end) +end) - it("'pumheight'", function() - screen:try_resize(32,8) - feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - command("set pumheight=2") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - some long prefix before the ^ | - {1:~ }{n: word }{c: }| - {1:~ }{n: choice}{s: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) +describe('builtin popupmenu', function() + before_each(clear) - it("'pumwidth'", function() - screen:try_resize(32,8) - feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - command("set pumwidth=8") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) - screen:expect([[ - some long prefix before the ^ | - {1:~ }{n: word }| - {1:~ }{n: choice}| - {1:~ }{n: text }| - {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) + local function with_ext_multigrid(multigrid) + local screen + before_each(function() + screen = Screen.new(32, 20) + screen:set_default_attr_ids({ + -- popup selected item / scrollbar track + ['s'] = {background = Screen.colors.WebGray}, + -- popup non-selected item + ['n'] = {background = Screen.colors.LightMagenta}, + -- popup scrollbar knob + ['c'] = {background = Screen.colors.Grey0}, + [1] = {bold = true, foreground = Screen.colors.Blue}, + [2] = {bold = true}, + [3] = {reverse = true}, + [4] = {bold = true, reverse = true}, + [5] = {bold = true, foreground = Screen.colors.SeaGreen}, + [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [7] = {background = Screen.colors.Yellow}, -- Search + [8] = {foreground = Screen.colors.Red}, + }) + screen:attach({ext_multigrid=multigrid}) + end) - it('does not crash when displayed in the last column with rightleft (#12032)', function() - local col = 30 - local items = {'word', 'choice', 'text', 'thing'} - local max_len = 0 - for _, v in ipairs(items) do - max_len = max_len < #v and #v or max_len - end - screen:try_resize(col, 8) - command('set rightleft') - command('call setline(1, repeat(" ", &columns - '..max_len..'))') - feed('$i') - funcs.complete(col - max_len, items) - feed('') - assert_alive() - end) + it('with preview-window above', function() + feed(':ped4+') + feed('iaa bb cc dd ee ff gg hh ii jj') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + {3:[No Name] [Preview][+] }| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + {4:[No Name] [+] }| + [3:--------------------------------]| + ## grid 2 + aa bb cc dd ee ff gg hh ii jj | + aa^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- }{5:match 1 of 10} | + ## grid 4 + aa bb cc dd ee ff gg hh ii jj | + aa | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 5 + {s:aa }{c: }| + {n:bb }{c: }| + {n:cc }{c: }| + {n:dd }{c: }| + {n:ee }{c: }| + {n:ff }{c: }| + {n:gg }{s: }| + {n:hh }{s: }| + ]], float_pos={ + [5] = {{id = -1}, "NW", 2, 2, 0, false, 100}; + }} + else + screen:expect([[ + aa bb cc dd ee ff gg hh ii jj | + aa | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {3:[No Name] [Preview][+] }| + aa bb cc dd ee ff gg hh ii jj | + aa^ | + {s:aa }{c: }{1: }| + {n:bb }{c: }{1: }| + {n:cc }{c: }{1: }| + {n:dd }{c: }{1: }| + {n:ee }{c: }{1: }| + {n:ff }{c: }{1: }| + {n:gg }{s: }{1: }| + {n:hh }{s: }{4: }| + {2:-- }{5:match 1 of 10} | + ]]) + end + end) - it('truncates double-width character correctly when there is no scrollbar', function() - screen:try_resize(32,8) - command('set completeopt+=menuone,noselect') - feed('i' .. string.rep(' ', 13)) - funcs.complete(14, {'哦哦哦哦哦哦哦哦哦哦'}) - screen:expect([[ - ^ | - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) + it('with preview-window below', function() + feed(':ped4+r') + feed('iaa bb cc dd ee ff gg hh ii jj') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + {4:[No Name] [+] }| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + {3:[No Name] [Preview][+] }| + [3:--------------------------------]| + ## grid 2 + aa bb cc dd ee ff gg hh ii jj | + aa^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- }{5:match 1 of 10} | + ## grid 4 + aa bb cc dd ee ff gg hh ii jj | + aa | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 5 + {s:aa }{c: }| + {n:bb }{c: }| + {n:cc }{c: }| + {n:dd }{c: }| + {n:ee }{c: }| + {n:ff }{c: }| + {n:gg }{s: }| + {n:hh }{s: }| + ]], float_pos={ + [5] = {{id = -1}, "NW", 2, 2, 0, false, 100}; + }} + else + screen:expect([[ + aa bb cc dd ee ff gg hh ii jj | + aa^ | + {s:aa }{c: }{1: }| + {n:bb }{c: }{1: }| + {n:cc }{c: }{1: }| + {n:dd }{c: }{1: }| + {n:ee }{c: }{1: }| + {n:ff }{c: }{1: }| + {n:gg }{s: }{1: }| + {n:hh }{s: }{4: }| + aa bb cc dd ee ff gg hh ii jj | + aa | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {3:[No Name] [Preview][+] }| + {2:-- }{5:match 1 of 10} | + ]]) + end + end) - it('truncates double-width character correctly when there is scrollbar', function() - screen:try_resize(32,8) - command('set completeopt+=noselect') - command('set pumheight=4') - feed('i' .. string.rep(' ', 12)) - local items = {} - for _ = 1, 8 do - table.insert(items, {word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1}) - end - funcs.complete(13, items) - screen:expect([[ - ^ | - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {1:~ }| - {1:~ }| - {2:-- INSERT --} | - ]]) - end) + it('with preview-window above and tall and inverted', function() + feed(':ped8+') + feed('iaabbccddee') + feed('ffgghhiijj') + feed('kkllmmnnoo') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + {3:[No Name] [Preview][+] }| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + {4:[No Name] [+] }| + [3:--------------------------------]| + ## grid 2 + dd | + ee | + ff | + gg | + hh | + ii | + jj | + kk | + ll | + mm | + nn | + oo | + aa^ | + ## grid 3 + {2:-- }{5:match 1 of 15} | + ## grid 4 + aa | + bb | + cc | + dd | + ## grid 5 + {s:aa }{c: }| + {n:bb }{c: }| + {n:cc }{c: }| + {n:dd }{c: }| + {n:ee }{c: }| + {n:ff }{c: }| + {n:gg }{c: }| + {n:hh }{c: }| + {n:ii }{c: }| + {n:jj }{c: }| + {n:kk }{c: }| + {n:ll }{s: }| + {n:mm }{s: }| + ]], float_pos={ + [5] = {{id = -1}, "SW", 2, 12, 0, false, 100}; + }} + else + screen:expect([[ + aa | + bb | + cc | + dd | + {s:aa }{c: }{3:ew][+] }| + {n:bb }{c: } | + {n:cc }{c: } | + {n:dd }{c: } | + {n:ee }{c: } | + {n:ff }{c: } | + {n:gg }{c: } | + {n:hh }{c: } | + {n:ii }{c: } | + {n:jj }{c: } | + {n:kk }{c: } | + {n:ll }{s: } | + {n:mm }{s: } | + aa^ | + {4:[No Name] [+] }| + {2:-- }{5:match 1 of 15} | + ]]) + end + end) - it('supports mousemodel=popup', function() - screen:try_resize(32, 6) - exec([[ - call setline(1, 'popup menu test') - set mouse=a mousemodel=popup + it('with preview-window above and short and inverted', function() + feed(':ped4+') + feed('iaabbccddee') + feed('ffgghhiijj') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + {3:[No Name] [Preview][+] }| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + {4:[No Name] [+] }| + [3:--------------------------------]| + ## grid 2 + cc | + dd | + ee | + ff | + gg | + hh | + ii | + jj | + aa^ | + ## grid 3 + {2:-- }{5:match 1 of 10} | + ## grid 4 + aa | + bb | + cc | + dd | + ee | + ff | + gg | + hh | + ## grid 5 + {s:aa }{c: }| + {n:bb }{c: }| + {n:cc }{c: }| + {n:dd }{c: }| + {n:ee }{c: }| + {n:ff }{c: }| + {n:gg }{c: }| + {n:hh }{c: }| + {n:ii }{s: }| + ]], float_pos={ + [5] = {{id = -1}, "SW", 2, 8, 0, false, 100}; + }} + else + screen:expect([[ + aa | + bb | + cc | + dd | + ee | + ff | + gg | + hh | + {s:aa }{c: }{3:ew][+] }| + {n:bb }{c: } | + {n:cc }{c: } | + {n:dd }{c: } | + {n:ee }{c: } | + {n:ff }{c: } | + {n:gg }{c: } | + {n:hh }{c: } | + {n:ii }{s: } | + aa^ | + {4:[No Name] [+] }| + {2:-- }{5:match 1 of 10} | + ]]) + end + end) - aunmenu PopUp - menu PopUp.foo :let g:menustr = 'foo' - menu PopUp.bar :let g:menustr = 'bar' - menu PopUp.baz :let g:menustr = 'baz' - ]]) - feed('<4,0>') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{n: baz }{1: }| - {1:~ }| - | - ]]) - feed('') - screen:expect([[ - ^popup menu test | - {1:~ }{s: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{n: baz }{1: }| - {1:~ }| - | - ]]) - feed('') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{s: bar }{1: }| - {1:~ }{n: baz }{1: }| - {1:~ }| - | - ]]) - feed('') - screen:expect([[ - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :let g:menustr = 'bar' | - ]]) - eq('bar', meths.get_var('menustr')) - feed('<20,2>') - screen:expect([[ - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - :let g:menustr = 'b{n: baz } | - ]]) - feed('<22,5>') - screen:expect([[ - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :let g:menustr = 'baz' | - ]]) - eq('baz', meths.get_var('menustr')) - feed('<4,0>') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{n: baz }{1: }| - {1:~ }| - :let g:menustr = 'baz' | - ]]) - feed('<6,3>') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{s: baz }{1: }| - {1:~ }| - :let g:menustr = 'baz' | - ]]) - feed('<6,1>') - screen:expect([[ - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :let g:menustr = 'foo' | - ]]) - eq('foo', meths.get_var('menustr')) - eq(false, screen.options.mousemoveevent) - feed('<4,0>') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{n: baz }{1: }| - {1:~ }| - :let g:menustr = 'foo' | - ]]) - eq(true, screen.options.mousemoveevent) - feed('<6,3>') - screen:expect([[ - ^popup menu test | - {1:~ }{n: foo }{1: }| - {1:~ }{n: bar }{1: }| - {1:~ }{s: baz }{1: }| - {1:~ }| - :let g:menustr = 'foo' | - ]]) - eq(true, screen.options.mousemoveevent) - feed('<6,2>') - screen:expect([[ - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :let g:menustr = 'bar' | - ]]) - eq(false, screen.options.mousemoveevent) - eq('bar', meths.get_var('menustr')) - end) + it('with preview-window below and inverted', function() + feed(':ped4+r') + feed('iaabbccddee') + feed('ffgghhiijj') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + {4:[No Name] [+] }| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + [4:--------------------------------]| + {3:[No Name] [Preview][+] }| + [3:--------------------------------]| + ## grid 2 + cc | + dd | + ee | + ff | + gg | + hh | + ii | + jj | + aa^ | + ## grid 3 + {2:-- }{5:match 1 of 10} | + ## grid 4 + aa | + bb | + cc | + dd | + ee | + ff | + gg | + hh | + ## grid 5 + {s:aa }{c: }| + {n:bb }{c: }| + {n:cc }{c: }| + {n:dd }{c: }| + {n:ee }{c: }| + {n:ff }{c: }| + {n:gg }{s: }| + {n:hh }{s: }| + ]], float_pos={ + [5] = {{id = -1}, "SW", 2, 8, 0, false, 100}; + }} + else + screen:expect([[ + {s:aa }{c: } | + {n:bb }{c: } | + {n:cc }{c: } | + {n:dd }{c: } | + {n:ee }{c: } | + {n:ff }{c: } | + {n:gg }{s: } | + {n:hh }{s: } | + aa^ | + {4:[No Name] [+] }| + aa | + bb | + cc | + dd | + ee | + ff | + gg | + hh | + {3:[No Name] [Preview][+] }| + {2:-- }{5:match 1 of 10} | + ]]) + end + end) - -- oldtest: Test_popup_command_dump() - it(':popup command', function() - exec([[ - func ChangeMenu() - aunmenu PopUp.&Paste - nnoremenu 1.40 PopUp.&Paste :echomsg "pasted" - echomsg 'changed' - return "\" - endfunc - - let lines =<< trim END - one two three four five - and one two Xthree four five - one more two three four five - END - call setline(1, lines) - - aunmenu * - source $VIMRUNTIME/menu.vim - ]]) - feed('/X:popup PopUp') - screen:expect([[ - one two three four five | - and one two {7:^X}three four five | - one more tw{n: Undo } | - {1:~ }{n: }{1: }| - {1:~ }{n: Paste }{1: }| - {1:~ }{n: }{1: }| - {1:~ }{n: Select Word }{1: }| - {1:~ }{n: Select Sentence }{1: }| - {1:~ }{n: Select Paragraph }{1: }| - {1:~ }{n: Select Line }{1: }| - {1:~ }{n: Select Block }{1: }| - {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :popup PopUp | - ]]) + if not multigrid then + -- oldtest: Test_pum_with_preview_win() + it('preview window opened during completion', function() + exec([[ + funct Omni_test(findstart, base) + if a:findstart + return col(".") - 1 + endif + return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] + endfunc + set omnifunc=Omni_test + set completeopt+=longest + ]]) + feed('Gi') + screen:expect([[ + ^ | + {n:one }{1: }| + {n:two }{1: }| + {n:three }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- }{8:Back at original} | + ]]) + feed('') + screen:expect([[ + 1info | + | + {1:~ }| + {3:[Scratch] [Preview] }| + one^ | + {s:one }{1: }| + {n:two }{1: }| + {n:three }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4:[No Name] [+] }| + {2:-- }{5:match 1 of 3} | + ]]) + end) + end - -- go to the Paste entry in the menu - feed('jj') - screen:expect([[ - one two three four five | - and one two {7:^X}three four five | - one more tw{n: Undo } | - {1:~ }{n: }{1: }| - {1:~ }{s: Paste }{1: }| - {1:~ }{n: }{1: }| - {1:~ }{n: Select Word }{1: }| - {1:~ }{n: Select Sentence }{1: }| - {1:~ }{n: Select Paragraph }{1: }| - {1:~ }{n: Select Line }{1: }| - {1:~ }{n: Select Block }{1: }| - {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - :popup PopUp | - ]]) + it('with vsplits', function() + screen:try_resize(32, 8) + insert('aaa aab aac\n') + feed(':vsplit') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + {4:[No Name] [+] }{3:') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]| + {4:[No Name] [+] }{3:oc a') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + {3:') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + {3:') + screen:expect([[ + Est ^ | + L{n: sunt }{s: }sit amet, consectetur | + a{n: in }{s: }sed do eiusmod tempor | + i{n: culpa }{s: }re et dolore magna aliqua. | + U{n: qui }{s: }eniam, quis nostrud | + e{n: officia }{s: }co laboris nisi ut aliquip ex | + {4:[No}{n: deserunt }{s: }{4: }| + Est{n: mollit }{s: } | + L{n: anim }{s: }sit amet, consectetur | + a{n: id }{s: }sed do eiusmod tempor | + i{n: est }{s: }re et dolore magna aliqua. | + U{n: laborum }{c: }eniam, quis nostrud | + {3:[No}{s: Est }{c: }{3: }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + meths.input_mouse('wheel', 'down', '', 0, 9, 40) + screen:expect([[ + Est ^ | + L{n: sunt }{s: }sit amet, consectetur | + a{n: in }{s: }sed do eiusmod tempor | + i{n: culpa }{s: }re et dolore magna aliqua. | + U{n: qui }{s: }eniam, quis nostrud | + e{n: officia }{s: }co laboris nisi ut aliquip ex | + {4:[No}{n: deserunt }{s: }{4: }| + i{n: mollit }{s: }re et dolore magna aliqua. | + U{n: anim }{s: }eniam, quis nostrud | + e{n: id }{s: }co laboris nisi ut aliquip ex | + e{n: est }{s: }at. Duis aute irure dolor in | + r{n: laborum }{c: }oluptate velit esse cillum | + {3:[No}{s: Est }{c: }{3: }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + feed('e') + screen:expect([[ + Est e^ | + L{n: elit } sit amet, consectetur | + a{n: eiusmod } sed do eiusmod tempor | + i{n: et }ore et dolore magna aliqua. | + U{n: enim }veniam, quis nostrud | + e{n: exercitation }mco laboris nisi ut aliquip ex | + {4:[No}{n: ex }{4: }| + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{n: eu }mco laboris nisi ut aliquip ex | + e{s: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + meths.input_mouse('wheel', 'up', '', 0, 9, 40) + screen:expect([[ + Est e^ | + L{n: elit } sit amet, consectetur | + a{n: eiusmod } sed do eiusmod tempor | + i{n: et }ore et dolore magna aliqua. | + U{n: enim }veniam, quis nostrud | + e{n: exercitation }mco laboris nisi ut aliquip ex | + {4:[No}{n: ex }{4: }| + Est{n: ea } | + L{n: esse } sit amet, consectetur | + a{n: eu } sed do eiusmod tempor | + i{s: est }ore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + feed('s') + screen:expect([[ + Est es^ | + L{n: esse } sit amet, consectetur | + a{s: est } sed do eiusmod tempor | + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + {4:[No Name] [+] }| + Est es | + Lorem ipsum dolor sit amet, consectetur | + adipisicing elit, sed do eiusmod tempor | + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + meths.input_mouse('wheel', 'down', '', 0, 9, 40) + screen:expect([[ + Est es^ | + L{n: esse } sit amet, consectetur | + a{s: est } sed do eiusmod tempor | + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + {4:[No Name] [+] }| + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + feed('') + screen:expect([[ + Est e^ | + L{n: elit } sit amet, consectetur | + a{n: eiusmod } sed do eiusmod tempor | + i{n: et }ore et dolore magna aliqua. | + U{n: enim }veniam, quis nostrud | + e{n: exercitation }mco laboris nisi ut aliquip ex | + {4:[No}{n: ex }{4: }| + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{n: eu }mco laboris nisi ut aliquip ex | + e{s: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | + ]]) + + feed('') + screen:expect([[ + Est eu^ | + L{n: elit } sit amet, consectetur | + a{n: eiusmod } sed do eiusmod tempor | + i{n: et }ore et dolore magna aliqua. | + U{n: enim }veniam, quis nostrud | + e{n: exercitation }mco laboris nisi ut aliquip ex | + {4:[No}{n: ex }{4: }| + i{n: ea }ore et dolore magna aliqua. | + U{n: esse }veniam, quis nostrud | + e{s: eu }mco laboris nisi ut aliquip ex | + e{n: est }uat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | + ]]) + + meths.input_mouse('wheel', 'down', '', 0, 9, 40) + screen:expect([[ + Est eu^ | + L{n: elit } sit amet, consectetur | + a{n: eiusmod } sed do eiusmod tempor | + i{n: et }ore et dolore magna aliqua. | + U{n: enim }veniam, quis nostrud | + e{n: exercitation }mco laboris nisi ut aliquip ex | + {4:[No}{n: ex }{4: }| + e{n: ea }uat. Duis aute irure dolor in | + r{n: esse }voluptate velit esse cillum | + d{s: eu }nulla pariatur. Excepteur sint | + o{n: est }t non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | + ]]) + + funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) + screen:expect([[ + Est eu^ | + {s: ea }t amet, consectetur | + {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor | + {n: ei } et dolore magna aliqua. | + {n: eo }iam, quis nostrud | + {n: eu } laboris nisi ut aliquip ex | + {4:[N}{n: ey }{4: }| + {n: eå }. Duis aute irure dolor in | + {n: eä }uptate velit esse cillum | + {n: eö }la pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} | + ]]) + + funcs.complete(4, {'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) + screen:expect([[ + Est eu^ | + {s: ea }r sit amet, consectetur | + {n: eee }, sed do eiusmod tempor | + {n: ei }bore et dolore magna aliqua. | + {n: eo } veniam, quis nostrud | + {n: eu }amco laboris nisi ut aliquip ex | + {4:[N}{n: ey }{4: }| + {n: eå }quat. Duis aute irure dolor in | + {n: eä } voluptate velit esse cillum | + {n: eö } nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + Esteee^ | + {n: ea }r sit amet, consectetur | + {s: eee }, sed do eiusmod tempor | + {n: ei }bore et dolore magna aliqua. | + {n: eo } veniam, quis nostrud | + {n: eu }amco laboris nisi ut aliquip ex | + {4:[N}{n: ey }{4: }| + {n: eå }quat. Duis aute irure dolor in | + {n: eä } voluptate velit esse cillum | + {n: eö } nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + + funcs.complete(6, {'foo', 'bar'}) + screen:expect([[ + Esteee^ | + Lo{s: foo }sit amet, consectetur | + ad{n: bar }sed do eiusmod tempor | + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + {4:[No Name] [+] }| + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + Esteefoo^ | + Lorem ipsum dolor sit amet, consectetur | + adipisicing elit, sed do eiusmod tempor | + incididunt ut labore et dolore magna aliqua. | + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + {4:[No Name] [+] }| + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + end) + + it('can be moved due to wrap or resize', function() + feed('isome long prefix before the ') + command("set completeopt+=noinsert,noselect") + command("set linebreak") + funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + screen:expect([[ + some long prefix before the ^ | + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + some long prefix before the | + thing^ | + {n:word }{1: }| + {n:choice }{1: }| + {n:text }{1: }| + {s:thing }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + some long prefix before the text| + {1:^~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{s: text }| + {1:~ }{n: thing }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + screen:try_resize(30,8) + screen:expect([[ + some long prefix before the | + text^ | + {n:word }{1: }| + {n:choice }{1: }| + {s:text }{1: }| + {n:thing }{1: }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + screen:try_resize(50,8) + screen:expect([[ + some long prefix before the text^ | + {1:~ }{n: word }{1: }| + {1:~ }{n: choice }{1: }| + {1:~ }{s: text }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + screen:try_resize(25,10) + screen:expect([[ + some long prefix before | + the text^ | + {1:~ }{n: word }{1: }| + {1:~ }{n: choice }{1: }| + {1:~ }{s: text }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + screen:try_resize(12,5) + screen:expect([[ + some long | + prefix | + bef{n: word } | + tex{n: }^ | + {2:-- INSERT -} | + ]]) + + -- can't draw the pum, but check we don't crash + screen:try_resize(12,2) + screen:expect([[ + text^ | + {2:-- INSERT -} | + ]]) + + -- but state is preserved, pum reappears + screen:try_resize(20,8) + screen:expect([[ + some long prefix | + before the text^ | + {1:~ }{n: word }{1: }| + {1:~ }{n: choice }{1: }| + {1:~ }{s: text }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end) + + it('with VimResized autocmd', function() + feed('isome long prefix before the ') + command("set completeopt+=noinsert,noselect") + command("autocmd VimResized * redraw!") + command("set linebreak") + funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + screen:expect([[ + some long prefix before the ^ | + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + screen:try_resize(16,10) + screen:expect([[ + some long | + prefix before | + the ^ | + {1:~ }{n: word }| + {1:~ }{n: choice }| + {1:~ }{n: text }| + {1:~ }{n: thing }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end) + + it('with rightleft window', function() + command("set rl wildoptions+=pum") + feed('isome rightleft ') + screen:expect([[ + ^ tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {2:-- INSERT --} | + ]]) + + command("set completeopt+=noinsert,noselect") + funcs.complete(16, {'word', 'choice', 'text', 'thing'}) + screen:expect([[ + ^ tfelthgir emos| + {1: }{n: drow}{1: ~}| + {1: }{n: eciohc}{1: ~}| + {1: }{n: txet}{1: ~}| + {1: }{n: gniht}{1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + ^ drow tfelthgir emos| + {1: }{s: drow}{1: ~}| + {1: }{n: eciohc}{1: ~}| + {1: }{n: txet}{1: ~}| + {1: }{n: gniht}{1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + ^ drow tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {2:-- INSERT --} | + ]]) + + -- not rightleft on the cmdline + feed(':sign ') + screen:expect{grid=[[ + drow tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + :sign ^ | + ]]} + + feed('') + screen:expect{grid=[[ + drow tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: }{s: define }{1: ~}| + {1: }{n: jump }{1: ~}| + {1: }{n: list }{1: ~}| + {1: }{n: place }{1: ~}| + {1: }{n: undefine }{1: ~}| + {1: }{n: unplace }{1: ~}| + :sign define^ | + ]]} + end) + end - feed('') + it('with rightleft vsplits', function() + screen:try_resize(40, 8) + command('set rightleft') + command('rightbelow vsplit') + command("set completeopt+=noinsert,noselect") + feed('isome rightleft ') + funcs.complete(16, {'word', 'choice', 'text', 'thing'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + {3:[No Name] [+] }{4:[No Name] [+] }| + [3:----------------------------------------]| + ## grid 2 + tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + ^ tfelthgir emos| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 5 + {n: drow}| + {n: eciohc}| + {n: txet}| + {n: gniht}| + ]], float_pos={ + [5] = {{id = -1}, "NW", 4, 1, -11, false, 100}; + }} + else + screen:expect([[ + tfelthgir emos│ ^ tfelthgir emos| + {1: }{n: drow}{1: ~}| + {1: }{n: eciohc}{1: ~}| + {1: }{n: txet}{1: ~}| + {1: }{n: gniht}{1: ~}| + {1: ~}│{1: ~}| + {3:[No Name] [+] }{4:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + end + end) - -- Set an mapping to change a menu entry while it's displayed. - -- The text should not change but the command does. - -- Also verify that "changed" shows up, which means the mapping triggered. - command('nnoremap ChangeMenu()') - feed('/X:popup PopUp') - screen:expect([[ - one two three four five | - and one two {7:^X}three four five | - one more tw{n: Undo } | - {1:~ }{n: }{1: }| - {1:~ }{n: Paste }{1: }| - {1:~ }{n: }{1: }| - {1:~ }{n: Select Word }{1: }| - {1:~ }{n: Select Sentence }{1: }| - {1:~ }{n: Select Paragraph }{1: }| - {1:~ }{n: Select Line }{1: }| - {1:~ }{n: Select Block }{1: }| - {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - changed | - ]]) + if not multigrid then + it('with multiline messages', function() + screen:try_resize(40,8) + feed('ixx') + command('imap echoerr "very"\\|echoerr "much"\\|echoerr "error"') + funcs.complete(1, {'word', 'choice', 'text', 'thing'}) + screen:expect([[ + xx | + word^ | + {s:word }{1: }| + {n:choice }{1: }| + {n:text }{1: }| + {n:thing }{1: }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + xx | + word | + {s:word }{1: }| + {4: }| + {6:very} | + {6:much} | + {6:error} | + {5:Press ENTER or type command to continue}^ | + ]]) + + feed('') + screen:expect([[ + xx | + word^ | + {s:word }{1: }| + {n:choice }{1: }| + {n:text }{1: }| + {n:thing }{1: }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + xx | + choice^ | + {n:word }{1: }| + {s:choice }{1: }| + {n:text }{1: }| + {n:thing }{1: }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + command("split") + screen:expect([[ + xx | + choice^ | + {n:word }{1: }| + {s:choice }{4: }| + {n:text } | + {n:thing } | + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + + meths.input_mouse('wheel', 'down', '', 0, 6, 15) + screen:expect{grid=[[ + xx | + choice^ | + {n:word }{1: }| + {s:choice }{4: }| + {n:text } | + {n:thing }{1: }| + {3:[No Name] [+] }| + {2:-- INSERT --} | + ]], unchanged=true} + end) + + it('with kind, menu and abbr attributes', function() + screen:try_resize(40,8) + feed('ixx ') + funcs.complete(4, {{word='wordey', kind= 'x', menu='extrainfo'}, 'thing', {word='secret', abbr='sneaky', menu='bar'}}) + screen:expect([[ + xx wordey^ | + {1:~ }{s: wordey x extrainfo }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }{n: sneaky bar }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + xx ^ | + {1:~ }{n: wordey x extrainfo }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }{n: sneaky bar }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + xx secret^ | + {1:~ }{n: wordey x extrainfo }{1: }| + {1:~ }{n: thing }{1: }| + {1:~ }{s: sneaky bar }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + + feed('') + screen:expect([[ + xx secre^t | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) + + it('wildoptions=pum', function() + screen:try_resize(32,10) + command('set wildmenu') + command('set wildoptions=pum') + command('set shellslash') + command("cd test/functional/fixtures/wildpum") + + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{s: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign list^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{s: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign place^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{s: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign list^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{s: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign jump^ | + ]]) + + -- pressing should end completion and go back to the original match + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]]) + + -- pressing should select the current match and end completion + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplace^ | + ]]) + + -- showing popup menu in different columns in the cmdline + feed('sign define ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: culhl= }{1: }| + {1:~ }{n: icon= }{1: }| + {1:~ }{n: linehl= }{1: }| + {1:~ }{n: numhl= }{1: }| + {1:~ }{n: text= }{1: }| + {1:~ }{n: texthl= }{1: }| + :sign define culhl=^ | + ]]) + + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: culhl= }{1: }| + {1:~ }{n: icon= }{1: }| + {1:~ }{n: linehl= }{1: }| + {1:~ }{n: numhl= }{1: }| + {1:~ }{n: text= }{1: }| + {1:~ }{n: texthl= }{1: }| + :sign define culhl= culhl=^ | + ]]) + + feed('e Xdi') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: XdirA/ }{1: }| + {1:~ }{n: XfileA }{1: }| + :e Xdir/XdirA/^ | + ]]) + + -- Pressing on a directory name should go into that directory + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: XdirB/ }{1: }| + {1:~ }{n: XfileB }{1: }| + :e Xdir/XdirA/XdirB/^ | + ]]) + + -- Pressing on a directory name should go to the parent directory + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: XdirA/ }{1: }| + {1:~ }{n: XfileA }{1: }| + :e Xdir/XdirA/^ | + ]]) + + -- Pressing when the popup menu is displayed should list all the + -- matches and remove the popup menu + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :sign define jump list place und| + efine unplace^ | + ]]) + + -- Pressing after that should move the cursor + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :sign define jump list place und| + efine unplac^e | + ]]) + feed('') + + -- Pressing when the popup menu is displayed should remove the popup + -- menu + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :sign define | + define | + :sign define^ | + ]]) + + -- Pressing should open the popup menu with the last entry selected + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{s: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign undefine^ | + ]]) + + -- Pressing should close the popup menu and cancel the cmd line + feed(':sign ') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + + -- Typing a character when the popup is open, should close the popup + feed(':sign x') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign definex^ | + ]]) + + -- When the popup is open, entering the cmdline window should close the popup + feed('sign ') + screen:expect([[ + | + {3:[No Name] }| + {1::}sign define | + {1::}sign define^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4:[Command Line] }| + :sign define | + ]]) + feed(':q') + + -- After the last popup menu item, should show the original string + feed(':sign u') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign u^ | + ]]) + + -- Use the popup menu for the command name + feed('bu') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {s: bufdo }{1: }| + {n: buffer }{1: }| + {n: buffers }{1: }| + {n: bunload }{1: }| + :bufdo^ | + ]]) + + -- Pressing should remove the popup menu and erase the last character + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign defin^ | + ]]) + + -- Pressing should remove the popup menu and erase the previous word + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]]) + + -- Pressing should remove the popup menu and erase the entire line + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :^ | + ]]) + + -- Using to cancel the popup menu and then pressing should recall + -- the cmdline from history + feed('sign xyz:sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign xyz^ | + ]]) + + feed('') + + -- Check "list" still works + command('set wildmode=longest,list') + feed(':cn') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :cn | + cnewer cnoreabbrev | + cnext cnoremap | + cnfile cnoremenu | + :cn^ | + ]]) + feed('s') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + :cn | + cnewer cnoreabbrev | + cnext cnoremap | + cnfile cnoremenu | + :cns^ | + ]]) + + feed('') + command('set wildmode=full') + + -- Tests a directory name contained full-width characters. + feed(':e あいう/') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: 123 }{1: }| + {1:~ }{n: abc }{1: }| + {1:~ }{n: xyz }{1: }| + :e あいう/123^ | + ]]) + feed('') + + -- Pressing should scroll the menu downward + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{s: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign undefine^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{s: unplace }{1: }| + :sign unplace^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign ^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{s: unplace }{1: }| + :sign unplace^ | + ]]) + + -- Pressing should scroll the menu upward + feed('sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign ^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{s: unplace }{1: }| + :sign unplace^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{s: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign jump^ | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + + feed('') + + -- check positioning with multibyte char in pattern + command("e långfile1") + command("sp långfile2") + feed(':b lå') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }{s: långfile1 }{1: }| + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + + -- check doesn't crash on screen resize + screen:try_resize(20,6) + screen:expect([[ + | + {1:~ }| + {4:långfile2 }| + {s: långfile1 } | + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + + screen:try_resize(50,15) + screen:expect([[ + | + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: långfile1 }{1: }| + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + + -- position is calculated correctly with "longest" + feed('') + command('set wildmode=longest:full,full') + feed(':b lå') + screen:expect([[ + | + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{n: långfile1 }{1: }| + {3:lå}{n: långfile2 }{3: }| + :b långfile^ | + ]]) + + feed('') + command("close") + command('set wildmode=full') + + -- special case: when patterns ends with "/", show menu items aligned + -- after the "/" + feed(':e compdir/') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: file1 }{1: }| + {1:~ }{n: file2 }{1: }| + :e compdir/file1^ | + ]]) + end) + + it('wildoptions=pum with scrolled messages', function() + screen:try_resize(40,10) + command('set wildmenu') + command('set wildoptions=pum') + + feed(':echoerr "fail"|echoerr "error"') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + {6:fail} | + {6:error} | + {5:Press ENTER or type command to continue}^ | + ]]} + + feed(':sign ') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {4: }{n: place }{4: }| + {6:fail} {n: undefine } | + {6:error}{n: unplace } | + :sign define^ | + ]]} + + feed('d') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4: }| + {6:fail} | + {6:error} | + :sign defined^ | + ]]} + end) + + it('wildoptions=pum and wildmode=longest,full #11622', function() + screen:try_resize(30,8) + command('set wildmenu') + command('set wildoptions=pum') + command('set wildmode=longest,full') + + -- With 'wildmode' set to 'longest,full', completing a match should display + -- the longest match, the wildmenu should not be displayed. + feed(':sign u') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign un^ | + ]]} + eq(0, funcs.wildmenumode()) + + -- pressing should display the wildmenu + feed('') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign undefine^ | + ]]} + eq(1, funcs.wildmenumode()) + + -- pressing second time should select the next entry in the menu + feed('') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{n: undefine }{1: }| + {1:~ }{s: unplace }{1: }| + :sign unplace^ | + ]]} + end) + + it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function() + screen:try_resize(32, 10) + meths.buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) + command('set wildoptions+=pum') + feed('$') + feed(':sign ') + screen:expect([[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaa {s: define } | + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + end) + + -- oldtest: Test_wildmenu_pum_clear_entries() + it('wildoptions=pum when using Ctrl-E as wildchar vim-patch:9.0.1030', function() + screen:try_resize(30, 10) + exec([[ + set wildoptions=pum + set wildchar= + ]]) + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + assert_alive() + end) + end - -- Select the Paste entry, executes the changed menu item. - feed('jj') - screen:expect([[ - one two three four five | - and one two {7:^X}three four five | - one more two three four five | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - pasted | - ]]) - end) + it("'pumheight'", function() + screen:try_resize(32,8) + feed('isome long prefix before the ') + command("set completeopt+=noinsert,noselect") + command("set linebreak") + command("set pumheight=2") + funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + some long prefix before the ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + {n: word }{c: }| + {n: choice}{s: }| + ]], float_pos={ + [4] = {{id = -1}, "NW", 2, 1, 24, false, 100}; + }} + else + screen:expect([[ + some long prefix before the ^ | + {1:~ }{n: word }{c: }| + {1:~ }{n: choice}{s: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end + end) - describe('"kind" and "menu"', function() - before_each(function() - screen:try_resize(30, 8) - exec([[ - func CompleteFunc( findstart, base ) - if a:findstart - return 0 - endif - return { - \ 'words': [ - \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', }, - \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, - \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', }, - \]} - endfunc - set completeopt=menu - set completefunc=CompleteFunc - ]]) + it("'pumwidth'", function() + screen:try_resize(32,8) + feed('isome long prefix before the ') + command("set completeopt+=noinsert,noselect") + command("set linebreak") + command("set pumwidth=8") + funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + some long prefix before the ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + {n: word }| + {n: choice}| + {n: text }| + {n: thing }| + ]], float_pos={ + [4] = {{id = -1}, "NW", 2, 1, 25, false, 100}; + }} + else + screen:expect([[ + some long prefix before the ^ | + {1:~ }{n: word }| + {1:~ }{n: choice}| + {1:~ }{n: text }| + {1:~ }{n: thing }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end end) - -- oldtest: Test_pum_highlights_default() - it('default highlight groups', function() - feed('iaw') - screen:expect([[ - aword1^ | - {s:aword1 W extra text 1 }{1: }| - {n:aword2 W extra text 2 }{1: }| - {n:aword3 W extra text 3 }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- }{5:match 1 of 3} | - ]]) + it('does not crash when displayed in the last column with rightleft #12032', function() + local col = 30 + local items = {'word', 'choice', 'text', 'thing'} + local max_len = 0 + for _, v in ipairs(items) do + max_len = max_len < #v and #v or max_len + end + screen:try_resize(col, 8) + command('set rightleft') + command('call setline(1, repeat(" ", &columns - '..max_len..'))') + feed('$i') + funcs.complete(col - max_len, items) + feed('') + assert_alive() end) - -- oldtest: Test_pum_highlights_custom() - it('custom highlight groups', function() - exec([[ - hi PmenuKind guifg=Red guibg=Magenta - hi PmenuKindSel guifg=Red guibg=Grey - hi PmenuExtra guifg=White guibg=Magenta - hi PmenuExtraSel guifg=Black guibg=Grey - ]]) - local attrs = screen:get_default_attr_ids() - attrs.kn = {foreground = Screen.colors.Red, background = Screen.colors.Magenta} - attrs.ks = {foreground = Screen.colors.Red, background = Screen.colors.Grey} - attrs.xn = {foreground = Screen.colors.White, background = Screen.colors.Magenta} - attrs.xs = {foreground = Screen.colors.Black, background = Screen.colors.Grey} - feed('iaw') - screen:expect([[ - aword1^ | - {s:aword1 }{ks:W }{xs:extra text 1 }{1: }| - {n:aword2 }{kn:W }{xn:extra text 2 }{1: }| - {n:aword3 }{kn:W }{xn:extra text 3 }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {2:-- }{5:match 1 of 3} | - ]], attrs) + it('truncates double-width character correctly without scrollbar', function() + screen:try_resize(32, 8) + command('set completeopt+=menuone,noselect') + feed('i' .. string.rep(' ', 13)) + funcs.complete(14, {'哦哦哦哦哦哦哦哦哦哦'}) + if multigrid then + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + {n: 哦哦哦哦哦哦哦哦哦>}| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 12, false, 100}}}) + else + screen:expect([[ + ^ | + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end end) - end) -end) -describe('builtin popupmenu with ui/ext_multigrid', function() - local screen - before_each(function() - clear() - screen = Screen.new(32, 20) - screen:attach({ext_multigrid=true}) - screen:set_default_attr_ids({ - -- popup selected item / scrollbar track - ['s'] = {background = Screen.colors.WebGray}, - -- popup non-selected item - ['n'] = {background = Screen.colors.LightMagenta}, - -- popup scrollbar knob - ['c'] = {background = Screen.colors.Grey0}, - [1] = {bold = true, foreground = Screen.colors.Blue}, - [2] = {bold = true}, - [3] = {reverse = true}, - [4] = {bold = true, reverse = true}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen}, - [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - }) - end) + it('truncates double-width character correctly with scrollbar', function() + screen:try_resize(32,8) + command('set completeopt+=noselect') + command('set pumheight=4') + feed('i' .. string.rep(' ', 12)) + local items = {} + for _ = 1, 8 do + table.insert(items, {word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1}) + end + funcs.complete(13, items) + if multigrid then + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + {n: 哦哦哦哦哦哦哦哦哦>}{c: }| + {n: 哦哦哦哦哦哦哦哦哦>}{c: }| + {n: 哦哦哦哦哦哦哦哦哦>}{s: }| + {n: 哦哦哦哦哦哦哦哦哦>}{s: }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 11, false, 100}}}) + else + screen:expect([[ + ^ | + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end + end) - it('truncates double-width character correctly when there is no scrollbar', function() - screen:try_resize(32,8) - command('set completeopt+=menuone,noselect') - feed('i' .. string.rep(' ', 13)) - funcs.complete(14, {'哦哦哦哦哦哦哦哦哦哦'}) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - {2:-- INSERT --} | - ## grid 4 - {n: 哦哦哦哦哦哦哦哦哦>}| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 12, false, 100}}}) - end) + it('supports mousemodel=popup', function() + screen:try_resize(32, 6) + exec([[ + call setline(1, 'popup menu test') + set mouse=a mousemodel=popup + + aunmenu PopUp + menu PopUp.foo :let g:menustr = 'foo' + menu PopUp.bar :let g:menustr = 'bar' + menu PopUp.baz :let g:menustr = 'baz' + ]]) - it('truncates double-width character correctly when there is scrollbar', function() - screen:try_resize(32,8) - command('set completeopt+=noselect') - command('set pumheight=4') - feed('i' .. string.rep(' ', 12)) - local items = {} - for _ = 1, 8 do - table.insert(items, {word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1}) + if multigrid then + meths.input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + feed('<4,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + | + ]]) + end + feed('') + if multigrid then + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {s: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + screen:expect([[ + ^popup menu test | + {1:~ }{s: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + | + ]]) + end + feed('') + if multigrid then + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + {n: foo }| + {s: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{s: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + | + ]]) + end + feed('') + if multigrid then + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ]]}) + else + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :let g:menustr = 'bar' | + ]]) + end + eq('bar', meths.get_var('menustr')) + + if multigrid then + meths.input_mouse('right', 'press', '', 2, 2, 20) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 3, 19, false, 250}}}) + else + feed('<20,2>') + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + :let g:menustr = 'b{n: baz } | + ]]) + end + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 2) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'baz' | + ]]}) + else + feed('<22,5>') + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :let g:menustr = 'baz' | + ]]) + end + eq('baz', meths.get_var('menustr')) + + if multigrid then + meths.input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'baz' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + feed('<4,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + :let g:menustr = 'baz' | + ]]) + end + if multigrid then + meths.input_mouse('right', 'drag', '', 2, 3, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'baz' | + ## grid 4 + {n: foo }| + {n: bar }| + {s: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + feed('<6,3>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{s: baz }{1: }| + {1:~ }| + :let g:menustr = 'baz' | + ]]) + end + if multigrid then + meths.input_mouse('right', 'release', '', 2, 1, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ]]}) + else + feed('<6,1>') + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq('foo', meths.get_var('menustr')) + + eq(false, screen.options.mousemoveevent) + if multigrid then + meths.input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + feed('<4,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| + {1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq(true, screen.options.mousemoveevent) + if multigrid then + meths.input_mouse('move', '', '', 2, 3, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo }| + {n: bar }| + {s: baz }| + ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + else + feed('<6,3>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{s: baz }{1: }| + {1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq(true, screen.options.mousemoveevent) + if multigrid then + meths.input_mouse('left', 'press', '', 2, 2, 6) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [2:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ]]}) + else + feed('<6,2>') + screen:expect([[ + ^popup menu test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :let g:menustr = 'bar' | + ]]) + end + eq(false, screen.options.mousemoveevent) + eq('bar', meths.get_var('menustr')) + + command('set laststatus=0 | botright split') + if multigrid then + meths.input_mouse('right', 'press', '', 5, 1, 20) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:--------------------------------]| + [5:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ## grid 5 + ^popup menu test | + {1:~ }| + ]], float_pos={[4] = {{id = -1}, "SW", 5, 1, 19, false, 250}}}) + else + feed('<20,4>') + screen:expect([[ + popup menu test | + {1:~ }{n: foo }{1: }| + {3:[No Name] [+] }{n: bar }{3: }| + ^popup menu test {n: baz } | + {1:~ }| + :let g:menustr = 'bar' | + ]]) + end + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 2) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:--------------------------------]| + [5:--------------------------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'baz' | + ## grid 5 + ^popup menu test | + {1:~ }| + ]]}) + else + feed('<22,3>') + screen:expect([[ + popup menu test | + {1:~ }| + {3:[No Name] [+] }| + ^popup menu test | + {1:~ }| + :let g:menustr = 'baz' | + ]]) + end + eq('baz', meths.get_var('menustr')) + + command('set winwidth=1 | rightbelow vsplit') + if multigrid then + meths.input_mouse('right', 'press', '', 6, 1, 14) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'baz' | + ## grid 4 + {n: foo}| + {n: bar}| + {n: baz}| + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + ^popup menu test | + {1:~ }| + ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}}) + else + feed('<30,4>') + screen:expect([[ + popup menu test | + {1:~ }{n: foo}| + {3:[No Name] [+] }{n: bar}| + popup menu test│^popup menu t{n: baz}| + {1:~ }│{1:~ }| + :let g:menustr = 'baz' | + ]]) + end + if multigrid then + meths.input_mouse('left', 'press', '', 4, 0, 2) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + ^popup menu test | + {1:~ }| + ]]}) + else + feed('<31,1>') + screen:expect([[ + popup menu test | + {1:~ }| + {3:[No Name] [+] }| + popup menu test│^popup menu test | + {1:~ }│{1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq('foo', meths.get_var('menustr')) + end) + + if not multigrid then + -- oldtest: Test_popup_command_dump() + it(':popup command', function() + exec([[ + func ChangeMenu() + aunmenu PopUp.&Paste + nnoremenu 1.40 PopUp.&Paste :echomsg "pasted" + echomsg 'changed' + return "\" + endfunc + + let lines =<< trim END + one two three four five + and one two Xthree four five + one more two three four five + END + call setline(1, lines) + + aunmenu * + source $VIMRUNTIME/menu.vim + ]]) + feed('/X:popup PopUp') + screen:expect([[ + one two three four five | + and one two {7:^X}three four five | + one more tw{n: Undo } | + {1:~ }{n: }{1: }| + {1:~ }{n: Paste }{1: }| + {1:~ }{n: }{1: }| + {1:~ }{n: Select Word }{1: }| + {1:~ }{n: Select Sentence }{1: }| + {1:~ }{n: Select Paragraph }{1: }| + {1:~ }{n: Select Line }{1: }| + {1:~ }{n: Select Block }{1: }| + {1:~ }{n: Select All }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :popup PopUp | + ]]) + + -- go to the Paste entry in the menu + feed('jj') + screen:expect([[ + one two three four five | + and one two {7:^X}three four five | + one more tw{n: Undo } | + {1:~ }{n: }{1: }| + {1:~ }{s: Paste }{1: }| + {1:~ }{n: }{1: }| + {1:~ }{n: Select Word }{1: }| + {1:~ }{n: Select Sentence }{1: }| + {1:~ }{n: Select Paragraph }{1: }| + {1:~ }{n: Select Line }{1: }| + {1:~ }{n: Select Block }{1: }| + {1:~ }{n: Select All }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :popup PopUp | + ]]) + + -- Select a word + feed('j') + screen:expect([[ + one two three four five | + and one two {7:^X}three four five | + one more tw{n: Undo } | + {1:~ }{n: }{1: }| + {1:~ }{n: Paste }{1: }| + {1:~ }{n: }{1: }| + {1:~ }{s: Select Word }{1: }| + {1:~ }{n: Select Sentence }{1: }| + {1:~ }{n: Select Paragraph }{1: }| + {1:~ }{n: Select Line }{1: }| + {1:~ }{n: Select Block }{1: }| + {1:~ }{n: Select All }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :popup PopUp | + ]]) + + feed('') + + -- Set an mapping to change a menu entry while it's displayed. + -- The text should not change but the command does. + -- Also verify that "changed" shows up, which means the mapping triggered. + command('nnoremap ChangeMenu()') + feed('/X:popup PopUp') + screen:expect([[ + one two three four five | + and one two {7:^X}three four five | + one more tw{n: Undo } | + {1:~ }{n: }{1: }| + {1:~ }{n: Paste }{1: }| + {1:~ }{n: }{1: }| + {1:~ }{n: Select Word }{1: }| + {1:~ }{n: Select Sentence }{1: }| + {1:~ }{n: Select Paragraph }{1: }| + {1:~ }{n: Select Line }{1: }| + {1:~ }{n: Select Block }{1: }| + {1:~ }{n: Select All }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + changed | + ]]) + + -- Select the Paste entry, executes the changed menu item. + feed('jj') + screen:expect([[ + one two three four five | + and one two {7:^X}three four five | + one more two three four five | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + pasted | + ]]) + end) + + describe('"kind" and "menu"', function() + before_each(function() + screen:try_resize(30, 8) + exec([[ + func CompleteFunc( findstart, base ) + if a:findstart + return 0 + endif + return { + \ 'words': [ + \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', }, + \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, + \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', }, + \]} + endfunc + set completeopt=menu + set completefunc=CompleteFunc + ]]) + end) + + -- oldtest: Test_pum_highlights_default() + it('default highlight groups', function() + feed('iaw') + screen:expect([[ + aword1^ | + {s:aword1 W extra text 1 }{1: }| + {n:aword2 W extra text 2 }{1: }| + {n:aword3 W extra text 3 }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- }{5:match 1 of 3} | + ]]) + end) + + -- oldtest: Test_pum_highlights_custom() + it('custom highlight groups', function() + exec([[ + hi PmenuKind guifg=Red guibg=Magenta + hi PmenuKindSel guifg=Red guibg=Grey + hi PmenuExtra guifg=White guibg=Magenta + hi PmenuExtraSel guifg=Black guibg=Grey + ]]) + local attrs = screen:get_default_attr_ids() + attrs.kn = {foreground = Screen.colors.Red, background = Screen.colors.Magenta} + attrs.ks = {foreground = Screen.colors.Red, background = Screen.colors.Grey} + attrs.xn = {foreground = Screen.colors.White, background = Screen.colors.Magenta} + attrs.xs = {foreground = Screen.colors.Black, background = Screen.colors.Grey} + feed('iaw') + screen:expect([[ + aword1^ | + {s:aword1 }{ks:W }{xs:extra text 1 }{1: }| + {n:aword2 }{kn:W }{xn:extra text 2 }{1: }| + {n:aword3 }{kn:W }{xn:extra text 3 }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- }{5:match 1 of 3} | + ]], attrs) + end) + end) end - funcs.complete(13, items) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - {2:-- INSERT --} | - ## grid 4 - {n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {n: 哦哦哦哦哦哦哦哦哦>}{s: }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 11, false, 100}}}) - end) + end - it('supports mousemodel=popup', function() - screen:try_resize(32, 6) - exec([[ - call setline(1, 'popup menu test') - set mouse=a mousemodel=popup + describe('with ext_multigrid', function() + with_ext_multigrid(true) + end) - aunmenu PopUp - menu PopUp.foo :let g:menustr = 'foo' - menu PopUp.bar :let g:menustr = 'bar' - menu PopUp.baz :let g:menustr = 'baz' - ]]) - meths.input_mouse('right', 'press', '', 2, 1, 20) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - | - ## grid 4 - {n: foo }| - {n: bar }| - {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 2, 19, false, 250}}}) - meths.input_mouse('left', 'press', '', 4, 2, 2) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'baz' | - ]]}) - eq('baz', meths.get_var('menustr')) - meths.input_mouse('right', 'press', '', 2, 0, 4) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'baz' | - ## grid 4 - {n: foo }| - {n: bar }| - {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) - meths.input_mouse('right', 'drag', '', 2, 3, 6) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'baz' | - ## grid 4 - {n: foo }| - {n: bar }| - {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) - meths.input_mouse('right', 'release', '', 2, 1, 6) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'foo' | - ]]}) - eq('foo', meths.get_var('menustr')) - eq(false, screen.options.mousemoveevent) - meths.input_mouse('right', 'press', '', 2, 0, 4) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'foo' | - ## grid 4 - {n: foo }| - {n: bar }| - {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) - eq(true, screen.options.mousemoveevent) - meths.input_mouse('move', '', '', 2, 3, 6) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'foo' | - ## grid 4 - {n: foo }| - {n: bar }| - {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) - eq(true, screen.options.mousemoveevent) - meths.input_mouse('left', 'press', '', 2, 2, 6) - screen:expect({grid=[[ - ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [3:--------------------------------]| - ## grid 2 - ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - :let g:menustr = 'bar' | - ]]}) - eq(false, screen.options.mousemoveevent) - eq('bar', meths.get_var('menustr')) + describe('without ext_multigrid', function() + with_ext_multigrid(false) end) end) -- cgit From eb4676c67f5dd54bcda473783315901a3444b40b Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 27 Apr 2023 17:30:22 +0100 Subject: fix: disallow removing extmarks in on_lines callbacks (#23219) fix(extmarks): disallow removing extmarks in on_lines callbacks decor_redraw_start (which runs before decor_providers_invoke_lines) gets references for the extmarks on a specific line. If these extmarks are deleted in on_lines callbacks then this results in a heap-use-after-free error. Fixes #22801 --- test/functional/ui/decorations_spec.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 80e5b6230e..5792c9703d 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -122,7 +122,7 @@ describe('decorations providers', function() ]]} check_trace { { "start", 5 }; - { "buf", 1 }; + { "buf", 1, 5 }; { "win", 1000, 1, 0, 8 }; { "line", 1000, 1, 6 }; { "end", 5 }; @@ -565,6 +565,23 @@ describe('decorations providers', function() | ]]) end) + + it('does not allow removing extmarks during on_line callbacks', function() + exec_lua([[ + eok = true + ]]) + setup_provider([[ + local function on_do(kind, winid, bufnr, topline, botline_guess) + if kind == 'line' then + api.nvim_buf_set_extmark(bufnr, ns1, 1, -1, { sign_text = 'X' }) + eok = pcall(api.nvim_buf_clear_namespace, bufnr, ns1, 0, -1) + end + end + ]]) + exec_lua([[ + assert(eok == false) + ]]) + end) end) describe('extmark decorations', function() -- cgit From fbaa2787736173e417a93b958a9ca61e888e567d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 27 Apr 2023 23:40:39 +0800 Subject: fix(pum): make :popup position correctly with float border --- test/functional/ui/float_spec.lua | 123 +++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index e2fe0a2df5..28c16642f1 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -9,6 +9,7 @@ local eval = helpers.eval local eq = helpers.eq local neq = helpers.neq local expect = helpers.expect +local exec = helpers.exec local exec_lua = helpers.exec_lua local insert = helpers.insert local meths = helpers.meths @@ -2123,7 +2124,7 @@ describe('float window', function() {5:║}{1:^ }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true } + [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; @@ -2181,8 +2182,8 @@ describe('float window', function() {1: abb }| {13: acc }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 }, - [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 } + [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 }; + [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; @@ -2201,6 +2202,122 @@ describe('float window', function() {3:-- }{8:match 1 of 4} | ]]} end + + feed '' + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {5:╔═════════╗}| + {5:║}{1:aaa aab }{5:║}| + {5:║}{1:abb acc }{5:║}| + {5:║}{1:ac^c }{5:║}| + {5:╚═════════╝}| + ]], float_pos={ + [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {5:╔═════════╗} | + {0:~ }{5:║}{1:aaa aab }{5:║}{0: }| + {0:~ }{5:║}{1:abb acc }{5:║}{0: }| + {0:~ }{5:║}{1:ac^c }{5:║}{0: }| + {0:~ }{5:╚═════════╝}{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end + + exec([[ + nnoremenu Test.foo : + nnoremenu Test.bar : + nnoremenu Test.baz : + ]]) + feed ':popup Test' + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + :popup Test | + ## grid 5 + {5:╔═════════╗}| + {5:║}{1:aaa aab }{5:║}| + {5:║}{1:abb acc }{5:║}| + {5:║}{1:ac^c }{5:║}| + {5:╚═════════╝}| + ## grid 6 + {1: foo }| + {1: bar }| + {1: baz }| + ]], float_pos={ + [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; + [6] = { { id = -1 }, "NW", 5, 4, 2, false, 250 }; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {5:╔═════════╗} | + {0:~ }{5:║}{1:aaa aab }{5:║}{0: }| + {0:~ }{5:║}{1:abb acc }{5:║}{0: }| + {0:~ }{5:║}{1:ac^c }{5:║}{0: }| + {0:~ }{5:╚═}{1: foo }{5:═══╝}{0: }| + {0:~ }{1: bar }{0: }| + {0:~ }{1: baz }{0: }| + {0:~ }| + {0:~ }| + :popup Test | + ]]} + end end) it('show ruler of current floating window', function() -- cgit From aca226d728418e791b897a908631d52aa24157fe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Apr 2023 05:50:08 +0800 Subject: vim-patch:9.0.1493: popup menu position wrong in window with toolbar Problem: Popup menu position wrong in window with toolbar. Solution: Take the window toolbar into account when positioning the popup menu. (closes vim/vim#12308) https://github.com/vim/vim/commit/4e1ca0d9a6c6d66987da67155e97f83f286ffbcc Fixed in the previous commit. Test only. --- test/functional/ui/popupmenu_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index c5e0c10a81..0b71e12b6f 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -4508,6 +4508,34 @@ describe('builtin popupmenu', function() {1:~ }| pasted | ]]) + + -- Add a window toolbar to the window and check the :popup menu position. + command('setlocal winbar=TEST') + feed('/X:popup PopUp') + screen:expect([[ + {2:TEST }| + one two three four five | + and one two {7:^X}three four five | + one more tw{n: Undo } | + {1:~ }{n: }{1: }| + {1:~ }{n: Paste }{1: }| + {1:~ }{n: }{1: }| + {1:~ }{n: Select Word }{1: }| + {1:~ }{n: Select Sentence }{1: }| + {1:~ }{n: Select Paragraph }{1: }| + {1:~ }{n: Select Line }{1: }| + {1:~ }{n: Select Block }{1: }| + {1:~ }{n: Select All }{1: }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :popup PopUp | + ]]) + + feed('') end) describe('"kind" and "menu"', function() -- cgit From a803bff89c89cc63e549a3c791fa07d91d1106c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 1 May 2023 12:30:55 +0800 Subject: fix(spell): extmark with spell=false should disable spell (#23400) --- test/functional/ui/decorations_spec.lua | 117 ++++++++++++++++----------- test/functional/ui/spell_spec.lua | 139 ++++++++++++++++++++++++++------ 2 files changed, 187 insertions(+), 69 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 5792c9703d..f531878bc6 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -8,6 +8,7 @@ local exec_lua = helpers.exec_lua local exec = helpers.exec local expect_events = helpers.expect_events local meths = helpers.meths +local curbufmeths = helpers.curbufmeths local command = helpers.command describe('decorations providers', function() @@ -31,8 +32,9 @@ describe('decorations providers', function() [12] = {foreground = tonumber('0x990000')}; [13] = {background = Screen.colors.LightBlue}; [14] = {background = Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}; - [15] = {special = Screen.colors.Blue1, undercurl = true}, + [15] = {special = Screen.colors.Blue, undercurl = true}, [16] = {special = Screen.colors.Red, undercurl = true}, + [17] = {foreground = Screen.colors.Red}, } end) @@ -201,14 +203,14 @@ describe('decorations providers', function() feed "gg0" screen:expect{grid=[[ - ^I am well written text. | - {15:i} am not capitalized. | - I am a {16:speling} {16:mistakke}. | - | - {1:~ }| - {1:~ }| - {1:~ }| - | + ^I am well written text. | + {15:i} am not capitalized. | + I am a {16:speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | ]]} feed "]s" @@ -216,14 +218,14 @@ describe('decorations providers', function() { "spell", 1000, 1, 1, 0, 1, -1 }; } screen:expect{grid=[[ - I am well written text. | - {15:^i} am not capitalized. | - I am a {16:speling} {16:mistakke}. | - | - {1:~ }| - {1:~ }| - {1:~ }| - | + I am well written text. | + {15:^i} am not capitalized. | + I am a {16:speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | ]]} feed "]s" @@ -231,43 +233,68 @@ describe('decorations providers', function() { "spell", 1000, 1, 2, 7, 2, -1 }; } screen:expect{grid=[[ - I am well written text. | - {15:i} am not capitalized. | - I am a {16:^speling} {16:mistakke}. | - | - {1:~ }| - {1:~ }| - {1:~ }| - | + I am well written text. | + {15:i} am not capitalized. | + I am a {16:^speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | ]]} - -- spell=false with lower priority doesn't disable spell + -- spell=false with higher priority does disable spell local ns = meths.create_namespace "spell" - local id = helpers.curbufmeths.set_extmark(ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false }) + local id = curbufmeths.set_extmark(ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false }) screen:expect{grid=[[ - I am well written text. | - i am not capitalized. | - I am a ^speling mistakke. | - | - {1:~ }| - {1:~ }| - {1:~ }| - | + I am well written text. | + i am not capitalized. | + I am a ^speling mistakke. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | ]]} - -- spell=false with higher priority does disable spell - helpers.curbufmeths.set_extmark(ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false }) + feed "]s" + screen:expect{grid=[[ + I am well written text. | + i am not capitalized. | + I am a ^speling mistakke. | + | + {1:~ }| + {1:~ }| + {1:~ }| + {17:search hit BOTTOM, continuing at TOP} | + ]]} + command('echo ""') + + -- spell=false with lower priority doesn't disable spell + curbufmeths.set_extmark(ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false }) + + screen:expect{grid=[[ + I am well written text. | + {15:i} am not capitalized. | + I am a {16:^speling} {16:mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed "]s" screen:expect{grid=[[ - I am well written text. | - {15:i} am not capitalized. | - I am a {16:^speling} {16:mistakke}. | - | - {1:~ }| - {1:~ }| - {1:~ }| - | + I am well written text. | + {15:i} am not capitalized. | + I am a {16:speling} {16:^mistakke}. | + | + {1:~ }| + {1:~ }| + {1:~ }| + | ]]} end) diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 361f83d1ce..15819aef40 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -6,6 +6,8 @@ local clear = helpers.clear local feed = helpers.feed local insert = helpers.insert local command = helpers.command +local meths = helpers.meths +local curbufmeths = helpers.curbufmeths local is_os = helpers.is_os describe("'spell'", function() @@ -18,11 +20,13 @@ describe("'spell'", function() screen:set_default_attr_ids( { [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {special = Screen.colors.Red, undercurl = true}, - [2] = {special = Screen.colors.Blue1, undercurl = true}, + [2] = {special = Screen.colors.Blue, undercurl = true}, [3] = {foreground = tonumber('0x6a0dad')}, [4] = {foreground = Screen.colors.Magenta}, [5] = {bold = true, foreground = Screen.colors.SeaGreen}, [6] = {foreground = Screen.colors.Red}, + [7] = {foreground = Screen.colors.Blue}, + [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, }) end) @@ -74,19 +78,57 @@ describe("'spell'", function() ]]) end) - it('"noplainbuffer" and syntax #20385', function() + it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() command('set filetype=c') command('syntax on') command('set spell') insert([[ #include - bool func(void);]]) + bool func(void); + // I am a speling mistakke]]) + feed('ge') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | + {5:bool} func({5:void}); | + {7:// I am a }{8:spelin^g}{7: }{8:mistakke} | {0:~ }| {0:~ }| {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:speling}{7: }{8:^mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {6:search hit BOTTOM, continuing at TOP} | + ]]) + command('echo ""') + local ns = meths.create_namespace("spell") + -- extmark with spell=true enables spell + local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) + screen:expect([[ + {3:#include }{4:} | + {5:bool} {1:func}({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| {0:~ }| {0:~ }| | @@ -94,73 +136,122 @@ describe("'spell'", function() feed('[s') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | + {5:bool} {1:^func}({5:void}); | + {7:// I am a }{8:speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| {0:~ }| + {0:~ }| + | + ]]) + curbufmeths.del_extmark(ns, id) + -- extmark with spell=false disables spell + id = curbufmeths.set_extmark(ns, 2, 18, { end_row = 2, end_col = 26, spell = false }) + screen:expect([[ + {3:#include }{4:} | + {5:bool} ^func({5:void}); | + {7:// I am a }{8:speling}{7: mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed('[s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| {6:search hit TOP, continuing at BOTTOM} | ]]) + command('echo ""') + curbufmeths.del_extmark(ns, id) + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + feed(']s') + screen:expect([[ + {3:#include }{4:} | + {5:bool} func({5:void}); | + {7:// I am a }{8:speling}{7: }{8:^mistakke} | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) -- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled command('set spelloptions+=noplainbuffer') screen:expect_unchanged() - feed(']s') + feed('[s') screen:expect([[ {3:#include }{4:} | - {5:bool} func({5:void})^; | - {0:~ }| + {5:bool} func({5:void}); | + {7:// I am a }{8:^speling}{7: }{8:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) -- no spellchecking with "noplainbuffer" and syntax disabled command('syntax off') screen:expect([[ #include | - bool func(void)^; | + bool func(void); | + // I am a ^speling mistakke | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) - feed('[s') + feed(']s') screen:expect([[ #include | - bool func(void)^; | + bool func(void); | + // I am a ^speling mistakke | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {0:~ }| - {6:search hit TOP, continuing at BOTTOM} | + {6:search hit BOTTOM, continuing at TOP} | ]]) + command('echo ""') -- everything is spellchecked without "noplainbuffer" with syntax disabled command('set spelloptions&') screen:expect([[ #include <{1:stdbool}.h> | - {1:bool} {1:func}(void)^; | - {0:~ }| + {1:bool} {1:func}(void); | + // I am a {1:^speling} {1:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit TOP, continuing at BOTTOM} | + | ]]) - feed(']s') + feed('[s') screen:expect([[ - #include <{1:^stdbool}.h> | - {1:bool} {1:func}(void); | - {0:~ }| + #include <{1:stdbool}.h> | + {1:bool} {1:^func}(void); | + // I am a {1:speling} {1:mistakke} | {0:~ }| {0:~ }| {0:~ }| {0:~ }| - {6:search hit BOTTOM, continuing at TOP} | + | ]]) end) + end) -- cgit From 03e8b5fc91f9b4b0535f79a8d725e1551aec6795 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 10:00:34 +0800 Subject: fix(float): make bufpos work properly with resized parent grid --- test/functional/ui/multigrid_spec.lua | 103 ++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 2525314b8e..7b2bf30642 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -37,6 +37,8 @@ describe('ext_multigrid', function() [18] = {bold = true, foreground = Screen.colors.Magenta}, [19] = {foreground = Screen.colors.Brown}, [20] = {background = Screen.colors.LightGrey}, + [21] = {background = Screen.colors.LightMagenta}, + [22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue}, }) end) @@ -1060,6 +1062,107 @@ describe('ext_multigrid', function() | ]]} end) + + it('anchored float window "bufpos"', function() + insert(('c'):rep(1111)) + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccc^c | + {1:~ }| + ## grid 3 + | + ]]} + local float_buf = meths.create_buf(false, false) + meths.open_win(float_buf, false, { + relative = 'win', + win = curwin(), + bufpos = {0, 1018}, + anchor = 'SE', + width = 5, + height = 5, + }) + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccc^c | + {1:~ }| + ## grid 3 + | + ## grid 4 + {21: }| + {22:~ }| + {22:~ }| + {22:~ }| + {22:~ }| + ]], float_pos={ + [4] = {{id = 1001}, "SE", 2, 16, 58, true, 50}; + }} + end) end) it('multiline messages scroll over windows', function() -- cgit From 37b73cf14b118ca1583da2a3e89611222bd3e020 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 10:36:41 +0800 Subject: fix(drawline): make cursorlineopt=screenline work with resized grid --- test/functional/ui/multigrid_spec.lua | 47 +++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 7b2bf30642..9663997a71 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -39,6 +39,7 @@ describe('ext_multigrid', function() [20] = {background = Screen.colors.LightGrey}, [21] = {background = Screen.colors.LightMagenta}, [22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue}, + [23] = {background = Screen.colors.Grey90}, }) end) @@ -930,7 +931,7 @@ describe('ext_multigrid', function() end) it('wraps with grid width', function() - insert(('b'):rep(80).."\n") + insert(('b'):rep(160).."\n") screen:expect{grid=[[ ## grid 1 [2:-----------------------------------------------------]| @@ -949,7 +950,8 @@ describe('ext_multigrid', function() [3:-----------------------------------------------------]| ## grid 2 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| - bbbbbbbbbbbbbbbbbbbb | + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ^ | {1:~ }| {1:~ }| @@ -967,6 +969,47 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| {1:~ }| + ## grid 3 + | + ]]} + feed('2gk') + command('setlocal cursorline cursorlineopt=screenline') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + {23:^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| {1:~ }| ## grid 3 | -- cgit From 088cdf69e3faf5cf6c9ef743379638127e6e7c0b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 11:09:27 +0800 Subject: fix(normal): make "g$" work properly with resized grid --- test/functional/ui/multigrid_spec.lua | 88 ++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 9663997a71..6b6d6ad1d2 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -887,7 +887,6 @@ describe('ext_multigrid', function() it('gets written till grid width', function() insert(('a'):rep(60).."\n") - screen:expect{grid=[[ ## grid 1 [2:-----------------------------------------------------]| @@ -930,6 +929,93 @@ describe('ext_multigrid', function() ]]} end) + it('"g$" works correctly with double-width characters and no wrapping', function() + command('set nowrap') + insert(('a'):rep(58) .. ('哦'):rep(3)) + feed('0') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa哦| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]} + feed('g$') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^哦| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]} + end) + it('wraps with grid width', function() insert(('b'):rep(160).."\n") screen:expect{grid=[[ -- cgit From 7c1921e9d69e008781c9fb16c11e843f7bd9099a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 15:25:41 +0800 Subject: fix(mouse): fix popup_setpos position check with ext_multigrid (#23436) --- test/functional/ui/multigrid_spec.lua | 396 +++++++++++++++++++++++++++++++++- 1 file changed, 395 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 6b6d6ad1d2..558b9e3e16 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -2235,7 +2235,7 @@ describe('ext_multigrid', function() {1:~ }| ]]} - meths.input_mouse('left', 'press', '', 1,8, 26) + meths.input_mouse('left', 'press', '', 1, 8, 26) poke_eventloop() meths.input_mouse('left', 'drag', '', 1, 6, 30) screen:expect{grid=[[ @@ -2276,6 +2276,400 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]]} + + command('aunmenu PopUp | vmenu PopUp.Copy y') + + funcs.setreg('"', '') + meths.input_mouse('left', 'press', '2', 2, 1, 6) + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {12:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] }{11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be {20:clicke}^d | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | + {1:~ }| + ## grid 5 + some text | + to be {20:clicked} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + meths.input_mouse('right', 'press', '', 2, 1, 6) + meths.input_mouse('right', 'release', '', 2, 1, 6) + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {12:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] }{11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be {20:clicke}^d | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | + {1:~ }| + ## grid 5 + some text | + to be {20:clicked} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 6 + {21: Copy }| + ]], float_pos={ + [6] = {{id = -1}, "NW", 2, 2, 5, false, 250}; + }} + feed('') + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {12:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] }{11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be ^clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmo | + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + eq('clicked', funcs.getreg('"')) + + funcs.setreg('"', '') + meths.input_mouse('left', 'press', '2', 4, 0, 64) + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do {20:eiusm}^o | + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + meths.input_mouse('right', 'press', '', 4, 0, 64) + meths.input_mouse('right', 'release', '', 4, 0, 64) + -- FIXME: popup menu position is strange + -- screen:expect{} + feed('') + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ^eiusmo | + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + eq('eiusmo', funcs.getreg('"')) + + command('wincmd J') + screen:try_resize_grid(4, 7, 10) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + ^eiusmo| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + + funcs.setreg('"', '') + meths.input_mouse('left', 'press', '2', 4, 9, 1) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + {20:eiusm}^o| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + meths.input_mouse('right', 'press', '', 4, 9, 1) + meths.input_mouse('right', 'release', '', 4, 9, 1) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + {20:eiusm}^o| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 6 + {21: Copy }| + ]], float_pos={ + [6] = {{id = -1}, "SW", 4, 9, 0, false, 250}; + }} + feed('') + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + ^eiusmo| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + eq('eiusmo', funcs.getreg('"')) end) it('supports mouse drag with mouse=a', function() -- cgit From f3b44cf23d9c240471826e4f35555ee85ded1e5b Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 27 Apr 2023 04:54:50 +0200 Subject: vim-patch:9.0.0652: 'smoothscroll' not tested with 'number' and "n" in 'cpo' Problem: 'smoothscroll' not tested with 'number' and "n" in 'cpo'. Solution: Add tests, fix uncovered problem. https://github.com/vim/vim/commit/b6aab8f44beb8c5d99393abdc2c9faab085c72aa Co-authored-by: Bram Moolenaar --- test/functional/ui/highlight_spec.lua | 2 +- test/functional/ui/popupmenu_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 89b503141b..01895003ae 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -704,7 +704,7 @@ describe("'listchars' highlight", function() feed_command('set listchars=eol:¬,precedes:< list') feed('90ia') screen:expect([[ - {0:<}aaaaaaaaaaaaaaaaaaa| + {0:<<<}aaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaa| aaaaaaaaa^a{0:¬} | diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 0b71e12b6f..6c26c8ea39 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -2396,7 +2396,7 @@ describe('builtin popupmenu', function() -- can't draw the pum, but check we don't crash screen:try_resize(12,2) screen:expect([[ - text^ | + {1:<<<}t^ | {2:-- INSERT -} | ]]) -- cgit From 0588329c8569553e3232e72889a28496a30aa54b Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 27 Apr 2023 03:15:46 +0200 Subject: vim-patch:9.0.0760: display test for 'listchars' "precedes" fails Problem: Display test for 'listchars' "precedes" fails. Solution: Correct the expected result. https://github.com/vim/vim/commit/297164cb7972beff35e375ccac4fbad8196ccbd7 Co-authored-by: Bram Moolenaar --- test/functional/ui/highlight_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 01895003ae..89b503141b 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -704,7 +704,7 @@ describe("'listchars' highlight", function() feed_command('set listchars=eol:¬,precedes:< list') feed('90ia') screen:expect([[ - {0:<<<}aaaaaaaaaaaaaaaaa| + {0:<}aaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaa| aaaaaaaaaaaaaaaaaaaa| aaaaaaaaa^a{0:¬} | -- cgit From f186224dfcf86678b6e5ee126d6b9a393f02f634 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 May 2023 23:55:14 +0800 Subject: fix(pum): fix missing rightmost column with 'rightleft' (#23445) --- test/functional/ui/popupmenu_spec.lua | 225 +++++++++++++++++++++++++++++++--- 1 file changed, 208 insertions(+), 17 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 6c26c8ea39..4c0ecd9c4e 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5,6 +5,7 @@ local clear, feed = helpers.clear, helpers.feed local source = helpers.source local insert = helpers.insert local meths = helpers.meths +local async_meths = helpers.async_meths local command = helpers.command local funcs = helpers.funcs local eq = helpers.eq @@ -1978,6 +1979,54 @@ describe('builtin popupmenu', function() {2:-- }{5:match 1 of 4} | ]]) end + + feed('\n') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]| + {3:') screen:expect([[ ^ drow tfelthgir emos| - {1: }{s: drow}{1: ~}| - {1: }{n: eciohc}{1: ~}| - {1: }{n: txet}{1: ~}| - {1: }{n: gniht}{1: ~}| + {1: }{s: drow }{1: ~}| + {1: }{n: eciohc }{1: ~}| + {1: }{n: txet }{1: ~}| + {1: }{n: gniht }{1: ~}| {1: ~}| {1: ~}| {1: ~}| @@ -2643,25 +2692,167 @@ describe('builtin popupmenu', function() {1: ~}| {1: ~}| ## grid 5 - {n: drow}| - {n: eciohc}| - {n: txet}| - {n: gniht}| + {n: drow }| + {n: eciohc }| + {n: txet }| + {n: gniht }| ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 1, -11, false, 100}; + [5] = {{id = -1}, "NW", 4, 1, -10, false, 100}; }} else screen:expect([[ tfelthgir emos│ ^ tfelthgir emos| - {1: }{n: drow}{1: ~}| - {1: }{n: eciohc}{1: ~}| - {1: }{n: txet}{1: ~}| - {1: }{n: gniht}{1: ~}| + {1: }{n: drow }{1: ~}| + {1: }{n: eciohc }{1: ~}| + {1: }{n: txet }{1: ~}| + {1: }{n: gniht }{1: ~}| {1: ~}│{1: ~}| {3:[No Name] [+] }{4:[No Name] [+] }| {2:-- INSERT --} | ]]) end + feed('') + funcs.complete(1, {'word', 'choice', 'text', 'thing'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + {3:[No Name] [+] }{4:[No Name] [+] }| + [3:----------------------------------------]| + ## grid 2 + tfelthgir emos| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + {2:-- INSERT --} | + ## grid 4 + tfelthgir emos| + ^ | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 5 + {n: drow}| + {n: eciohc}| + {n: txet}| + {n: gniht}| + ]], float_pos={ + [5] = {{id = -1}, "NW", 4, 2, 5, false, 100}; + }} + else + screen:expect([[ + tfelthgir emos│ tfelthgir emos| + │ ^ | + {1: ~}│{1: }{n: drow}| + {1: ~}│{1: }{n: eciohc}| + {1: ~}│{1: }{n: txet}| + {1: ~}│{1: }{n: gniht}| + {3:[No Name] [+] }{4:[No Name] [+] }| + {2:-- INSERT --} | + ]]) + end + feed('') + async_meths.call_function('input', {'', '', 'sign'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + {3:[No Name] [+] }{4:[No Name] [+] }| + [3:----------------------------------------]| + ## grid 2 + tfelthgir emos| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + ^ | + ## grid 4 + tfelthgir emos| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ]]} + else + screen:expect([[ + tfelthgir emos│ tfelthgir emos| + │ | + {1: ~}│{1: ~}| + {1: ~}│{1: ~}| + {1: ~}│{1: ~}| + {1: ~}│{1: ~}| + {3:[No Name] [+] }{4:[No Name] [+] }| + ^ | + ]]) + end + command('set wildoptions+=pum') + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]| + {3:[No Name] [+] }{4:[No Name] [+] }| + [3:----------------------------------------]| + ## grid 2 + tfelthgir emos| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + define^ | + ## grid 4 + tfelthgir emos| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 5 + {s:define }| + {n:jump }| + {n:list }| + {n:place }| + {n:undefine }| + {n:unplace }| + ]], float_pos={ + [5] = {{id = -1}, "SW", 1, 7, 0, false, 250}; + }} + else + screen:expect([[ + tfelthgir emos│ tfelthgir emos| + {s:define } │ | + {n:jump }{1: ~}│{1: ~}| + {n:list }{1: ~}│{1: ~}| + {n:place }{1: ~}│{1: ~}| + {n:undefine }{1: ~}│{1: ~}| + {n:unplace }{3: }{4:[No Name] [+] }| + define^ | + ]]) + end end) if not multigrid then -- cgit From 8bc973c6f59c6b90917dafc025303e69835167a3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 May 2023 01:13:03 +0800 Subject: fix(pum): fix missing scrollbar with 'rightleft' (#23448) --- test/functional/ui/popupmenu_spec.lua | 79 +++++++++-------------------------- 1 file changed, 20 insertions(+), 59 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 4c0ecd9c4e..61b815dbf6 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -2658,10 +2658,11 @@ describe('builtin popupmenu', function() end it('with rightleft vsplits', function() - screen:try_resize(40, 8) + screen:try_resize(40, 6) command('set rightleft') command('rightbelow vsplit') - command("set completeopt+=noinsert,noselect") + command('set completeopt+=noinsert,noselect') + command('set pumheight=2') feed('isome rightleft ') funcs.complete(16, {'word', 'choice', 'text', 'thing'}) if multigrid then @@ -2671,8 +2672,6 @@ describe('builtin popupmenu', function() [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -2680,8 +2679,6 @@ describe('builtin popupmenu', function() {1: ~}| {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 3 {2:-- INSERT --} | ## grid 4 @@ -2689,23 +2686,17 @@ describe('builtin popupmenu', function() {1: ~}| {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 5 - {n: drow }| - {n: eciohc }| - {n: txet }| - {n: gniht }| + {c: }{n: drow }| + {s: }{n: eciohc }| ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 1, -10, false, 100}; + [5] = {{id = -1}, "NW", 4, 1, -11, false, 100}; }} else screen:expect([[ tfelthgir emos│ ^ tfelthgir emos| - {1: }{n: drow }{1: ~}| - {1: }{n: eciohc }{1: ~}| - {1: }{n: txet }{1: ~}| - {1: }{n: gniht }{1: ~}| + {1: }{c: }{n: drow }{1: ~}| + {1: }{s: }{n: eciohc }{1: ~}| {1: ~}│{1: ~}| {3:[No Name] [+] }{4:[No Name] [+] }| {2:-- INSERT --} | @@ -2720,8 +2711,6 @@ describe('builtin popupmenu', function() [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -2729,8 +2718,6 @@ describe('builtin popupmenu', function() | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 3 {2:-- INSERT --} | ## grid 4 @@ -2738,24 +2725,18 @@ describe('builtin popupmenu', function() ^ | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 5 - {n: drow}| - {n: eciohc}| - {n: txet}| - {n: gniht}| + {c: }{n: drow}| + {s: }{n: eciohc}| ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 2, 5, false, 100}; + [5] = {{id = -1}, "NW", 4, 2, 4, false, 100}; }} else screen:expect([[ tfelthgir emos│ tfelthgir emos| │ ^ | - {1: ~}│{1: }{n: drow}| - {1: ~}│{1: }{n: eciohc}| - {1: ~}│{1: }{n: txet}| - {1: ~}│{1: }{n: gniht}| + {1: ~}│{1: }{c: }{n: drow}| + {1: ~}│{1: }{s: }{n: eciohc}| {3:[No Name] [+] }{4:[No Name] [+] }| {2:-- INSERT --} | ]]) @@ -2769,8 +2750,6 @@ describe('builtin popupmenu', function() [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -2778,8 +2757,6 @@ describe('builtin popupmenu', function() | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 3 ^ | ## grid 4 @@ -2787,8 +2764,6 @@ describe('builtin popupmenu', function() | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ]]} else screen:expect([[ @@ -2796,8 +2771,6 @@ describe('builtin popupmenu', function() │ | {1: ~}│{1: ~}| {1: ~}│{1: ~}| - {1: ~}│{1: ~}| - {1: ~}│{1: ~}| {3:[No Name] [+] }{4:[No Name] [+] }| ^ | ]]) @@ -2811,8 +2784,6 @@ describe('builtin popupmenu', function() [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -2820,8 +2791,6 @@ describe('builtin popupmenu', function() | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 3 define^ | ## grid 4 @@ -2829,27 +2798,19 @@ describe('builtin popupmenu', function() | {1: ~}| {1: ~}| - {1: ~}| - {1: ~}| ## grid 5 - {s:define }| - {n:jump }| - {n:list }| - {n:place }| - {n:undefine }| - {n:unplace }| + {s:define }{c: }| + {n:jump }{s: }| ]], float_pos={ - [5] = {{id = -1}, "SW", 1, 7, 0, false, 250}; + [5] = {{id = -1}, "SW", 1, 5, 0, false, 250}; }} else screen:expect([[ tfelthgir emos│ tfelthgir emos| - {s:define } │ | - {n:jump }{1: ~}│{1: ~}| - {n:list }{1: ~}│{1: ~}| - {n:place }{1: ~}│{1: ~}| - {n:undefine }{1: ~}│{1: ~}| - {n:unplace }{3: }{4:[No Name] [+] }| + │ | + {1: ~}│{1: ~}| + {s:define }{c: }{1: ~}│{1: ~}| + {n:jump }{s: }{3: }{4:[No Name] [+] }| define^ | ]]) end -- cgit From 540941ef8320e2005fe65e6776fc1068f18543c6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 May 2023 06:17:53 +0800 Subject: fix(pum): don't position too far with resized parent grid (#23442) --- test/functional/ui/multigrid_spec.lua | 378 +++++++++++++++++++++++++++++++++- 1 file changed, 376 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 558b9e3e16..4c04bcb54e 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -40,6 +40,7 @@ describe('ext_multigrid', function() [21] = {background = Screen.colors.LightMagenta}, [22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue}, [23] = {background = Screen.colors.Grey90}, + [24] = {background = Screen.colors.Grey}, }) end) @@ -1292,6 +1293,154 @@ describe('ext_multigrid', function() [4] = {{id = 1001}, "SE", 2, 16, 58, true, 50}; }} end) + + it('completion popup position', function() + insert(('\n'):rep(14) .. ('foo bar '):rep(7)) + feed('A') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + | + | + | + | + | + | + | + | + | + | + | + | + | + | + foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | + ## grid 4 + {24: foo}| + {21: bar}| + ]], float_pos={ + [4] = {{id = -1}, "NW", 2, 15, 55, false, 100}; + }} + feed('') + + command('setlocal rightleft') + feed('o') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + | + | + | + | + | + | + | + | + | + | + | + | + | + | + rab oof rab oof rab oof rab oof rab oof rab oof rab oof| + ^ oof| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | + ## grid 4 + {24: oof}| + {21: rab}| + ]], float_pos={ + [4] = {{id = -1}, "NW", 2, 16, 45, false, 100}; + }} + feed('') + + command('set wildoptions+=pum') + feed(':sign un') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + | + | + | + | + | + | + | + | + | + | + | + | + | + | + rab oof rab oof rab oof rab oof rab oof rab oof rab oof| + | + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + ## grid 3 + :sign undefine^ | + ## grid 4 + {24: undefine }| + {21: unplace }| + ]], float_pos={ + [4] = {{id = -1}, "SW", 1, 13, 5, false, 250}; + }} + end) end) it('multiline messages scroll over windows', function() @@ -2446,8 +2595,48 @@ describe('ext_multigrid', function() ]]} meths.input_mouse('right', 'press', '', 4, 0, 64) meths.input_mouse('right', 'release', '', 4, 0, 64) - -- FIXME: popup menu position is strange - -- screen:expect{} + screen:expect{grid=[[ + ## grid 1 + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do {20:eiusm}^o | + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 6 + {21: Copy }| + ]], float_pos={ + [6] = {{id = -1}, "NW", 4, 1, 63, false, 250}; + }} feed('') screen:expect{grid=[[ ## grid 1 @@ -2670,6 +2859,191 @@ describe('ext_multigrid', function() {1:~ }| ]]} eq('eiusmo', funcs.getreg('"')) + + screen:try_resize_grid(4, 7, 11) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + ^Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + eiusmo| + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + + funcs.setreg('"', '') + meths.input_mouse('left', 'press', '2', 4, 9, 1) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + {20:eiusm}^o| + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + meths.input_mouse('right', 'press', '', 4, 9, 1) + meths.input_mouse('right', 'release', '', 4, 9, 1) + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {7:-- VISUAL --} | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + {20:eiusm}^o| + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 6 + {21: Copy }| + ]], float_pos={ + [6] = {{id = -1}, "NW", 4, 10, 0, false, 250}; + }} + feed('') + screen:expect{grid=[[ + ## grid 1 + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]| + {12:[No Name] [+] [No Name] [+] }| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]| + {11:[No Name] [+] }| + [3:-----------------------------------------------------]| + ## grid 2 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ## grid 4 + Lorem i| + psum do| + lor sit| + amet, | + consect| + etur ad| + ipiscin| + g elit,| + sed do| + ^eiusmo| + {1:~ }| + ## grid 5 + some text | + to be clicked | + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + eq('eiusmo', funcs.getreg('"')) end) it('supports mouse drag with mouse=a', function() -- cgit From 62ecb05957f43b140e7dd874e1f84e3a6fa99838 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 May 2023 07:21:09 +0800 Subject: vim-patch:9.0.1506: line number not displayed when using 'smoothscroll' (#23453) Problem: Line number not displayed when using 'smoothscroll'. Solution: Adjust condition for showing the line number. (closes vim/vim#12333) https://github.com/vim/vim/commit/88bb3e0a48f160134bdea98cd2b8bd3af86f9d6f --- test/functional/ui/diff_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index dbdf3823ec..0f551e3044 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -1325,6 +1325,7 @@ it('win_update redraws lines properly', function() ]]} end) +-- oldtest: Test_diff_rnu() it('diff updates line numbers below filler lines', function() clear() local screen = Screen.new(40, 14) @@ -1401,6 +1402,7 @@ it('diff updates line numbers below filler lines', function() ]]) end) +-- oldtest: Test_diff_with_scroll_and_change() it('Align the filler lines when changing text in diff mode', function() clear() local screen = Screen.new(40, 20) -- cgit From dc394b9641f92a5014147da58f5e14fd1681ec0f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 3 May 2023 10:29:19 +0800 Subject: fix(mouse): fix popup menu position check with winbar (#23456) --- test/functional/ui/mouse_spec.lua | 11 ++++++ test/functional/ui/popupmenu_spec.lua | 73 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index d9b9cf9f1b..2c0a00c74f 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1861,5 +1861,16 @@ describe('ui/mouse/input', function() feed('') eq({1, 9}, meths.win_get_cursor(0)) eq('ran away', funcs.getreg('"')) + + -- Test for right click inside visual selection at bottom of window with winbar + command('setlocal winbar=WINBAR') + feed('2yyP') + funcs.setreg('"', '') + feed('G$vbb') + meths.input_mouse('right', 'press', '', 0, 4, 61) + meths.input_mouse('right', 'release', '', 0, 4, 61) + feed('') + eq({4, 20}, meths.win_get_cursor(0)) + eq('the moon', funcs.getreg('"')) end) end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 61b815dbf6..76038472bd 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -4509,6 +4509,79 @@ describe('builtin popupmenu', function() ]]) end eq('foo', meths.get_var('menustr')) + + command('setlocal winbar=WINBAR') + if multigrid then + meths.input_mouse('right', 'press', '', 6, 1, 14) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo}| + {n: bar}| + {n: baz}| + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + {2:WINBAR }| + ^popup menu test | + ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}}) + else + feed('<30,4>') + screen:expect([[ + popup menu test | + {1:~ }{n: foo}| + {3:[No Name] [+] }{n: bar}| + popup menu test│{2:WINBAR }{n: baz}| + {1:~ }│^popup menu test | + :let g:menustr = 'foo' | + ]]) + end + if multigrid then + meths.input_mouse('left', 'press', '', 4, 1, 2) + screen:expect({grid=[[ + ## grid 1 + [2:--------------------------------]| + [2:--------------------------------]| + {3:[No Name] [+] }| + [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]| + [3:--------------------------------]| + ## grid 2 + popup menu test | + {1:~ }| + ## grid 3 + :let g:menustr = 'bar' | + ## grid 5 + popup menu test| + {1:~ }| + ## grid 6 + {2:WINBAR }| + ^popup menu test | + ]]}) + else + feed('<31,2>') + screen:expect([[ + popup menu test | + {1:~ }| + {3:[No Name] [+] }| + popup menu test│{2:WINBAR }| + {1:~ }│^popup menu test | + :let g:menustr = 'bar' | + ]]) + end + eq('bar', meths.get_var('menustr')) end) if not multigrid then -- cgit From 88cfb49bee3c9102082c7010acb92244e4ad1348 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 07:14:39 +0800 Subject: vim-patch:8.2.4890: inconsistent capitalization in error messages Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar --- test/functional/ui/cmdline_highlight_spec.lua | 4 ++-- test/functional/ui/mouse_spec.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 783246c6e4..636f571641 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -854,11 +854,11 @@ describe('Ex commands coloring', function() :# | {ERR:Error detected while processing :} | {ERR:E605: Exception not caught: 42} | - {ERR:E749: empty buffer} | + {ERR:E749: Empty buffer} | {PE:Press ENTER or type command to continue}^ | ]]) feed('') - eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: empty buffer', + eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: Empty buffer', exec_capture('messages')) end) it('errors out when failing to get callback', function() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 2c0a00c74f..e55804e29f 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -790,7 +790,7 @@ describe('ui/mouse/input', function() feed('<0,0>') screen:expect([[ {6:E433: No tags file} | - {6:E426: tag not found: test}| + {6:E426: Tag not found: test}| {6:ing} | {7:Press ENTER or type comma}| {7:nd to continue}^ | -- cgit From 4a098b97e53551a3383e669f4730be542c61e012 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 5 May 2023 06:32:17 +0800 Subject: fix(excmd): append original command to error message Revert the change to do_cmdline_cmd() from #5226. This function is used in many places, so making it different from Vim leads to small differences from Vim in the behavior of some functions like execute() and assert_fails(). If DOCMD_VERBOSE really needs to be removed somewhere, a do_cmdline() call without DOCMD_VERBOSE is also shorter than a do_cmdline() call with DOCMD_VERBOSE. --- test/functional/ui/inccommand_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index a67db78cbe..28f489783b 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -1720,7 +1720,7 @@ describe("'inccommand' and :cnoremap", function() local function refresh(case, visual) clear() - screen = visual and Screen.new(50,10) or nil + screen = visual and Screen.new(80,10) or nil common_setup(screen, case, default_text) end -- cgit From 22205f36a6213f51f211a67444b335f916a2fa9f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 May 2023 07:46:07 +0800 Subject: fix(api): don't change title when setting buffer in a window (#23492) --- test/functional/ui/screen_basic_spec.lua | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 439021ad87..6b05bd01c2 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, command = helpers.feed, helpers.command +local curwin = helpers.curwin local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval @@ -189,6 +190,52 @@ local function screen_tests(linegrid) eq(expected, screen.title) end) end) + + it('setting the buffer of another window using RPC', function() + local oldwin = curwin().id + command('split') + meths.win_set_buf(oldwin, buf2) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('setting the buffer of another window using Lua callback', function() + local oldwin = curwin().id + command('split') + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_win_set_buf(%d, %d) + end) + ]], oldwin, buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using RPC', function() + meths.open_win(buf2, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using Lua callback', function() + exec_lua(string.format([[ + vim.api.nvim_open_win(%d, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) end) end) -- cgit From 4ecf6fdfd857b52c0bab9a8dbfc760364ac2677b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 May 2023 16:25:03 +0800 Subject: fix(statusline): bail out properly on negative row (#23535) --- test/functional/ui/winbar_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 970f9c3d76..3b79f4328d 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -713,3 +713,26 @@ describe('local winbar with tabs', function() ]]} end) end) + +it('winbar works properly when redrawing is postponed #23534', function() + clear({args = { + '-c', 'set laststatus=2 lazyredraw', + '-c', 'setlocal statusline=(statusline) winbar=(winbar)', + '-c', 'call nvim_input(":")', + }}) + local screen = Screen.new(60, 6) + screen:attach() + screen:set_default_attr_ids({ + [0] = {foreground = Screen.colors.Blue, bold = true}, + [1] = {bold = true}, + [2] = {bold = true, reverse = true}, + }) + screen:expect([[ + {1:(winbar) }| + ^ | + {0:~ }| + {0:~ }| + {2:(statusline) }| + | + ]]) +end) -- cgit From 36baaf7c1aa0bbc9c80f4512bb1384839c8851ff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 May 2023 00:14:54 +0800 Subject: test: move most title tests to a separate file (#23557) This avoids running title tests twice unnecessarily. --- test/functional/ui/screen_basic_spec.lua | 121 +-------------------------- test/functional/ui/title_spec.lua | 138 +++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 120 deletions(-) create mode 100644 test/functional/ui/title_spec.lua (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 6b05bd01c2..e1ae76badf 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,12 +2,10 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, command = helpers.feed, helpers.command -local curwin = helpers.curwin local insert = helpers.insert local eq = helpers.eq local eval = helpers.eval -local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua -local is_os = helpers.is_os +local funcs, meths = helpers.funcs, helpers.meths describe('screen', function() local screen @@ -120,123 +118,6 @@ local function screen_tests(linegrid) eq(expected, screen.title) end) end) - - it('has correct default title with unnamed file', function() - local expected = '[No Name] - NVIM' - command('set title') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('has correct default title with named file', function() - local expected = (is_os('win') and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM') - command('set title') - command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - describe('is not changed by', function() - local file1 = is_os('win') and 'C:\\mydir\\myfile1' or '/mydir/myfile1' - local file2 = is_os('win') and 'C:\\mydir\\myfile2' or '/mydir/myfile2' - local expected = (is_os('win') and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM') - local buf2 - - before_each(function() - command('edit '..file1) - buf2 = funcs.bufadd(file2) - command('set title') - end) - - it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() - command([[inoremap =setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : '']]) - feed('i') - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('an RPC call to nvim_buf_set_option in a hidden buffer', function() - meths.buf_set_option(buf2, 'autoindent', true) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function() - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_buf_set_option(%d, 'autoindent', true) - end) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('a Lua callback calling nvim_buf_call in a hidden buffer', function() - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_buf_call(%d, function() end) - end) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('setting the buffer of another window using RPC', function() - local oldwin = curwin().id - command('split') - meths.win_set_buf(oldwin, buf2) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('setting the buffer of another window using Lua callback', function() - local oldwin = curwin().id - command('split') - exec_lua(string.format([[ - vim.schedule(function() - vim.api.nvim_win_set_buf(%d, %d) - end) - ]], oldwin, buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('creating a floating window using RPC', function() - meths.open_win(buf2, false, { - relative = 'editor', width = 5, height = 5, row = 0, col = 0, - }) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - - it('creating a floating window using Lua callback', function() - exec_lua(string.format([[ - vim.api.nvim_open_win(%d, false, { - relative = 'editor', width = 5, height = 5, row = 0, col = 0, - }) - ]], buf2)) - command('redraw!') - screen:expect(function() - eq(expected, screen.title) - end) - end) - end) end) describe(':set icon', function() diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua new file mode 100644 index 0000000000..75ead49f74 --- /dev/null +++ b/test/functional/ui/title_spec.lua @@ -0,0 +1,138 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local command = helpers.command +local curwin = helpers.curwin +local eq = helpers.eq +local exec_lua = helpers.exec_lua +local feed = helpers.feed +local funcs = helpers.funcs +local meths = helpers.meths +local is_os = helpers.is_os + +describe('title', function() + local screen + + before_each(function() + clear() + screen = Screen.new() + screen:attach() + end) + + it('has correct default title with unnamed file', function() + local expected = '[No Name] - NVIM' + command('set title') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('has correct default title with named file', function() + local expected = (is_os('win') and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM') + command('set title') + command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + describe('is not changed by', function() + local file1 = is_os('win') and 'C:\\mydir\\myfile1' or '/mydir/myfile1' + local file2 = is_os('win') and 'C:\\mydir\\myfile2' or '/mydir/myfile2' + local expected = (is_os('win') and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM') + local buf2 + + before_each(function() + command('edit '..file1) + buf2 = funcs.bufadd(file2) + command('set title') + end) + + it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() + command([[inoremap =setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : '']]) + feed('i') + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('an RPC call to nvim_buf_set_option in a hidden buffer', function() + meths.buf_set_option(buf2, 'autoindent', true) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function() + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_buf_set_option(%d, 'autoindent', true) + end) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('a Lua callback calling nvim_buf_call in a hidden buffer', function() + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_buf_call(%d, function() end) + end) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('setting the buffer of another window using RPC', function() + local oldwin = curwin().id + command('split') + meths.win_set_buf(oldwin, buf2) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('setting the buffer of another window using Lua callback', function() + local oldwin = curwin().id + command('split') + exec_lua(string.format([[ + vim.schedule(function() + vim.api.nvim_win_set_buf(%d, %d) + end) + ]], oldwin, buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using RPC', function() + meths.open_win(buf2, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + + it('creating a floating window using Lua callback', function() + exec_lua(string.format([[ + vim.api.nvim_open_win(%d, false, { + relative = 'editor', width = 5, height = 5, row = 0, col = 0, + }) + ]], buf2)) + command('redraw!') + screen:expect(function() + eq(expected, screen.title) + end) + end) + end) +end) -- cgit From 03ca36d1f8d027c95edd46f3127284e9a3577990 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 May 2023 23:46:50 +0800 Subject: fix(highlight): apply 'winblend' to NormalNC (#23555) --- test/functional/ui/float_spec.lua | 63 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 28c16642f1..46a079d9ff 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8079,10 +8079,13 @@ describe('float window', function() [6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')}, [7] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0x0000d8')}, [8] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1}, - [9] = {background = Screen.colors.LightMagenta, blend=30}, - [10] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend=0}, - [11] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend=80}, - [12] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1, blend=30}, + [9] = {background = Screen.colors.LightMagenta, blend = 30}, + [10] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 0}, + [11] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 80}, + [12] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1, blend = 30}, + [13] = {background = Screen.colors.LightGray, blend = 30}, + [14] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey88}, + [15] = {foreground = tonumber('0x939393'), background = Screen.colors.Grey88}, }) insert([[ Lorem ipsum dolor sit amet, consectetur @@ -8184,6 +8187,58 @@ describe('float window', function() ]]) end + -- Check that 'winblend' works with NormalNC highlight + meths.set_option_value('winhighlight', 'NormalNC:Visual', {win = win}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [3:--------------------------------------------------]| + ## grid 2 + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + laborum^. | + ## grid 3 + | + ## grid 5 + {13:test }| + {13: }| + {13:popup text }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + }} + else + screen:expect([[ + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea co{14:test}{15:o consequat}. Duis aute irure dolor in | + repre{15:henderit in vol}uptate velit esse cillum | + dolor{14:popup}{15:fugi}{14:text}{15:ul}la pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + qui officia deserunt mollit anim id est | + laborum^. | + | + ]]) + end + + -- Also test with global NormalNC highlight + meths.set_option_value('winhighlight', '', {win = win}) + command('hi link NormalNC Visual') + screen:expect_unchanged(true) + command('hi clear NormalNC') + command('hi SpecialRegion guifg=Red blend=0') meths.buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1) if multigrid then -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/ui/cmdline_highlight_spec.lua | 2 +- test/functional/ui/cursor_spec.lua | 8 ++-- test/functional/ui/decorations_spec.lua | 6 +-- test/functional/ui/float_spec.lua | 52 ++++++++++++------------- test/functional/ui/fold_spec.lua | 4 +- test/functional/ui/inccommand_spec.lua | 23 +++++------ test/functional/ui/inccommand_user_spec.lua | 2 +- test/functional/ui/messages_spec.lua | 2 +- test/functional/ui/mouse_spec.lua | 26 ++++++------- test/functional/ui/multigrid_spec.lua | 6 +-- test/functional/ui/quickfix_spec.lua | 2 +- test/functional/ui/screen_basic_spec.lua | 10 ++--- test/functional/ui/statusline_spec.lua | 56 +++++++++++++-------------- test/functional/ui/title_spec.lua | 8 ++-- test/functional/ui/wildmode_spec.lua | 20 +++++----- test/functional/ui/winbar_spec.lua | 8 ++-- 16 files changed, 115 insertions(+), 120 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 636f571641..17e6855ee4 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -178,7 +178,7 @@ end describe('Command-line coloring', function() it('works', function() set_color_cb('RainBowParens') - meths.set_option('more', false) + meths.set_option_value('more', false, {}) start_prompt() screen:expect([[ | diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 7e28caea04..01475a189d 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -265,8 +265,8 @@ describe('ui/cursor', function() } -- Another cursor style. - meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' - ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42') + meths.set_option_value('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' + ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', {}) screen:expect(function() local named = {} for _, m in ipairs(screen._mode_info) do @@ -288,7 +288,7 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.set_option('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor') + meths.set_option_value('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {}) screen:expect(function() for _,m in ipairs(screen._mode_info) do if m.name ~= 'normal' then @@ -304,7 +304,7 @@ describe('ui/cursor', function() end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() - meths.set_option('guicursor', '') + meths.set_option_value('guicursor', '', {}) screen:expect(function() -- Empty 'guicursor' sets enabled=false. eq(false, screen._cursor_style_enabled) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f531878bc6..324362a865 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1910,7 +1910,7 @@ describe('decorations: signs', function() } ns = meths.create_namespace 'test' - meths.win_set_option(0, 'signcolumn', 'auto:9') + meths.set_option_value('signcolumn', 'auto:9', {win = 0}) end) local example_text = [[ @@ -2222,7 +2222,7 @@ l5 ]]} -- Check truncation works too - meths.win_set_option(0, 'signcolumn', 'auto') + meths.set_option_value('signcolumn', 'auto', {win = 0}) screen:expect{grid=[[ S5^l1 | @@ -2233,7 +2233,7 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) - meths.win_set_option(0, 'signcolumn', 'auto') + meths.set_option_value('signcolumn', 'auto', {win = 0}) insert(example_text) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 46a079d9ff..19ad340dd5 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -105,7 +105,7 @@ describe('float window', function() it('opened with correct height', function() local height = exec_lua([[ - vim.api.nvim_set_option("winheight", 20) + vim.go.winheight = 20 local bufnr = vim.api.nvim_create_buf(false, true) local opts = { @@ -127,7 +127,7 @@ describe('float window', function() it('opened with correct width', function() local width = exec_lua([[ - vim.api.nvim_set_option("winwidth", 20) + vim.go.winwidth = 20 local bufnr = vim.api.nvim_create_buf(false, true) local opts = { @@ -427,36 +427,36 @@ describe('float window', function() it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local float_win = meths.open_win(0, true, float_opts) - meths.win_set_option(float_win, 'fillchars', NIL) + meths.set_option_value('fillchars', NIL, {win=float_win.id}) float_opts.style = 'minimal' meths.win_set_config(float_win, float_opts) assert_alive() - end) + end) - it("should re-apply 'style' when present", function() + it("should re-apply 'style' when present", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} local float_win = meths.open_win(0, true, float_opts) - meths.win_set_option(float_win, 'number', true) + meths.set_option_value('number', true, { win = float_win }) float_opts.row = 2 meths.win_set_config(float_win, float_opts) - eq(false, meths.win_get_option(float_win, 'number')) + eq(false, meths.get_option_value('number', { win = float_win })) end) it("should not re-apply 'style' when missing", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} local float_win = meths.open_win(0, true, float_opts) - meths.win_set_option(float_win, 'number', true) + meths.set_option_value('number', true, { win = float_win }) float_opts.row = 2 float_opts.style = nil meths.win_set_config(float_win, float_opts) - eq(true, meths.win_get_option(float_win, 'number')) + eq(true, meths.get_option_value('number', { win = float_win })) end) it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function() - meths.set_option('splitkeep', 'screen') + meths.set_option_value('splitkeep', 'screen', {}) local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} local float_win = meths.open_win(0, true, float_opts) - eq(5, meths.win_get_option(float_win, 'scroll')) + eq(5, meths.get_option_value('scroll', {win=float_win.id})) end) describe('with only one tabpage,', function() @@ -4553,8 +4553,8 @@ describe('float window', function() describe('and completion', function() before_each(function() local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}) - meths.win_set_option(win , 'winhl', 'Normal:ErrorMsg') + local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id + meths.set_option_value('winhl', 'Normal:ErrorMsg', {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -7823,7 +7823,7 @@ describe('float window', function() local buf = meths.create_buf(false,false) meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) - meths.win_set_option(float_win, 'winbar', 'floaty bar') + meths.set_option_value('winbar', 'floaty bar', {win=float_win.id}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8144,7 +8144,7 @@ describe('float window', function() ]]) end - meths.win_set_option(win, "winblend", 30) + meths.set_option_value("winblend", 30, {win=win.id}) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -8452,7 +8452,7 @@ describe('float window', function() -- at least. Also check invisible EndOfBuffer region blends correctly. meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) - meths.win_set_option(win, 'winblend', 30) + meths.set_option_value('winblend', 30, {win=win.id}) screen:set_default_attr_ids({ [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')}, [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')}, @@ -8694,7 +8694,7 @@ describe('float window', function() it("correctly orders multiple opened floats (current last)", function() local buf = meths.create_buf(false,false) local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg") + meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) if multigrid then screen:expect{grid=[[ @@ -8739,10 +8739,10 @@ describe('float window', function() exec_lua [[ local buf = vim.api.nvim_create_buf(false,false) local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8}) - vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal") + vim.wo[win].winhl = "EndOfBuffer:Normal" buf = vim.api.nvim_create_buf(false,false) win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10}) - vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search") + vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search" ]] if multigrid then @@ -8799,7 +8799,7 @@ describe('float window', function() it("correctly orders multiple opened floats (non-current last)", function() local buf = meths.create_buf(false,false) local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg") + meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) if multigrid then screen:expect{grid=[[ @@ -8844,10 +8844,10 @@ describe('float window', function() exec_lua [[ local buf = vim.api.nvim_create_buf(false,false) local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10}) - vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search") + vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search" buf = vim.api.nvim_create_buf(false,false) win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8}) - vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal") + vim.wo[win].winhl = "EndOfBuffer:Normal" ]] if multigrid then @@ -8904,11 +8904,11 @@ describe('float window', function() it('can use z-index', function() local buf = meths.create_buf(false,false) local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30}) - meths.win_set_option(win1, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg") + meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id}) local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50}) - meths.win_set_option(win2, "winhl", "Normal:Search,EndOfBuffer:Search") + meths.set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id}) local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40}) - meths.win_set_option(win3, "winhl", "Normal:Question,EndOfBuffer:Question") + meths.set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id}) if multigrid then screen:expect{grid=[[ @@ -8967,7 +8967,7 @@ describe('float window', function() it('can use winbar', function() local buf = meths.create_buf(false,false) local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) - meths.win_set_option(win1, 'winbar', 'floaty bar') + meths.set_option_value('winbar', 'floaty bar', {win=win1.id}) if multigrid then screen:expect{grid=[[ diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index a99b77f707..7a0495f93c 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -967,8 +967,8 @@ describe("folded lines", function() it("works with multibyte text", function() -- Currently the only allowed value of 'maxcombine' - eq(6, meths.get_option('maxcombine')) - eq(true, meths.get_option('arabicshape')) + eq(6, meths.get_option_value('maxcombine', {})) + eq(true, meths.get_option_value('arabicshape', {})) insert([[ å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة möre text]]) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 28f489783b..23b200bd24 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2,7 +2,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command -local curbufmeths = helpers.curbufmeths local eq = helpers.eq local eval = helpers.eval local feed_command = helpers.feed_command @@ -178,8 +177,8 @@ describe(":substitute, 'inccommand' preserves", function() feed_command("set inccommand=" .. case) insert("as") feed(":%s/as/glork/") - eq(meths.get_option('undolevels'), 139) - eq(curbufmeths.get_option('undolevels'), 34) + eq(meths.get_option_value('undolevels', {scope='global'}), 139) + eq(meths.get_option_value('undolevels', {buf=0}), 34) end) end @@ -1192,7 +1191,7 @@ describe(":substitute, inccommand=split", function() it("deactivates if 'redrawtime' is exceeded #5602", function() -- prevent redraws from 'incsearch' - meths.set_option('incsearch', false) + meths.set_option_value('incsearch', false, {}) -- Assert that 'inccommand' is ENABLED initially. eq("split", eval("&inccommand")) -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. @@ -2465,16 +2464,14 @@ describe(":substitute", function() end) it("inccommand=split, contraction of two subsequent NL chars", function() - -- luacheck: push ignore 611 local text = [[ AAA AA - + BBB BB - + CCC CC - + ]] - -- luacheck: pop -- This used to crash, but more than 20 highlight entries are required -- to reproduce it (so that the marktree has multiple nodes) @@ -2501,16 +2498,14 @@ describe(":substitute", function() end) it("inccommand=nosplit, contraction of two subsequent NL chars", function() - -- luacheck: push ignore 611 local text = [[ AAA AA - + BBB BB - + CCC CC - + ]] - -- luacheck: pop common_setup(screen, "nosplit", string.rep(text,10)) feed(":%s/\\n\\n//g") diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 43e9b94feb..6329ece40a 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -391,7 +391,7 @@ describe("'inccommand' for user commands", function() vim.api.nvim_create_user_command('Replace', function() end, { nargs = '*', preview = function() - vim.api.nvim_set_option('inccommand', 'split') + vim.api.nvim_set_option_value('inccommand', 'split', {}) return 2 end, }) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 1a7fe26d26..46a42e5beb 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1273,7 +1273,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| | ]]) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) end) end) diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index e55804e29f..d8739e1c31 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -11,8 +11,8 @@ describe('ui/mouse/input', function() before_each(function() clear() - meths.set_option('mouse', 'a') - meths.set_option('list', true) + meths.set_option_value('mouse', 'a', {}) + meths.set_option_value('list', true, {}) -- NB: this is weird, but mostly irrelevant to the test -- So I didn't bother to change it command('set listchars=eol:$') @@ -64,7 +64,7 @@ describe('ui/mouse/input', function() end) it("in external ui works with unset 'mouse'", function() - meths.set_option('mouse', '') + meths.set_option_value('mouse', '', {}) feed('<2,1>') screen:expect{grid=[[ testing | @@ -379,7 +379,7 @@ describe('ui/mouse/input', function() end) it('left click in default tabline (position 24) closes tab', function() - meths.set_option('hidden', true) + meths.set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -402,7 +402,7 @@ describe('ui/mouse/input', function() end) it('double click in default tabline (position 4) opens new tab', function() - meths.set_option('hidden', true) + meths.set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -437,8 +437,8 @@ describe('ui/mouse/input', function() return call('Test', a:000 + [2]) endfunction ]]) - meths.set_option('tabline', '%@Test@test%X-%5@Test2@test2') - meths.set_option('showtabline', 2) + meths.set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {}) + meths.set_option_value('showtabline', 2, {}) screen:expect([[ {fill:test-test2 }| testing | @@ -786,7 +786,7 @@ describe('ui/mouse/input', function() end) it('ctrl + left click will search for a tag', function() - meths.set_option('tags', './non-existent-tags-file') + meths.set_option_value('tags', './non-existent-tags-file', {}) feed('<0,0>') screen:expect([[ {6:E433: No tags file} | @@ -1577,9 +1577,9 @@ describe('ui/mouse/input', function() end) it('getmousepos works correctly', function() - local winwidth = meths.get_option('winwidth') + local winwidth = meths.get_option_value('winwidth', {}) -- Set winwidth=1 so that window sizes don't change. - meths.set_option('winwidth', 1) + meths.set_option_value('winwidth', 1, {}) command('tabedit') local tabpage = meths.get_current_tabpage() insert('hello') @@ -1597,8 +1597,8 @@ describe('ui/mouse/input', function() } local float = meths.open_win(meths.get_current_buf(), false, opts) command('redraw') - local lines = meths.get_option('lines') - local columns = meths.get_option('columns') + local lines = meths.get_option_value('lines', {}) + local columns = meths.get_option_value('columns', {}) -- Test that screenrow and screencol are set properly for all positions. for row = 0, lines - 1 do @@ -1696,7 +1696,7 @@ describe('ui/mouse/input', function() -- Restore state and release mouse. command('tabclose!') - meths.set_option('winwidth', winwidth) + meths.set_option_value('winwidth', winwidth, {}) meths.input_mouse('left', 'release', '', 0, 0, 0) end) diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 4c04bcb54e..8918c46de6 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3555,7 +3555,7 @@ describe('ext_multigrid', function() end) it('with winbar dragging statusline with mouse works correctly', function() - meths.set_option('winbar', 'Set Up The Bars') + meths.set_option_value('winbar', 'Set Up The Bars', {}) command('split') screen:expect([[ ## grid 1 @@ -3695,7 +3695,7 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]]) - eq(3, meths.get_option('cmdheight')) + eq(3, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 1, 12, 10) screen:expect([[ @@ -3730,6 +3730,6 @@ describe('ext_multigrid', function() {1:~ }| {1:~ }| ]]) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) end) end) diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua index b0d89ee3b6..df43871e60 100644 --- a/test/functional/ui/quickfix_spec.lua +++ b/test/functional/ui/quickfix_spec.lua @@ -27,7 +27,7 @@ describe('quickfix selection highlight', function() [12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia}, }) - meths.set_option('errorformat', '%m %l') + meths.set_option_value('errorformat', '%m %l', {}) command('syntax on') command('highlight Search guibg=Green') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index e1ae76badf..b31e40d4ab 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -828,7 +828,7 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option('showtabline', 2) + meths.set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | @@ -1056,8 +1056,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option('lines')) - eq(99, meths.get_option('window')) + eq(100, meths.get_option_value('lines', {})) + eq(99, meths.get_option_value('window', {})) eq(99, meths.win_get_height(0)) feed('1000o') eq(903, funcs.line('w0')) @@ -1071,8 +1071,8 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() eq(903, funcs.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option('lines')) - eq(49, meths.get_option('window')) + eq(50, meths.get_option_value('lines', {})) + eq(49, meths.get_option_value('window', {})) eq(49, meths.win_get_height(0)) eq(953, funcs.line('w0')) feed('') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 5ea4eade4e..5afa912be6 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -34,7 +34,7 @@ for _, model in ipairs(mousemodels) do end) it('works', function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) meths.input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval("g:testvar")) meths.input_mouse('left', 'press', '', 0, 6, 17) @@ -54,7 +54,7 @@ for _, model in ipairs(mousemodels) do end) it('works for winbar', function() - meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) meths.input_mouse('left', 'press', '', 0, 0, 17) eq('0 1 l', eval("g:testvar")) meths.input_mouse('right', 'press', '', 0, 0, 17) @@ -72,8 +72,8 @@ for _, model in ipairs(mousemodels) do it('works when there are multiple windows', function() command('split') - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') - meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) meths.input_mouse('left', 'press', '', 0, 0, 17) eq('0 1 l', eval("g:testvar")) meths.input_mouse('right', 'press', '', 0, 4, 17) @@ -90,23 +90,23 @@ for _, model in ipairs(mousemodels) do vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) end ]]) - meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T') + meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {}) meths.input_mouse('left', 'press', '', 0, 6, 17) eq('0 1 l', eval("g:testvar")) end) it('ignores unsupported click items', function() command('tabnew | tabprevious') - meths.set_option('statusline', '%2TNot clicky stuff%T') + meths.set_option_value('statusline', '%2TNot clicky stuff%T', {}) meths.input_mouse('left', 'press', '', 0, 6, 0) eq(1, meths.get_current_tabpage().id) - meths.set_option('statusline', '%2XNot clicky stuff%X') + meths.set_option_value('statusline', '%2XNot clicky stuff%X', {}) meths.input_mouse('left', 'press', '', 0, 6, 0) eq(2, #meths.list_tabpages()) end) it("right click works when statusline isn't focused #18994", function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) meths.input_mouse('right', 'press', '', 0, 6, 17) eq('0 1 r', eval("g:testvar")) meths.input_mouse('right', 'press', '', 0, 6, 17) @@ -114,7 +114,7 @@ for _, model in ipairs(mousemodels) do end) it("works with modifiers #18994", function() - meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks meths.input_mouse('left', 'press', 'S', 0, 6, 17) eq('0 1 l(s )', eval("g:testvar")) @@ -143,7 +143,7 @@ for _, model in ipairs(mousemodels) do it("works for global statusline with vertical splits #19186", function() command('set laststatus=3') - meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T') + meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {}) command('vsplit') screen:expect([[ ^ │ | @@ -394,38 +394,38 @@ describe('global statusline', function() end) it('win_move_statusline() can reduce cmdheight to 1', function() - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) funcs.win_move_statusline(0, -1) - eq(2, meths.get_option('cmdheight')) + eq(2, meths.get_option_value('cmdheight', {})) funcs.win_move_statusline(0, -1) - eq(3, meths.get_option('cmdheight')) + eq(3, meths.get_option_value('cmdheight', {})) funcs.win_move_statusline(0, 1) - eq(2, meths.get_option('cmdheight')) + eq(2, meths.get_option_value('cmdheight', {})) funcs.win_move_statusline(0, 1) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) end) it('mouse dragging can reduce cmdheight to 1', function() command('set mouse=a') meths.input_mouse('left', 'press', '', 0, 14, 10) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option('cmdheight')) + eq(2, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 12, 10) - eq(3, meths.get_option('cmdheight')) + eq(3, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option('cmdheight')) + eq(2, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 15, 10) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) end) it('cmdline row is correct after setting cmdheight #20514', function() command('botright split test/functional/fixtures/bigfile.txt') - meths.set_option('cmdheight', 1) + meths.set_option_value('cmdheight', 1, {}) feed('L') screen:expect([[ | @@ -464,7 +464,7 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option('showtabline', 2) + meths.set_option_value('showtabline', 2, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -483,7 +483,7 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option('cmdheight', 0) + meths.set_option_value('cmdheight', 0, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -502,7 +502,7 @@ describe('global statusline', function() ^0007;;Cc;0;BN;;;;;N;BELL;;;; | {2:test/functional/fixtures/bigfile.txt 8,1 0%}| ]]) - meths.set_option('cmdheight', 1) + meths.set_option_value('cmdheight', 1, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | @@ -526,8 +526,8 @@ end) it('statusline does not crash if it has Arabic characters #19447', function() clear() - meths.set_option('statusline', 'غً') - meths.set_option('laststatus', 2) + meths.set_option_value('statusline', 'غً', {}) + meths.set_option_value('laststatus', 2, {}) command('redraw!') assert_alive() end) diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua index 75ead49f74..2247d2e80f 100644 --- a/test/functional/ui/title_spec.lua +++ b/test/functional/ui/title_spec.lua @@ -57,18 +57,18 @@ describe('title', function() end) end) - it('an RPC call to nvim_buf_set_option in a hidden buffer', function() - meths.buf_set_option(buf2, 'autoindent', true) + it('an RPC call to nvim_set_option_value in a hidden buffer', function() + meths.set_option_value('autoindent', true, { buf = buf2 }) command('redraw!') screen:expect(function() eq(expected, screen.title) end) end) - it('a Lua callback calling nvim_buf_set_option in a hidden buffer', function() + it('a Lua callback calling nvim_set_option_value in a hidden buffer', function() exec_lua(string.format([[ vim.schedule(function() - vim.api.nvim_buf_set_option(%d, 'autoindent', true) + vim.api.nvim_set_option_value('autoindent', true, { buf = %d }) end) ]], buf2)) command('redraw!') diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 50466c9473..0355c57b5a 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -367,12 +367,12 @@ describe("'wildmenu'", function() } -- Wildcharm? where we are going we aint't no need no wildcharm. - eq(0, meths.get_option'wildcharm') + eq(0, meths.get_option_value('wildcharm', {})) -- Don't mess the defaults yet (neovim is about backwards compatibility) - eq(9, meths.get_option'wildchar') + eq(9, meths.get_option_value('wildchar', {})) -- Lol what is cnoremap? Some say it can define mappings. command 'set wildchar=0' - eq(0, meths.get_option'wildchar') + eq(0, meths.get_option_value('wildchar', {})) command 'cnoremap ' feed(':syntax ') @@ -481,9 +481,9 @@ describe('command line completion', function() end) it('does not leak memory with with wildmenu and only one match #19874', function() - meths.set_option('wildmenu', true) - meths.set_option('wildmode', 'full') - meths.set_option('wildoptions', 'pum') + meths.set_option_value('wildmenu', true, {}) + meths.set_option_value('wildmode', 'full', {}) + meths.set_option_value('wildoptions', 'pum', {}) feed(':sign unpla') screen:expect([[ @@ -505,8 +505,8 @@ describe('command line completion', function() end) it('does not show matches with without wildmenu with wildmode=full', function() - meths.set_option('wildmenu', false) - meths.set_option('wildmode', 'full') + meths.set_option_value('wildmenu', false, {}) + meths.set_option_value('wildmode', 'full', {}) feed(':sign ') screen:expect([[ @@ -519,8 +519,8 @@ describe('command line completion', function() end) it('shows matches with without wildmenu with wildmode=list', function() - meths.set_option('wildmenu', false) - meths.set_option('wildmode', 'list') + meths.set_option_value('wildmenu', false, {}) + meths.set_option_value('wildmode', 'list', {}) feed(':sign ') screen:expect([[ diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 3b79f4328d..78bbcd3a63 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -31,7 +31,7 @@ describe('winbar', function() [10] = {background = Screen.colors.LightGrey, underline = true}, [11] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, }) - meths.set_option('winbar', 'Set Up The Bars') + meths.set_option_value('winbar', 'Set Up The Bars', {}) end) it('works', function() @@ -206,7 +206,7 @@ describe('winbar', function() insert [[ just some random text]] - meths.set_option('winbar', 'Hello, I am a ruler: %l,%c') + meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {}) screen:expect{grid=[[ {1:Hello, I am a ruler: 2,11 }| just some | @@ -450,7 +450,7 @@ describe('winbar', function() | | ]]) - eq(3, meths.get_option('cmdheight')) + eq(3, meths.get_option_value('cmdheight', {})) meths.input_mouse('left', 'drag', '', 1, 11, 10) screen:expect([[ @@ -468,7 +468,7 @@ describe('winbar', function() {2:[No Name] }| | ]]) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) end) it('properly equalizes window height for window-local value', function() -- cgit From 60f69014a801891d084542cf98ba2aa0d476164a Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sun, 21 May 2023 13:00:37 +0200 Subject: fix(redraw): multibyte characters are wrapped at the end of a line (#23696) Problem: Multibyte characters may be wrapped at the end of a line when 'statuscolumn' and 'spell' are set. Solution: Update line pointerdiff "v" before fetching the line pointer after evaluating 'statuscolumn'. --- test/functional/ui/statuscolumn_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 3b41d3684a..3d68246ba9 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -674,4 +674,16 @@ describe('statuscolumn', function() ]]) eq(2, eval('g:stcnr')) end) + + it('does not wrap multibyte characters at the end of a line', function() + screen:try_resize(33, 4) + command([[set spell stc=%l\ ]]) + command('call setline(8, "This is a line that contains ᶏ multibyte character.")') + screen:expect([[ + 8 ^This is a line that contains ᶏ| + multibyte character. | + 9 aaaaa | + | + ]]) + end) end) -- cgit From 576dddb46168e81aa0f78c28816082c662dedea1 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 22 May 2023 12:47:10 +0600 Subject: test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value` `nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter. --- test/functional/ui/decorations_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 324362a865..ccf1810ee1 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1910,7 +1910,7 @@ describe('decorations: signs', function() } ns = meths.create_namespace 'test' - meths.set_option_value('signcolumn', 'auto:9', {win = 0}) + meths.set_option_value('signcolumn', 'auto:9', {}) end) local example_text = [[ @@ -2222,7 +2222,7 @@ l5 ]]} -- Check truncation works too - meths.set_option_value('signcolumn', 'auto', {win = 0}) + meths.set_option_value('signcolumn', 'auto', {}) screen:expect{grid=[[ S5^l1 | @@ -2233,7 +2233,7 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) - meths.set_option_value('signcolumn', 'auto', {win = 0}) + meths.set_option_value('signcolumn', 'auto', {}) insert(example_text) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) -- cgit From b11a8c1b5d3985479351b34f2078d490cbf59e90 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 22 May 2023 11:07:55 +0200 Subject: fix(highlight): remove unnecessary assignment to char_attr for 'spell' (#23713) --- test/functional/ui/spell_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 15819aef40..0f553d4a9b 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -254,4 +254,19 @@ describe("'spell'", function() ]]) end) + it('and syntax does not clear extmark highlighting at the start of a word', function() + screen:try_resize(43, 3) + command([[ + set spell + syntax match Constant "^.*$" + call setline(1, "This is some text without any spell errors.") + ]]) + local ns = meths.create_namespace("spell") + curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) + screen:expect([[ + {6:^This is some text without any spell errors.}| + {0:~ }| + | + ]]) + end) end) -- cgit From cb34d0ddd086141d6afcb9c48eae180abbeffecc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 22 May 2023 18:22:47 +0800 Subject: fix(redraw): overwrite double-width char with virt_text properly (#23708) --- test/functional/ui/decorations_spec.lua | 76 +++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ccf1810ee1..e31361e74c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -704,14 +704,14 @@ end]] -- can "float" beyond end of line meths.buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- bound check: right edge of window - meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork '}, {'bork bork bork', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) -- empty virt_text should not change anything meths.buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | {2:|} local text, hl_id_cell, count = unpack(item) | - {2:|} if hl_id_cell ~= nil tbork bork bork {4:bork bork}| + {2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork}| {2:|} {1:|} hl_id = hl_id_cell | {2:|} end | {2:|} for _ = 1, (count or 1) {4:loopy} | @@ -726,7 +726,6 @@ end]] | ]]} - -- handles broken lines screen:try_resize(22, 25) screen:expect{grid=[[ @@ -736,7 +735,7 @@ end]] cell, count = unpack(i| tem) | {2:|} if hl_id_cell ~= n| - il tbork bork bork {4:bor}| + il tbork bork bork{4: bor}| {2:|} {1:|} hl_id = hl_id_| cell | {2:|} end | @@ -756,6 +755,75 @@ end]] {1:~ }| | ]]} + + -- truncating in the middle of a char leaves a space + meths.buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) + meths.buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) + meths.buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + screen:expect{grid=[[ + ^for _,item in ipairs(i| + tems) do -- {4:A}AA 古 | + {2:|} local text, hl_id_| + cell, count = unpack(i| + tem) | + {2:|} if hl_id_cell ~= n| + il tbork bork bork{4: bor}| + {2:|} {1:|} hl_id = hl_id_| + cell | + {2:|} end | + {2:|} for _ = 1, (count | + or 1) {4:loopy} | + {2:|} {1:|} local cell = l| + ine[colpos] | + {2:|} {1:|} cell.text = te| + xt | + {2:|} {1:|} cell.hl_id = h| + l_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpo| + s+1 | + end -- ???????{4:口 }| + end -- {4:口口} 古古{4:口口 }| + {1:~ }| + {1:~ }| + | + ]]} + + screen:try_resize(82, 13) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do -- {4:A}AA 古 | + {2:|} local text, hl_id_cell, count = unpack(item) | + {2:|} if hl_id_cell ~= nil tbork bork bork{4: bork bork bork bork bork bork bork bork b}| + {2:|} {1:|} hl_id = hl_id_cell | + {2:|} end | + {2:|} for _ = 1, (count or 1) {4:loopy} | + {2:|} {1:|} local cell = line[colpos] | + {2:|} {1:|} cell.text = text | + {2:|} {1:|} cell.hl_id = hl_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | + end -- ???????{4:口口口} | + end -- {4:口口} 古古{4:口口口} | + | + ]]} + + meths.buf_clear_namespace(0, ns, 0, -1) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do -- 古古古 | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end -- ?????????? | + end -- ?古古古古?古古 | + | + ]]} end) it('can have virtual text of overlay position and styling', function() -- cgit From efa9b299a7cb68909e9bcd290e4d12bcb6d0bb03 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:31:08 +1100 Subject: feat(ui): inline virtual text vim-patch:9.0.0067: cannot show virtual text Problem: Cannot show virtual text. Solution: Initial changes for virtual text support, using text properties. https://github.com/vim/vim/commit/7f9969c559b51446632ac7e8f76cde07e7d0078d vim-patch:9.0.0116: virtual text not displayed if 'signcolumn' is "yes" Problem: Virtual text not displayed if 'signcolumn' is "yes". Solution: Set c_extra and c_final to NUL. https://github.com/vim/vim/commit/711483cd1381a4ed848d783ae0a6792d5b04447b Co-authored-by: bfredl --- test/functional/ui/decorations_spec.lua | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ccf1810ee1..80dfebd33e 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -645,6 +645,7 @@ describe('extmark decorations', function() [25] = {background = Screen.colors.LightRed}; [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; [27] = {background = Screen.colors.Plum1}; + [28] = {foreground = Screen.colors.SlateBlue}; } ns = meths.create_namespace 'test' @@ -1166,6 +1167,84 @@ end]] screen:expect_unchanged(true) end) + it('can have virtual text of inline position', function() + insert(example_text) + feed 'gg' + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + {1:~ }| + | + ]]} + + meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{28:: }{3:string}, hl_id_cell, count = unpack| + (item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + | + ]]} + + screen:try_resize(55, 15) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{28:: }{3:string}, hl_id_cell, count = unpack(item| + ) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + | + ]]} + + screen:try_resize(56, 15) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{28:: }{3:string}, hl_id_cell, count = unpack(item)| + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From a38d7f99845d6ef566b2885737b892c660749d5e Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 19 Mar 2023 17:37:28 +1100 Subject: fix(ui): fix cursor position with multiple inline virtual text vim-patch9.0.0121: cannot put virtual text after or below a line Problem: Cannot put virtual text after or below a line. Solution: Add "text_align" and "text_wrap" arguments. https://github.com/vim/vim/commit/b7963df98f9dbbb824713acad2f47c9989fcf8f3 This only patches the fix, not the whole thing. --- test/functional/ui/decorations_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 80dfebd33e..d029a66301 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1245,6 +1245,33 @@ end]] | ]]} end) + + it('cursor positions are correct with multiple inline virtual text', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + feed '^' + feed '4l' + screen:expect { grid = [[ + 1234{28: virtual text virtual text }^5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 389f5ca39d278173dc0446dc339f7ac1ff573329 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 19 Mar 2023 18:50:45 +1100 Subject: fix(ui): adjust the cursor when inserting virtual text Credit to: Jesse Bakker https://github.com/neovim/neovim/pull/20130#issuecomment-1369652743 Co-authored-by: Jesse Bakker --- test/functional/ui/decorations_spec.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index d029a66301..94267e35c4 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1272,6 +1272,32 @@ end]] | ]]} end) + + it('adjusts cursor location correctly when inserting around inline virtual text', function() + insert('12345678') + feed '$' + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + + screen:expect { grid = [[ + 1234{28: virtual text }567^8 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]] + } + end) end) describe('decorations: virtual lines', function() -- cgit From 0c7fa3bdcc3761cc851ea0ac37bf692b990044cc Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:31:52 +1100 Subject: fix(ui): fix multi-byte characters highlight in virtual text This also fixes insert cursor position around virtual text vim-patch:9.0.0132: multi-byte characters in virtual text not handled correctly Problem: Multi-byte characters in virtual text not handled correctly. Solution: Count screen cells instead of bytes. https://github.com/vim/vim/commit/09ff4b54fb86a64390ba9c609853c6410ea6197c --- test/functional/ui/decorations_spec.lua | 84 ++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 7 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 94267e35c4..6e4b19c856 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1254,7 +1254,7 @@ end]] { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '4l' - screen:expect { grid = [[ + screen:expect { grid = [[ 1234{28: virtual text virtual text }^5678 | {1:~ }| {1:~ }| @@ -1274,12 +1274,12 @@ end]] end) it('adjusts cursor location correctly when inserting around inline virtual text', function() - insert('12345678') - feed '$' - meths.buf_set_extmark(0, ns, 0, 4, + insert('12345678') + feed '$' + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + screen:expect { grid = [[ 1234{28: virtual text }567^8 | {1:~ }| {1:~ }| @@ -1295,8 +1295,78 @@ end]] {1:~ }| {1:~ }| | - ]] - } + ]]} + end) + + it('has correct highlighting with multi-byte characters in inline virtual text', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + + screen:expect { grid = [[ + 1234{28:múlti-byté chñröcters 修补}567^8 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('has correct cursor position when inserting around virtual text', function() + insert('12345678') + meths.buf_set_extmark(0, ns, 0, 4, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed '^' + feed '3l' + feed 'a' + screen:expect { grid = [[ + 1234{28:^virtual text}5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {24:-- INSERT --} | + ]]} + feed '' + feed '^' + feed '4l' + feed 'i' + screen:expect { grid = [[ + 1234{28:^virtual text}5678 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {24:-- INSERT --} | + ]]} end) end) -- cgit From 8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 26 Mar 2023 00:10:28 +1100 Subject: vim-patch:9.0.0143: cursor positioned after virtual text in empty line Problem: Cursor positioned after virtual text in empty line. Solution: Keep cursor in the first column. (closes vim/vim#10786) https://github.com/vim/vim/commit/afd2aa79eda3fe69f2e7c87d0b9b4bca874f386a --- test/functional/ui/decorations_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6e4b19c856..a2b0138da3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1368,6 +1368,28 @@ end]] {24:-- INSERT --} | ]]} end) + + it('has correct cursor position with virtual text on an empty line', function() + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + {28:^virtual text} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 43c2eaada220d5e7d44fa9086655b00ee3e5fbb5 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 26 Mar 2023 14:49:09 +1100 Subject: vim-patch:9.0.0179: cursor pos wrong with wrapping virtual text in empty line Problem: Cursor position wrong with wrapping virtual text in empty line. Solution: Adjust handling of an empty line. (closes vim/vim#10875) https://github.com/vim/vim/commit/49a90792d950c51608d0459ef8699fe921070718 Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index a2b0138da3..635666c941 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1390,6 +1390,92 @@ end]] | ]]} end) + + it('text is drawn correctly when inserting a wrapping virtual text on an empty line', function() + feed('o') + insert([[aaaaaaa + +bbbbbbb]]) + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, + { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + feed('gg0') + screen:expect { grid = [[ + {28:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {28:X} | + aaaaaaa | + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {28:X} | + ^aaaaaaa | + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {28:X} | + aaaaaaa | + {28:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('j') + screen:expect { grid = [[ + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {28:X} | + aaaaaaa | + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + ^bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From dee3af2122d5072d351551ef023d2c177334b332 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:09:09 +1100 Subject: vim-patch:9.0.0178: cursor position wrong with virtual text before Tab Problem: Cursor position wrong with virtual text before Tab. Solution: Use the byte length, not the cell with, to compare the column. Correct tab size after text prop. (closes vim/vim#10866) https://github.com/vim/vim/commit/e428fa04a758cc87ea580c856a796e58e407504b Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 105 ++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 635666c941..91284e3a2f 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1476,6 +1476,111 @@ bbbbbbb]]) | ]]} end) + + it('cursor position is correct with virtual text attatched to hard tabs', function() + command('set noexpandtab') + feed('i') + feed('') + feed('') + feed('test') + feed('') + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('0') + screen:expect { grid = [[ + ^ {28:virtual text} test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {28:virtual text} ^ test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {28:virtual text} ^test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {28:virtual text} t^est | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('l') + screen:expect { grid = [[ + {28:virtual text} te^st | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From e12b5882af97126a9525a74a0955cc9e0f9114a9 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:40:07 +1100 Subject: vim-patch:9.0.0183: extra space after virtual text when 'linebreak' is set Problem: Extra space after virtual text when 'linebreak' is set. Solution: Do not count virtual text when getting linebreak value. (closes vim/vim#10884) https://github.com/vim/vim/commit/52de3a8d3943520bbd4e5e40a4c43fcc7182dac0 Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 91284e3a2f..4ed9d5a044 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1581,6 +1581,31 @@ bbbbbbb]]) | ]]} end) + + it('has correct cursor position with virtual text on an empty line', function() + command('set linebreak') + insert('one twoword') + feed('0') + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + ^one{28:: virtual text} twoword | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From c5bf838f8aa51709f8d7ee81cf2b2a6479c77ad7 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 27 Mar 2023 01:25:37 +1100 Subject: fix(ui): fix visual and search highlighting interfering with virtual text vim-patch:9.0.0193: search and match highlgith interfere with virtual text Problem: Search and match highlgith interfere with virtual text highlight. (Ben Jackson) Solution: Check for match highlight after text properties. Reset and restore search highlight when showing virtual text. (closes vim/vim#10892) https://github.com/vim/vim/commit/e38fc86180fd3f6b372648eea6adc3f623fea302 vim-patch:9.0.0452: Visual highlighting extends into virtual text prop Problem: Visual highlighting extends into virtual text prop. Solution: Do not highlight what isn't actually selected. Fix ordering of stored text props. https://github.com/vim/vim/commit/6eda17d881c9b2880ccb2a4d11951939a58f233d Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 92 ++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4ed9d5a044..fa492dfcac 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -646,6 +646,8 @@ describe('extmark decorations', function() [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; [27] = {background = Screen.colors.Plum1}; [28] = {foreground = Screen.colors.SlateBlue}; + [29] = {background = Screen.colors.Yellow1}; + [30] = {reverse = true}; } ns = meths.create_namespace 'test' @@ -1582,7 +1584,7 @@ bbbbbbb]]) ]]} end) - it('has correct cursor position with virtual text on an empty line', function() + it('cursor position is correct with virtual text on an empty line', function() command('set linebreak') insert('one twoword') feed('0') @@ -1606,6 +1608,94 @@ bbbbbbb]]) | ]]} end) + + it('search highlight is correct with virtual text attatched to', function() + insert('foo foo foo foo') + feed('0') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + ^foo foo {28:virtual text}foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('/foo') + screen:expect { grid = [[ + {29:foo} {30:foo} {28:virtual text}{29:foo} {29:foo} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /foo^ | + ]]} + end) + + it('visual select highlight is correct with virtual text attatched to', function() + insert('foo foo foo foo') + feed('0') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('8l') + screen:expect { grid = [[ + foo foo {28:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('v') + feed('2h') + screen:expect { grid = [[ + foo fo^o{18: }{28:virtual text}{18:f}oo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {24:-- VISUAL --} | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From be273c3a23cf65665e843cfb13fd5319657cc5c2 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:23:21 +1100 Subject: vim-patch:9.0.0205: cursor in wrong position when inserting after virtual text Problem: Cursor in wrong position when inserting after virtual text. (Ben Jackson) Solution: Put the cursor after the virtual text, where the text will be inserted. (closes vim/vim#10914) https://github.com/vim/vim/commit/28c9f895716cfa8f1220bc41b72a534c0e10cabe Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 47 ++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index fa492dfcac..de3f7e7a5b 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1652,11 +1652,12 @@ bbbbbbb]]) ]]} end) + feed('8l') it('visual select highlight is correct with virtual text attatched to', function() insert('foo foo foo foo') feed('0') meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('8l') screen:expect { grid = [[ foo foo {28:virtual text}^foo foo | @@ -1696,6 +1697,50 @@ bbbbbbb]]) {24:-- VISUAL --} | ]]} end) + + it('cursor position is correct when inserting around a virtual text with right gravity set to false', function() + insert('foo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('0') + feed('8l') + screen:expect { grid = [[ + foo foo {28:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('i') + screen:expect { grid = [[ + foo foo {28:virtual text}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {24:-- INSERT --} | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 1936285d98f62a1357abf928b10c824cf9e3ff41 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 3 Apr 2023 01:05:08 +1000 Subject: fix(ui): fixes incorrect rendering when virtual text is not visable and nowrap --- test/functional/ui/decorations_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index de3f7e7a5b..68c0e5eaca 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1741,6 +1741,33 @@ bbbbbbb]]) {24:-- INSERT --} | ]]} end) + + it('no wrap is rendered correctly with multiple virtual text, where one is hidden', function() + insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 50, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('$') + screen:expect { grid = [[ + opqrstuvwxyzabcdefghijklmnopqrstuvwx{28:virtual text}y^z| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 7423d3479d95e875e2d261d6e404ad19a631e530 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 3 Apr 2023 01:43:06 +1000 Subject: vim-patch:9.0.0716: with 'nowrap' virtual text "after" does not scroll left Problem: With 'nowrap' virtual text "after" does not scroll left. Solution: Skip part of the virtual text that is left of the window. (closes vim/vim#11320) Fix going beyond the last column of the window. https://github.com/vim/vim/commit/cd105417a53fcf97c0935f3468201ef11516c9f1 Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 68c0e5eaca..ba3f73c229 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1742,7 +1742,7 @@ bbbbbbb]]) ]]} end) - it('no wrap is rendered correctly with multiple virtual text, where one is hidden', function() + it('draws correctly with no wrap multiple virtual text, where one is hidden', function() insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") meths.buf_set_extmark(0, ns, 0, 50, @@ -1768,6 +1768,31 @@ bbbbbbb]]) | ]]} end) + + it('draws correctly with no wrap and a long virtual text', function() + insert('abcdefghi') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('$') + screen:expect { grid = [[ + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 5d7afb2e9f222c32dd18c9c2bca49cab8bf751bc Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:21:46 +1000 Subject: fix(ui): fix tabs not being spaced properly after virtual text with no wrap also fixes incorrect skipping of multibyte characters --- test/functional/ui/decorations_spec.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ba3f73c229..9be8c23ba4 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1793,6 +1793,31 @@ bbbbbbb]]) | ]]} end) + + it('tabs are the correct length with no wrap following virtual text', function() + command('set nowrap') + feed('itesta') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('gg$') + screen:expect { grid = [[ + {28:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From ecf225df574a48a4bbddf4978972b2b97184e92c Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 3 Apr 2023 20:46:50 +1000 Subject: vim-patch:9.0.0944: 'cursorline' causes virtual text highlight to continue Problem: 'cursorline' causes virtual text highlight to continue. Solution: Save and restore line_attr. (closes vim/vim#11588) https://github.com/vim/vim/commit/6ac16f0c0fe923098b9df5ac430f1923045f16ea Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9be8c23ba4..77748eecb3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1818,6 +1818,31 @@ bbbbbbb]]) | ]]} end) + + it('highlighting does not extend when no wrap is enabled with a long virtual text', function() + insert('abcdef') + command("set nowrap") + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('$') + screen:expect { grid = [[ + {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 332b70d2ed310084fe382affddbef3126c12751c Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:12:56 +1000 Subject: fix(ui): fix incorrect highlighting when virtual text wraps with number --- test/functional/ui/decorations_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 77748eecb3..2d0f3e7a17 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1843,6 +1843,33 @@ bbbbbbb]]) | ]]} end) + + it('highlighting is correct when virtual text wraps with number', function() + insert([[ + test + test]]) + command('set number') + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + feed('gg0') + screen:expect { grid = [[ + {2: 1 }^t{28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {2: }{28:XXXXXXXXXX}est | + {2: 2 }test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 75f350aac6cd952341d7ce88e64b0d6ed2aa694d Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Wed, 5 Apr 2023 00:29:05 +1000 Subject: fix(ui): fix incorrect highlighting when virtual text next to match --- test/functional/ui/decorations_spec.lua | 53 +++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 2d0f3e7a17..292743e21a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1746,9 +1746,9 @@ bbbbbbb]]) insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") meths.buf_set_extmark(0, ns, 0, 50, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 2, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ opqrstuvwxyzabcdefghijklmnopqrstuvwx{28:virtual text}y^z| @@ -1773,7 +1773,7 @@ bbbbbbb]]) insert('abcdefghi') command("set nowrap") meths.buf_set_extmark(0, ns, 0, 2, - { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| @@ -1823,7 +1823,7 @@ bbbbbbb]]) insert('abcdef') command("set nowrap") meths.buf_set_extmark(0, ns, 0, 3, - { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| @@ -1850,7 +1850,7 @@ bbbbbbb]]) test]]) command('set number') meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') screen:expect { grid = [[ {2: 1 }^t{28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -1870,6 +1870,49 @@ bbbbbbb]]) | ]]} end) + + it('highlighting is correct when virtual text is proceeded with a match', function() + insert([[test]]) + meths.buf_set_extmark(0, ns, 0, 2, + { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + feed('gg0') + command('match ErrorMsg /e/') + screen:expect { grid = [[ + ^t{4:e}{28:virtual text}st | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + command('match ErrorMsg /s/') + screen:expect { grid = [[ + ^te{28:virtual text}{4:s}t | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 5547b16c40f92fbc75ad1b9a7b3dd1f5ff50cbb2 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Mon, 3 Apr 2023 22:13:15 +1000 Subject: vim-patch:9.0.1067: in diff mode virtual text is highlighted incorrectly Problem: In diff mode virtual text is highlighted incorrectly. (Rick Howe) Solution: Do not use diff attributes for virtual text. (closes vim/vim#11714) https://github.com/vim/vim/commit/d097af77797f030e0f29f9bbc298358a5addb2a5 Co-authored-by: Bram Moolenaar --- test/functional/ui/decorations_spec.lua | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 292743e21a..4579fad53f 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -648,6 +648,9 @@ describe('extmark decorations', function() [28] = {foreground = Screen.colors.SlateBlue}; [29] = {background = Screen.colors.Yellow1}; [30] = {reverse = true}; + [31] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; + [32] = {bold = true, reverse = true}; + [33] = {background = Screen.colors.Red1, bold = true} } ns = meths.create_namespace 'test' @@ -1913,6 +1916,46 @@ bbbbbbb]]) | ]]} end) + + it('in diff mode virtual text is highlighted correct', function() + insert([[ + 9000 + 0009 + 0009 + 9000 + 0009 + ]]) + command("set diff") + meths.buf_set_extmark(0, ns, 0, 1, + { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + command("vnew") + insert([[ + 000 + 000 + 000 + 000 + 000 + ]]) + command("set diff") + feed('gg0') + screen:expect { grid = [[ + {27:^000 }│{33:9}{31:test}{27:000 }| + {27:000 }│{27:000}{33:9}{27: }| + {27:000 }│{27:000}{33:9}{27: }| + {27:000 }│{33:9}{27:000 }| + {27:000 }│{27:000}{33:9}{27: }| + │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {32:[No Name] [+] }{30:[No Name] [+] }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 34d862942c3387eaa9d2bba963d931d384031b90 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Wed, 19 Apr 2023 19:02:33 +1000 Subject: fix(ui): fix virtual text not displaying when two overlapping inlines (nowrap) --- test/functional/ui/decorations_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4579fad53f..68a5bb5f9a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1956,6 +1956,33 @@ bbbbbbb]]) | ]]} end) + + it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() + command('set nowrap') + insert('a') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) + feed('$') + screen:expect { grid = [[ + {28:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From a37c99048359c27bbb7e1997c2ec318bb2cba787 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Thu, 20 Apr 2023 02:15:49 +1000 Subject: fix(ui): fix overflowing nowrap virtual text not displaying if tab follows --- test/functional/ui/decorations_spec.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 68a5bb5f9a..f67c4be419 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1983,6 +1983,38 @@ bbbbbbb]]) | ]]} end) + + it('correctly draws when overflowing virtual text is followed by tab with no wrap', function() + command('set nowrap') + feed('itest') + meths.buf_set_extmark( + 0, + ns, + 0, + 0, + { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' } + ) + feed('0') + screen:expect({ + grid = [[ + {28:aaaaaaaaaaaaaaaaaaaaaa} ^ test | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], + }) + end) end) describe('decorations: virtual lines', function() -- cgit From a78fd18ed92d7474d10b5640dcf7a15728d2e03a Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 9 May 2023 14:26:03 +0200 Subject: fix(extmark): fix cursor position with both left and right gravity inline text --- test/functional/ui/decorations_spec.lua | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f67c4be419..e8847258f4 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1745,6 +1745,49 @@ bbbbbbb]]) ]]} end) + it('cursor position is correct when inserting around virtual texts with both left and right gravity ', function() + insert('foo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + feed('08l') + screen:expect{ grid = [[ + foo foo {28:>><<}^foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('i') + screen:expect { grid = [[ + foo foo {28:>>^<<}foo foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {24:-- INSERT --} | + ]]} + end) + it('draws correctly with no wrap multiple virtual text, where one is hidden', function() insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") -- cgit From c5528e7fd852939a5719ecc35edde89b41275a15 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 22 May 2023 12:15:41 +0200 Subject: fix(test): clean up inline virtual text tests a little --- test/functional/ui/decorations_spec.lua | 429 ++++++++++---------------------- 1 file changed, 137 insertions(+), 292 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e8847258f4..4418729859 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -611,6 +611,20 @@ describe('decorations providers', function() end) end) +local example_text = [[ +for _,item in ipairs(items) do + local text, hl_id_cell, count = unpack(item) + if hl_id_cell ~= nil then + hl_id = hl_id_cell + end + for _ = 1, (count or 1) do + local cell = line[colpos] + cell.text = text + cell.hl_id = hl_id + colpos = colpos+1 + end +end]] + describe('extmark decorations', function() local screen, ns before_each( function() @@ -645,31 +659,11 @@ describe('extmark decorations', function() [25] = {background = Screen.colors.LightRed}; [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; [27] = {background = Screen.colors.Plum1}; - [28] = {foreground = Screen.colors.SlateBlue}; - [29] = {background = Screen.colors.Yellow1}; - [30] = {reverse = true}; - [31] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; - [32] = {bold = true, reverse = true}; - [33] = {background = Screen.colors.Red1, bold = true} } ns = meths.create_namespace 'test' end) - local example_text = [[ -for _,item in ipairs(items) do - local text, hl_id_cell, count = unpack(item) - if hl_id_cell ~= nil then - hl_id = hl_id_cell - end - for _ = 1, (count or 1) do - local cell = line[colpos] - cell.text = text - cell.hl_id = hl_id - colpos = colpos+1 - end -end]] - it('empty virtual text at eol should not break colorcolumn #17860', function() insert(example_text) feed('gg') @@ -1171,8 +1165,38 @@ end]] meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) screen:expect_unchanged(true) end) +end) + - it('can have virtual text of inline position', function() +describe('decorations: inline virtual text', function() + local screen, ns + before_each( function() + clear() + screen = Screen.new(50, 10) + screen:attach() + screen:set_default_attr_ids { + [1] = {bold=true, foreground=Screen.colors.Blue}; + [2] = {foreground = Screen.colors.Brown}; + [3] = {bold = true, foreground = Screen.colors.SeaGreen}; + [4] = {background = Screen.colors.Red1, foreground = Screen.colors.Gray100}; + [5] = {background = Screen.colors.Red1, bold = true}; + [6] = {foreground = Screen.colors.DarkCyan}; + [7] = {background = Screen.colors.LightGrey}; + [8] = {bold = true}; + [9] = {background = Screen.colors.Plum1}; + [10] = {foreground = Screen.colors.SlateBlue}; + [11] = {blend = 30, background = Screen.colors.Red1}; + [12] = {background = Screen.colors.Yellow1}; + [13] = {reverse = true}; + [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; + [15] = {bold = true, reverse = true}; + } + + ns = meths.create_namespace 'test' + end) + + + it('works', function() insert(example_text) feed 'gg' screen:expect{grid=[[ @@ -1185,18 +1209,13 @@ end]] local cell = line[colpos] | cell.text = text | cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | - {1:~ }| - {1:~ }| | ]]} meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | - local text{28:: }{3:string}, hl_id_cell, count = unpack| + local text{10:: }{3:string}, hl_id_cell, count = unpack| (item) | if hl_id_cell ~= nil then | hl_id = hl_id_cell | @@ -1204,18 +1223,13 @@ end]] for _ = 1, (count or 1) do | local cell = line[colpos] | cell.text = text | - cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | - {1:~ }| | ]]} - screen:try_resize(55, 15) + screen:try_resize(55, 10) screen:expect{grid=[[ ^for _,item in ipairs(items) do | - local text{28:: }{3:string}, hl_id_cell, count = unpack(item| + local text{10:: }{3:string}, hl_id_cell, count = unpack(item| ) | if hl_id_cell ~= nil then | hl_id = hl_id_cell | @@ -1223,18 +1237,13 @@ end]] for _ = 1, (count or 1) do | local cell = line[colpos] | cell.text = text | - cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | - {1:~ }| | ]]} - screen:try_resize(56, 15) + screen:try_resize(56, 10) screen:expect{grid=[[ ^for _,item in ipairs(items) do | - local text{28:: }{3:string}, hl_id_cell, count = unpack(item)| + local text{10:: }{3:string}, hl_id_cell, count = unpack(item)| if hl_id_cell ~= nil then | hl_id = hl_id_cell | end | @@ -1242,11 +1251,6 @@ end]] local cell = line[colpos] | cell.text = text | cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | - {1:~ }| - {1:~ }| | ]]} end) @@ -1260,12 +1264,7 @@ end]] feed '^' feed '4l' screen:expect { grid = [[ - 1234{28: virtual text virtual text }^5678 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + 1234{10: virtual text virtual text }^5678 | {1:~ }| {1:~ }| {1:~ }| @@ -1285,12 +1284,7 @@ end]] { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) screen:expect { grid = [[ - 1234{28: virtual text }567^8 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + 1234{10: virtual text }567^8 | {1:~ }| {1:~ }| {1:~ }| @@ -1303,18 +1297,13 @@ end]] ]]} end) - it('has correct highlighting with multi-byte characters in inline virtual text', function() + it('has correct highlighting with multi-byte characters', function() insert('12345678') meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) screen:expect { grid = [[ - 1234{28:múlti-byté chñröcters 修补}567^8 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + 1234{10:múlti-byté chñröcters 修补}567^8 | {1:~ }| {1:~ }| {1:~ }| @@ -1335,7 +1324,7 @@ end]] feed '3l' feed 'a' screen:expect { grid = [[ - 1234{28:^virtual text}5678 | + 1234{10:^virtual text}5678 | {1:~ }| {1:~ }| {1:~ }| @@ -1344,23 +1333,26 @@ end]] {1:~ }| {1:~ }| {1:~ }| + {8:-- INSERT --} | + ]]} + feed '' + screen:expect{grid=[[ + 123^4{10:virtual text}5678 | + {1:~ }| {1:~ }| {1:~ }| {1:~ }| {1:~ }| {1:~ }| - {24:-- INSERT --} | - ]]} - feed '' + {1:~ }| + {1:~ }| + | + ]]} feed '^' feed '4l' feed 'i' screen:expect { grid = [[ - 1234{28:^virtual text}5678 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + 1234{10:^virtual text}5678 | {1:~ }| {1:~ }| {1:~ }| @@ -1369,8 +1361,7 @@ end]] {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {24:-- INSERT --} | + {8:-- INSERT --} | ]]} end) @@ -1378,12 +1369,7 @@ end]] meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect { grid = [[ - {28:^virtual text} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:^virtual text} | {1:~ }| {1:~ }| {1:~ }| @@ -1407,82 +1393,62 @@ bbbbbbb]]) { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') screen:expect { grid = [[ - {28:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {28:X} | + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | aaaaaaa | - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} feed('j') screen:expect { grid = [[ - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {28:X} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | ^aaaaaaa | - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} feed('j') screen:expect { grid = [[ - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {28:X} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | aaaaaaa | - {28:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} feed('j') screen:expect { grid = [[ - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {28:X} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | aaaaaaa | - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| ^bbbbbbb | {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} end) - it('cursor position is correct with virtual text attatched to hard tabs', function() + it('cursor position is correct with virtual text attached to hard tabs', function() command('set noexpandtab') feed('i') feed('') @@ -1493,12 +1459,7 @@ bbbbbbb]]) { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('0') screen:expect { grid = [[ - ^ {28:virtual text} test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ^ {10:virtual text} test | {1:~ }| {1:~ }| {1:~ }| @@ -1512,12 +1473,7 @@ bbbbbbb]]) feed('l') screen:expect { grid = [[ - {28:virtual text} ^ test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:virtual text} ^ test | {1:~ }| {1:~ }| {1:~ }| @@ -1531,12 +1487,7 @@ bbbbbbb]]) feed('l') screen:expect { grid = [[ - {28:virtual text} ^test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:virtual text} ^test | {1:~ }| {1:~ }| {1:~ }| @@ -1550,12 +1501,7 @@ bbbbbbb]]) feed('l') screen:expect { grid = [[ - {28:virtual text} t^est | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:virtual text} t^est | {1:~ }| {1:~ }| {1:~ }| @@ -1569,12 +1515,7 @@ bbbbbbb]]) feed('l') screen:expect { grid = [[ - {28:virtual text} te^st | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:virtual text} te^st | {1:~ }| {1:~ }| {1:~ }| @@ -1594,12 +1535,7 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect { grid = [[ - ^one{28:: virtual text} twoword | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ^one{10:: virtual text} twoword | {1:~ }| {1:~ }| {1:~ }| @@ -1612,18 +1548,13 @@ bbbbbbb]]) ]]} end) - it('search highlight is correct with virtual text attatched to', function() + it('search highlight is correct', function() insert('foo foo foo foo') feed('0') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect { grid = [[ - ^foo foo {28:virtual text}foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ^foo foo {10:virtual text}foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1637,12 +1568,7 @@ bbbbbbb]]) feed('/foo') screen:expect { grid = [[ - {29:foo} {30:foo} {28:virtual text}{29:foo} {29:foo} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {12:foo} {13:foo} {10:virtual text}{12:foo} {12:foo} | {1:~ }| {1:~ }| {1:~ }| @@ -1655,20 +1581,14 @@ bbbbbbb]]) ]]} end) - feed('8l') - it('visual select highlight is correct with virtual text attatched to', function() + it('visual select highlight is correct', function() insert('foo foo foo foo') feed('0') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('8l') screen:expect { grid = [[ - foo foo {28:virtual text}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + foo foo {10:virtual text}^foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1683,10 +1603,7 @@ bbbbbbb]]) feed('v') feed('2h') screen:expect { grid = [[ - foo fo^o{18: }{28:virtual text}{18:f}oo foo | - {1:~ }| - {1:~ }| - {1:~ }| + foo fo^o{7: }{10:virtual text}{7:f}oo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1695,9 +1612,7 @@ bbbbbbb]]) {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {24:-- VISUAL --} | + {8:-- VISUAL --} | ]]} end) @@ -1708,12 +1623,7 @@ bbbbbbb]]) feed('0') feed('8l') screen:expect { grid = [[ - foo foo {28:virtual text}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + foo foo {10:virtual text}^foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1727,12 +1637,7 @@ bbbbbbb]]) feed('i') screen:expect { grid = [[ - foo foo {28:virtual text}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + foo foo {10:virtual text}^foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1741,7 +1646,7 @@ bbbbbbb]]) {1:~ }| {1:~ }| {1:~ }| - {24:-- INSERT --} | + {8:-- INSERT --} | ]]} end) @@ -1751,12 +1656,7 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) feed('08l') screen:expect{ grid = [[ - foo foo {28:>><<}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + foo foo {10:>><<}^foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1770,10 +1670,7 @@ bbbbbbb]]) feed('i') screen:expect { grid = [[ - foo foo {28:>>^<<}foo foo | - {1:~ }| - {1:~ }| - {1:~ }| + foo foo {10:>>^<<}foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -1782,9 +1679,7 @@ bbbbbbb]]) {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {24:-- INSERT --} | + {8:-- INSERT --} | ]]} end) @@ -1797,12 +1692,7 @@ bbbbbbb]]) { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ - opqrstuvwxyzabcdefghijklmnopqrstuvwx{28:virtual text}y^z| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| {1:~ }| {1:~ }| {1:~ }| @@ -1822,12 +1712,7 @@ bbbbbbb]]) { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| {1:~ }| {1:~ }| {1:~ }| @@ -1847,12 +1732,7 @@ bbbbbbb]]) { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg$') screen:expect { grid = [[ - {28:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | {1:~ }| {1:~ }| {1:~ }| @@ -1872,12 +1752,7 @@ bbbbbbb]]) { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ - {28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| {1:~ }| {1:~ }| {1:~ }| @@ -1899,19 +1774,14 @@ bbbbbbb]]) { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') screen:expect { grid = [[ - {2: 1 }^t{28:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {2: }{28:XXXXXXXXXX}est | + {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {2: }{10:XXXXXXXXXX}est | {2: 2 }test | {1:~ }| {1:~ }| {1:~ }| {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} @@ -1924,12 +1794,7 @@ bbbbbbb]]) feed('gg0') command('match ErrorMsg /e/') screen:expect { grid = [[ - ^t{4:e}{28:virtual text}st | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ^t{4:e}{10:virtual text}st | {1:~ }| {1:~ }| {1:~ }| @@ -1942,12 +1807,7 @@ bbbbbbb]]) ]]} command('match ErrorMsg /s/') screen:expect { grid = [[ - ^te{28:virtual text}{4:s}t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ^te{10:virtual text}{4:s}t | {1:~ }| {1:~ }| {1:~ }| @@ -1960,7 +1820,7 @@ bbbbbbb]]) ]]} end) - it('in diff mode virtual text is highlighted correct', function() + it('in diff mode is highlighted correct', function() insert([[ 9000 0009 @@ -1982,20 +1842,15 @@ bbbbbbb]]) command("set diff") feed('gg0') screen:expect { grid = [[ - {27:^000 }│{33:9}{31:test}{27:000 }| - {27:000 }│{27:000}{33:9}{27: }| - {27:000 }│{27:000}{33:9}{27: }| - {27:000 }│{33:9}{27:000 }| - {27:000 }│{27:000}{33:9}{27: }| + {9:^000 }│{5:9}{14:test}{9:000 }| + {9:000 }│{9:000}{5:9}{9: }| + {9:000 }│{9:000}{5:9}{9: }| + {9:000 }│{5:9}{9:000 }| + {9:000 }│{9:000}{5:9}{9: }| │ | {1:~ }│{1:~ }| {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {32:[No Name] [+] }{30:[No Name] [+] }| + {15:[No Name] [+] }{13:[No Name] [+] }| | ]]} end) @@ -2009,12 +1864,7 @@ bbbbbbb]]) { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect { grid = [[ - {28:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | {1:~ }| {1:~ }| {1:~ }| @@ -2040,12 +1890,7 @@ bbbbbbb]]) feed('0') screen:expect({ grid = [[ - {28:aaaaaaaaaaaaaaaaaaaaaa} ^ test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | {1:~ }| {1:~ }| {1:~ }| @@ -2081,7 +1926,7 @@ describe('decorations: virtual lines', function() ns = meths.create_namespace 'test' end) - local example_text = [[ + local example_text2 = [[ if (h->n_buckets < new_n_buckets) { // expand khkey_t *new_keys = (khkey_t *)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); h->keys = new_keys; @@ -2092,7 +1937,7 @@ if (h->n_buckets < new_n_buckets) { // expand }]] it('works with one line', function() - insert(example_text) + insert(example_text2) feed 'gg' meths.buf_set_extmark(0, ns, 1, 33, { virt_lines={ {{">> ", "NonText"}, {"krealloc", "Identifier"}, {": change the size of an allocation"}}}; @@ -2201,7 +2046,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with text at the beginning of the buffer', function() - insert(example_text) + insert(example_text2) feed 'gg' screen:expect{grid=[[ @@ -2262,7 +2107,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with text at the end of the buffer', function() - insert(example_text) + insert(example_text2) feed 'G' screen:expect{grid=[[ @@ -2381,7 +2226,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works beyond end of the buffer with virt_lines_above', function() - insert(example_text) + insert(example_text2) feed 'G' screen:expect{grid=[[ @@ -2652,7 +2497,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('works with sign and numbercolumns', function() - insert(example_text) + insert(example_text2) feed 'gg' command 'set number signcolumn=yes' screen:expect{grid=[[ @@ -2718,7 +2563,7 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with hard tabs', function() - insert(example_text) + insert(example_text2) feed 'gg' meths.buf_set_extmark(0, ns, 1, 0, { virt_lines={ {{">>", "NonText"}, {"\tvery\ttabby", "Identifier"}, {"text\twith\ttabs"}}}; @@ -2805,7 +2650,7 @@ describe('decorations: signs', function() meths.set_option_value('signcolumn', 'auto:9', {}) end) - local example_text = [[ + local example_test3 = [[ l1 l2 l3 @@ -2814,7 +2659,7 @@ l5 ]] it('can add a single sign (no end row)', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) @@ -2835,7 +2680,7 @@ l5 end) it('can add a single sign (with end row)', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) @@ -2857,7 +2702,7 @@ l5 it('can add multiple signs (single extmark)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) @@ -2879,7 +2724,7 @@ l5 it('can add multiple signs (multiple extmarks)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) @@ -2901,7 +2746,7 @@ l5 end) it('can add multiple signs (multiple extmarks) 2', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) @@ -2941,7 +2786,7 @@ l5 it('can add multiple signs (multiple extmarks) 3', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) @@ -2962,7 +2807,7 @@ l5 end) it('can add multiple signs (multiple extmarks) 4', function() - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) @@ -2983,7 +2828,7 @@ l5 end) it('works with old signs', function() - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=x') @@ -3010,7 +2855,7 @@ l5 it('works with old signs (with range)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=x') @@ -3039,7 +2884,7 @@ l5 it('can add a ranged sign (with start out of view)', function() pending('TODO(lewis6991): Support ranged signs') - insert(example_text) + insert(example_test3) command 'set signcolumn=yes:2' feed 'gg' feed '2' @@ -3096,7 +2941,7 @@ l5 it('works with priority #19716', function() screen:try_resize(20, 3) - insert(example_text) + insert(example_test3) feed 'gg' helpers.command('sign define Oldsign text=O3') @@ -3126,7 +2971,7 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) meths.set_option_value('signcolumn', 'auto', {}) - insert(example_text) + insert(example_test3) feed 'gg' meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) screen:expect{grid=[[ -- cgit From 678548a2b44601db73cc7d049467abd2b433baae Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 24 May 2023 21:25:39 +0800 Subject: fix(folds): show Folded highlight in Visual selection (#23741) Note: CursorLine highlight is now combined with Folded. --- test/functional/ui/fold_spec.lua | 65 +++++++++++++++++++++++++++++--- test/functional/ui/statuscolumn_spec.lua | 18 +++++---- 2 files changed, 69 insertions(+), 14 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 7a0495f93c..2afe27ecc7 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -42,7 +42,9 @@ describe("folded lines", function() [9] = {bold = true, foreground = Screen.colors.Brown}, [10] = {background = Screen.colors.LightGrey, underline = true}, [11] = {bold=true}, - [12] = {background = Screen.colors.Grey90}, + [12] = {background = Screen.colors.Grey90, underline = true}, + [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, + [14] = {background = Screen.colors.LightGray}, }) end) @@ -86,9 +88,10 @@ describe("folded lines", function() end end) - it("highlights with CursorLineFold when 'cursorline' is set", function() + it("foldcolumn highlighted with CursorLineFold when 'cursorline' is set", function() command("set number cursorline foldcolumn=2") command("hi link CursorLineFold Search") + command("hi! CursorLine gui=underline guibg=Grey90") insert(content1) feed("ggzf3jj") if multigrid then @@ -138,7 +141,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}| + {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| {7: }{8: 5 }in his cave. | {7: }{8: 6 } | {1:~ }| @@ -150,7 +153,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {6:+ }{9: 1 }{12:^+-- 4 lines: This is a················}| + {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| {7: }{8: 5 }in his cave. | {7: }{8: 6 } | {1:~ }| @@ -179,7 +182,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}| + {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| {7: }{8: 5 }in his cave. | {7: }{8: 6 } | {1:~ }| @@ -191,7 +194,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {7:+ }{8: 1 }{12:^+-- 4 lines: This is a················}| + {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| {7: }{8: 5 }in his cave. | {7: }{8: 6 } | {1:~ }| @@ -2013,6 +2016,56 @@ describe("folded lines", function() ]]) end end) + + it('Folded highlight does not disappear in Visual selection #19691', function() + insert([[ + " foo + " {{{1 + set nocp + " }}}1 + " bar + " {{{1 + set foldmethod=marker + " }}}1 + " baz]]) + feed('gg') + command('source') + feed('G3l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {14:" fo}o | + {5:+-- 3 lines: "······························}| + {14:" ba}r | + {5:+-- 3 lines: "······························}| + {14:" b}^az | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + {14:" fo}o | + {5:+-- 3 lines: "······························}| + {14:" ba}r | + {5:+-- 3 lines: "······························}| + {14:" b}^az | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + end) end describe("with ext_multigrid", function() diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 3d68246ba9..f349b182c9 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -196,8 +196,10 @@ describe('statuscolumn', function() [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey}, [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, [4] = {bold = true, foreground = Screen.colors.Brown}, - [5] = {background = Screen.colors.Grey90}, + [5] = {background = Screen.colors.Grey90, underline = true}, + [6] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, }) + command('hi! CursorLine gui=underline guibg=Grey90') screen:expect([[ {1: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1: │ }a | @@ -214,7 +216,7 @@ describe('statuscolumn', function() {1:10│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{0:@@@}| | ]]) - command("set stc=%C%s%=%l│\\ ") + command([[set stc=%C%s%=%l│\ ]]) screen:expect_unchanged() command('set signcolumn=auto:2 foldcolumn=auto') command('sign define piet1 text=>> texthl=LineNr') @@ -268,7 +270,7 @@ describe('statuscolumn', function() {2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: 7│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | - {2:+}{4: 8│}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2:+}{4: 8│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{1: 9│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | {2: }{1:10│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -286,7 +288,7 @@ describe('statuscolumn', function() {2: }{1: 6│}{2: }{1: }aaaaaa | {2: }{1: 7│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 7│}{2: }{1: }aaaaaa | - {2:+}{4: 8│}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2:+}{4: 8│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{1: 9│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 9│}{2: }{1: }aaaaaa | {2: }{1:10│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -304,7 +306,7 @@ describe('statuscolumn', function() {2: }{1: 2│}{2: }{1: }aaaaaa | {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaa | - {2:+}{4: 0│}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: 1│}{2: }{1: }aaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -321,7 +323,7 @@ describe('statuscolumn', function() {2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | - {2:+}{4: 0│}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -346,7 +348,7 @@ describe('statuscolumn', function() {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | - {2:+}{4: 0│}{2: }{4: }{5:^+-- 1 line: aaaaaaaaaaaaaaaaa}| + {2:+}{4: 0│}{2: }{4: }{6:^+-- 1 line: aaaaaaaaaaaaaaaaa}| {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -372,7 +374,7 @@ describe('statuscolumn', function() {1:wrapped 1 6}aaaaaaaa | {1:buffer 0 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 7}aaaaaaaa | - {4:buffer 0 8}{5:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:buffer 0 8}{6:^+-- 1 line: aaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {1:buffer 0 9}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 9}aaaaaaaa | | -- cgit From bff67c9fbe8c174dae8952a565a110930dc4fc58 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 19:50:01 +0200 Subject: vim-patch:9.0.0175: spell checking for capital not working with trailing space Problem: Spell checking for capital not working with trailing space. Solution: Do not calculate cap_col at the end of the line. (Christian Brabandt, closes vim/vim#10870, issue vim/vim#10838) https://github.com/vim/vim/commit/afa23d1b99692e3c726eb694933ab348b442a1e4 Co-authored-by: Christian Brabandt --- test/functional/ui/spell_spec.lua | 83 ++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 28 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 0f553d4a9b..c5c4ec3b99 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -3,9 +3,9 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear +local exec = helpers.exec local feed = helpers.feed local insert = helpers.insert -local command = helpers.command local meths = helpers.meths local curbufmeths = helpers.curbufmeths local is_os = helpers.is_os @@ -32,7 +32,7 @@ describe("'spell'", function() it('joins long lines #7937', function() if is_os('openbsd') then pending('FIXME #12104', function() end) return end - command('set spell') + exec('set spell') insert([[ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, @@ -57,31 +57,58 @@ describe("'spell'", function() -- oldtest: Test_spell_screendump() it('has correct highlight at start of line', function() - insert([[ - "This is some text without any spell errors. Everything", - "should just be black, nothing wrong here.", - "", - "This line has a sepll error. and missing caps.", - "And and this is the the duplication.", - "with missing caps here.", + exec([=[ + call setline(1, [ + \"This is some text without any spell errors. Everything", + \"should just be black, nothing wrong here.", + \"", + \"This line has a sepll error. and missing caps.", + \"And and this is the the duplication.", + \"with missing caps here.", + \]) + set spell spelllang=en_nz + ]=]) + screen:expect([[ + ^This is some text without any spell errors. Everything | + should just be black, nothing wrong here. | + | + This line has a {1:sepll} error. {2:and} missing caps. | + {1:And and} this is {1:the the} duplication. | + {2:with} missing caps here. | + {0:~ }| + | ]]) - command('set spell spelllang=en_nz') + end) + + -- oldtest: Test_spell_screendump_spellcap() + it('has correct highlight at start of line with trailing space', function() + exec([=[ + call setline(1, [ + \" This line has a sepll error. and missing caps and trailing spaces. ", + \"another missing cap here.", + \"", + \"and here.", + \" ", + \"and here." + \]) + set spell spelllang=en + ]=]) screen:expect([[ - "This is some text without any spell errors. Everything", | - "should just be black, nothing wrong here.", | - "", | - "This line has a {1:sepll} error. {2:and} missing caps.", | - "{1:And and} this is {1:the the} duplication.", | - "with missing caps here.", | - ^ | - | + ^ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + | + {2:and} here. | + | + {2:and} here. | + {0:~ }| + | ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() - command('set filetype=c') - command('syntax on') - command('set spell') + exec('set filetype=c') + exec('syntax on') + exec('set spell') insert([[ #include bool func(void); @@ -119,7 +146,7 @@ describe("'spell'", function() {0:~ }| {6:search hit BOTTOM, continuing at TOP} | ]]) - command('echo ""') + exec('echo ""') local ns = meths.create_namespace("spell") -- extmark with spell=true enables spell local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) @@ -168,7 +195,7 @@ describe("'spell'", function() {0:~ }| {6:search hit TOP, continuing at BOTTOM} | ]]) - command('echo ""') + exec('echo ""') curbufmeths.del_extmark(ns, id) screen:expect([[ {3:#include }{4:} | @@ -192,7 +219,7 @@ describe("'spell'", function() | ]]) -- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled - command('set spelloptions+=noplainbuffer') + exec('set spelloptions+=noplainbuffer') screen:expect_unchanged() feed('[s') screen:expect([[ @@ -206,7 +233,7 @@ describe("'spell'", function() | ]]) -- no spellchecking with "noplainbuffer" and syntax disabled - command('syntax off') + exec('syntax off') screen:expect([[ #include | bool func(void); | @@ -228,9 +255,9 @@ describe("'spell'", function() {0:~ }| {6:search hit BOTTOM, continuing at TOP} | ]]) - command('echo ""') + exec('echo ""') -- everything is spellchecked without "noplainbuffer" with syntax disabled - command('set spelloptions&') + exec('set spelloptions&') screen:expect([[ #include <{1:stdbool}.h> | {1:bool} {1:func}(void); | @@ -256,7 +283,7 @@ describe("'spell'", function() it('and syntax does not clear extmark highlighting at the start of a word', function() screen:try_resize(43, 3) - command([[ + exec([[ set spell syntax match Constant "^.*$" call setline(1, "This is some text without any spell errors.") -- cgit From ad7cded1f3f40912d962796d6965dac17ecb97f0 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:13:11 +0200 Subject: vim-patch:9.0.0590: after exiting Insert mode spelling not checked in next line Problem: After exiting Insert mode spelling is not checked in the next line. Solution: When spelling is enabled redraw the next line after exiting Insert mode in case the spell highlight needs updating. https://github.com/vim/vim/commit/ee09fcc9b6cf24e02899461809da9a5148208ea5 Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index c5c4ec3b99..5cfb85e431 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -103,6 +103,18 @@ describe("'spell'", function() {0:~ }| | ]]) + -- After adding word missing Cap in next line is updated + feed('3GANot') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + No^t | + and here. | + | + {2:and} here. | + {0:~ }| + | + ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() -- cgit From d2dc7cfa5b930a1ff68426f3d47809508ac7d392 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:26:03 +0200 Subject: vim-patch:9.0.0608: with spelling, deleting a full stop does not update next line Problem: With spell checking, deleting a full stop at the end of a line does not update SpellCap at the start of the next line. Solution: Update the next line when characters have been deleted. Also when using undo. https://github.com/vim/vim/commit/26f09ea54b2c60abf21df42c60bdfc60eca17b0d Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 5cfb85e431..800043b169 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -115,6 +115,30 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Deleting a full stop removes missing Cap in next line + feed('5Gddk$x') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + and her^e | + and here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Undo also updates the next line (go to command line to remove message) + feed('u:') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + and here^. | + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) end) it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() -- cgit From 50efdd6ccf1891392c048b92da5e5d123a30ff26 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 24 May 2023 20:41:58 +0200 Subject: vim-patch:9.0.0664: bad redrawing with spell checking, using "C" and "$" in 'cpo' Problem: Bad redrawing with spell checking, using "C" and "$" in 'cpo'. Solution: Do not redraw the next line when "$" is in 'cpo'. (closes vim/vim#11285) https://github.com/vim/vim/commit/f3ef026c9897f1d2e3fba47166a4771d507dae91 Co-authored-by: Bram Moolenaar --- test/functional/ui/spell_spec.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 800043b169..7f11b06f78 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -27,6 +27,7 @@ describe("'spell'", function() [6] = {foreground = Screen.colors.Red}, [7] = {foreground = Screen.colors.Blue}, [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, + [9] = {bold = true}, }) end) @@ -141,6 +142,40 @@ describe("'spell'", function() ]]) end) + -- oldtest: Test_spell_compatible() + it([[redraws properly when using "C" and "$" is in 'cpo']], function() + exec([=[ + call setline(1, [ + \ "test "->repeat(20), + \ "", + \ "end", + \ ]) + set spell cpo+=$ + ]=]) + feed('51|C') + screen:expect([[ + {2:test} test test test test test test test test test ^test test test test test test | + test test test test$ | + | + {2:end} | + {0:~ }| + {0:~ }| + {0:~ }| + {9:-- INSERT --} | + ]]) + feed('x') + screen:expect([[ + {2:test} test test test test test test test test test x^est test test test test test | + test test test test$ | + | + {2:end} | + {0:~ }| + {0:~ }| + {0:~ }| + {9:-- INSERT --} | + ]]) + end) + it('extmarks, "noplainbuffer" and syntax #20385 #23398', function() exec('set filetype=c') exec('syntax on') -- cgit From ee986ee0449b828ca64bf7d4c69624596aab8319 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 25 May 2023 22:14:12 +0800 Subject: fix(folds): combined Folded and Visual highlights (#23752) Also combine high-priority CursorLine with Folded. --- test/functional/ui/decorations_spec.lua | 39 ++++++++++++++++++++++++++++++-- test/functional/ui/fold_spec.lua | 37 ++++++++++++++++++++++-------- test/functional/ui/statuscolumn_spec.lua | 6 ++--- 3 files changed, 67 insertions(+), 15 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e430865df6..b301ed8353 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -10,6 +10,7 @@ local expect_events = helpers.expect_events local meths = helpers.meths local curbufmeths = helpers.curbufmeths local command = helpers.command +local assert_alive = helpers.assert_alive describe('decorations providers', function() local screen @@ -80,7 +81,7 @@ describe('decorations providers', function() local ns2 = api.nvim_create_namespace "ns2" api.nvim_set_decoration_provider(ns2, {}) ]]) - helpers.assert_alive() + assert_alive() end) it('leave a trace', function() @@ -1092,7 +1093,7 @@ describe('extmark decorations', function() {1:~ }| | ]]} - helpers.assert_alive() + assert_alive() end) it('conceal #19007', function() @@ -1258,6 +1259,9 @@ describe('decorations: inline virtual text', function() [13] = {reverse = true}; [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; [15] = {bold = true, reverse = true}; + [16] = {foreground = Screen.colors.Red}; + [17] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}; + [18] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Red}; } ns = meths.create_namespace 'test' @@ -1971,6 +1975,37 @@ bbbbbbb]]) ]], }) end) + + it('does not crash at column 0 when folded in a wide window', function() + screen:try_resize(82, 4) + command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') + command('set cursorline') + insert([[ + aaaaa + bbbbb + ccccc]]) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + fooaaaaa | + bbbbb | + {16:cccc^c }| + | + ]]} + command('1,2fold') + screen:expect{grid=[[ + {17:+-- 2 lines: aaaaa·······························································}| + {16:cccc^c }| + {1:~ }| + | + ]]} + feed('k') + screen:expect{grid=[[ + {18:^+-- 2 lines: aaaaa·······························································}| + ccccc | + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 2afe27ecc7..520979a2c2 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -42,9 +42,10 @@ describe("folded lines", function() [9] = {bold = true, foreground = Screen.colors.Brown}, [10] = {background = Screen.colors.LightGrey, underline = true}, [11] = {bold=true}, - [12] = {background = Screen.colors.Grey90, underline = true}, - [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, - [14] = {background = Screen.colors.LightGray}, + [12] = {foreground = Screen.colors.Red}, + [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, + [14] = {background = Screen.colors.Red}, + [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red}, }) end) @@ -88,10 +89,9 @@ describe("folded lines", function() end end) - it("foldcolumn highlighted with CursorLineFold when 'cursorline' is set", function() + local function test_folded_cursorline() command("set number cursorline foldcolumn=2") command("hi link CursorLineFold Search") - command("hi! CursorLine gui=underline guibg=Grey90") insert(content1) feed("ggzf3jj") if multigrid then @@ -239,6 +239,22 @@ describe("folded lines", function() | ]]) end + end + + describe("when 'cursorline' is set", function() + it('with high-priority CursorLine', function() + command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") + test_folded_cursorline() + end) + + it('with low-priority CursorLine', function() + command("hi! CursorLine guibg=NONE guifg=NONE gui=underline") + local attrs = screen:get_default_attr_ids() + attrs[12] = {underline = true} + attrs[13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true} + screen:set_default_attr_ids(attrs) + test_folded_cursorline() + end) end) it("work with spell", function() @@ -2017,7 +2033,8 @@ describe("folded lines", function() end end) - it('Folded highlight does not disappear in Visual selection #19691', function() + it('Folded and Visual highlights are combined #19691', function() + command('hi! Visual guibg=Red') insert([[ " foo " {{{1 @@ -2044,9 +2061,9 @@ describe("folded lines", function() [3:---------------------------------------------]| ## grid 2 {14:" fo}o | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" ba}r | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" b}^az | {1:~ }| {1:~ }| @@ -2056,9 +2073,9 @@ describe("folded lines", function() else screen:expect([[ {14:" fo}o | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" ba}r | - {5:+-- 3 lines: "······························}| + {15:+-- }{5: 3 lines: "······························}| {14:" b}^az | {1:~ }| {1:~ }| diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index f349b182c9..c218bd8fd6 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -196,10 +196,10 @@ describe('statuscolumn', function() [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey}, [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, [4] = {bold = true, foreground = Screen.colors.Brown}, - [5] = {background = Screen.colors.Grey90, underline = true}, - [6] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true}, + [5] = {foreground = Screen.colors.Red}, + [6] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, }) - command('hi! CursorLine gui=underline guibg=Grey90') + command('hi! CursorLine guifg=Red guibg=NONE') screen:expect([[ {1: 4│ }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1: │ }a | -- cgit From 455bca1ba86a2524251fea6f79ef668c1e38f6aa Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 24 May 2023 14:33:09 +0200 Subject: fix(drawline): combine extmark highligh with area hl correctly fixes #23734 Get rid of the weird attr_pri dance which always seemed like a kludge: if (!attr_pri) { wlv.char_attr = hl_combine_attr(wlv.char_attr, extmark_attr); } else { wlv.char_attr = hl_combine_attr(extmark_attr, wlv.char_attr); } Instead combine extmark attrs with (old-skool) syntax attrs in a consistent way and then combine that with attr_pri and the rest in an _unified_ code path fixes #23722 Co-authored-by: luukvbaal Co-authored-by: zeertzjq --- test/functional/ui/decorations_spec.lua | 49 ++++++++++++++++++++++++++++++++- test/functional/ui/highlight_spec.lua | 35 +++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e430865df6..1e21d90be9 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -659,6 +659,8 @@ describe('extmark decorations', function() [25] = {background = Screen.colors.LightRed}; [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; [27] = {background = Screen.colors.Plum1}; + [28] = {underline = true, foreground = Screen.colors.SlateBlue}; + [29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray, underline = true}; } ns = meths.create_namespace 'test' @@ -1233,8 +1235,53 @@ describe('extmark decorations', function() meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) screen:expect_unchanged(true) end) -end) + it('highlights the beginning of a TAB char correctly', function() + screen:try_resize(50, 3) + meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) + meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) + screen:expect{grid=[[ + ^this is the{4: tab} | + {1:~ }| + | + ]]} + + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' }) + screen:expect{grid=[[ + ^this is the {4:tab} | + {1:~ }| + | + ]]} + end) + + pending('highlight applies to a full Tab in visual block mode #23734', function() + screen:try_resize(50, 8) + meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) + meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) + screen:expect([[ + {28:^asdf} | + {28: asdf} | + {28: asdf} | + {28: asdf} | + {28:asdf} | + {1:~ }| + {1:~ }| + | + ]]) + feed('Gll') + screen:expect([[ + {29:asd}{28:f} | + {29: }{28: asdf} | + {29: }{28: asdf} | + {29: }{28: asdf} | + {29:as}{28:^df} | + {1:~ }| + {1:~ }| + {24:-- VISUAL BLOCK --} | + ]]) + end) +end) describe('decorations: inline virtual text', function() local screen, ns diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 89b503141b..9a4be4573c 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -526,6 +526,41 @@ describe('highlight', function() }) end) + + it("'diff', syntax and extmark", function() + local screen = Screen.new(25,10) + screen:attach() + exec([[ + new + call setline(1, ['', '01234 6789']) + windo diffthis + wincmd w + syn match WarningMsg "^.*$" + call nvim_buf_add_highlight(0, -1, 'ErrorMsg', 1, 2, 8) + ]]) + screen:expect([[ + {1: }^ | + {1: }{2:01}{3:234 67}{2:89}{5: }| + {4:~ }| + {4:~ }| + {7:[No Name] [+] }| + {1: } | + {1: }{6:-----------------------}| + {4:~ }| + {8:[No Name] }| + | + ]],{ + [0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}, + [1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4}, + [2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue}, + [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.LightBlue}, + [4] = {bold = true, foreground = Screen.colors.Blue}, + [5] = {background = Screen.colors.LightBlue}, + [6] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1}, + [7] = {reverse = true, bold = true}, + [8] = {reverse = true}, + }) + end) end) describe("'listchars' highlight", function() -- cgit From 43d66c0ebbe43f40a1f76e1635ccef6181c01317 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 May 2023 10:48:48 +0800 Subject: fix(ui-ext): send title to newly-attached UI --- test/functional/ui/screen_basic_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index b31e40d4ab..67e3b774b4 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -117,6 +117,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.title) end) + screen:detach() + screen.title = nil + screen:attach() + screen:expect(function() + eq(expected, screen.title) + end) end) end) @@ -128,6 +134,12 @@ local function screen_tests(linegrid) screen:expect(function() eq(expected, screen.icon) end) + screen:detach() + screen.icon = nil + screen:attach() + screen:expect(function() + eq(expected, screen.icon) + end) end) end) -- cgit From f733595e795cd2b819cb8fd18327cd51f47b2124 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 26 May 2023 02:08:18 +0200 Subject: vim-patch:9.0.1578: SpellCap highlight not always updated when needed (#23755) Problem: SpellCap highlight not always updated when needed. Solution: Handle updating line below closed fold and other situations where only part of the window is redrawn. (Luuk van Baal, closes vim/vim#12428, closes vim/vim#12420) https://github.com/vim/vim/commit/2ac6497f0ef186f0e3ba67d7f0a485bfb612bb08 --- test/functional/ui/spell_spec.lua | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 7f11b06f78..630d0d0948 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -28,6 +28,7 @@ describe("'spell'", function() [7] = {foreground = Screen.colors.Blue}, [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, [9] = {bold = true}, + [10] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, }) end) @@ -82,7 +83,7 @@ describe("'spell'", function() end) -- oldtest: Test_spell_screendump_spellcap() - it('has correct highlight at start of line with trailing space', function() + it('SpellCap highlight at start of line', function() exec([=[ call setline(1, [ \" This line has a sepll error. and missing caps and trailing spaces. ", @@ -117,7 +118,7 @@ describe("'spell'", function() | ]]) -- Deleting a full stop removes missing Cap in next line - feed('5Gddk$x') + feed('5Gddk$x') screen:expect([[ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | {2:another} missing cap here. | @@ -140,6 +141,43 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Folding an empty line does not remove Cap in next line + feed('uzfk:') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap here. | + Not | + {10:^+-- 2 lines: and here.·························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Folding the end of a sentence does not remove Cap in next line + -- and editing a line does not remove Cap in current line + feed('Jzfkk$x') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + -- Cap is correctly applied in the first row of a window + feed('') + screen:expect([[ + {2:another} missing cap her^e | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) end) -- oldtest: Test_spell_compatible() -- cgit From a6dd67f5b66c0ef646808422ceeac710ce144547 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 26 May 2023 10:41:19 +0800 Subject: fix(extmarks): fix virt_text_hide with 'nowrap' and multibyte (#23757) --- test/functional/ui/decorations_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index b301ed8353..767ec54a7b 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -825,6 +825,26 @@ describe('extmark decorations', function() end -- ?古古古古?古古 | | ]]} + + screen:try_resize(50, 2) + command('set nowrap') + meths.buf_set_lines(0, 12, 12, true, {'-- ' .. ('…'):rep(57)}) + feed('G') + meths.buf_set_extmark(0, ns, 12, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + screen:expect{grid=[[ + ^-- …………………………………………………………………………………………………………{4:!!!!!}……| + | + ]]} + feed('40zl') + screen:expect{grid=[[ + ^………{4:!!!!!}……………………………… | + | + ]]} + feed('10zl') + screen:expect{grid=[[ + ^………………………… | + | + ]]} end) it('can have virtual text of overlay position and styling', function() -- cgit From 510e1f131b56e0423342f597178459a63eb0b810 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 May 2023 21:36:16 +0800 Subject: fix(extmarks): make right_align and win_col work on wrapped line (#23759) --- test/functional/ui/decorations_spec.lua | 115 +++++++++++++++++++++++++++----- 1 file changed, 98 insertions(+), 17 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 3ed31033fa..b9080cbcf5 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -940,25 +940,30 @@ describe('extmark decorations', function() ]]} end) - it('can have virtual text of fixed win_col position', function() + it('can have virtual text of right_align and fixed win_col position', function() insert(example_text) feed 'gg' meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) -- empty virt_text should not change anything meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_pos='right_align', hl_mode='blend'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(item) | - if hl_id_cell ~= nil then {4:Much} | - hl_id = hl_id_cell {4:Error} | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if hl_id_cell ~= nil then {4:Much} {4:MUCH}| + hl_id = hl_id_cell {4:Error} {4:ERROR}| end | for _ = 1, (count or 1) do | local cell = line[colpos] | - {1:-} cell.text = text | + {1:-} cell.text = text {1:-}| cell.hl_id = hl_id | colpos = colpos+1 | end | @@ -971,14 +976,14 @@ describe('extmark decorations', function() feed '3G12|i' screen:expect{grid=[[ for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(item) | - if hl_i {4:Much} | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if hl_i {4:Much} {4:MUCH}| ^d_cell ~= nil then | - hl_id = hl_id_cell {4:Error} | + hl_id = hl_id_cell {4:Error} {4:ERROR}| end | for _ = 1, (count or 1) do | local cell = line[colpos] | - {1:-} cell.text = text | + {1:-} cell.text = text {1:-}| cell.hl_id = hl_id | colpos = colpos+1 | end | @@ -990,13 +995,13 @@ describe('extmark decorations', function() feed 'u:' screen:expect{grid=[[ for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(item) | - if hl_i^d_cell ~= nil then {4:Much} | - hl_id = hl_id_cell {4:Error} | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if hl_i^d_cell ~= nil then {4:Much} {4:MUCH}| + hl_id = hl_id_cell {4:Error} {4:ERROR}| end | for _ = 1, (count or 1) do | local cell = line[colpos] | - {1:-} cell.text = text | + {1:-} cell.text = text {1:-}| cell.hl_id = hl_id | colpos = colpos+1 | end | @@ -1009,14 +1014,14 @@ describe('extmark decorations', function() feed '8|i' screen:expect{grid=[[ for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(item) | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| if | - ^hl_id_cell ~= nil then {4:Much} | - hl_id = hl_id_cell {4:Error} | + ^hl_id_cell ~= nil then {4:Much} {4:MUCH}| + hl_id = hl_id_cell {4:Error} {4:ERROR}| end | for _ = 1, (count or 1) do | local cell = line[colpos] | - {1:-} cell.text = text | + {1:-} cell.text = text {1:-}| cell.hl_id = hl_id | colpos = colpos+1 | end | @@ -1024,6 +1029,82 @@ describe('extmark decorations', function() {1:~ }| | ]]} + + feed 'jI-- ..........' + screen:expect{grid=[[ + for _,item in ipairs(items) do | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if | + hl_id_cell ~= nil then {4:Much} {4:MUCH}| + --^ -- -- -- -- -- -- --{4:Error}- -- hl_i{4:ERROR}| + l_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + {1:-} cell.text = text {1:-}| + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + | + ]]} + + feed '.' + screen:expect{grid=[[ + for _,item in ipairs(items) do | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if | + hl_id_cell ~= nil then {4:Much} {4:MUCH}| + --^ -- -- -- -- -- -- -- -- -- -- -- hl_id | + = hl_id_cell {4:Error} {4:ERROR}| + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + {1:-} cell.text = text {1:-}| + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + | + ]]} + + command 'set nowrap' + screen:expect{grid=[[ + for _,item in ipairs(items) do | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if | + hl_id_cell ~= nil then {4:Much} {4:MUCH}| + --^ -- -- -- -- -- -- --{4:Error}- -- -- h{4:ERROR}| + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + {1:-} cell.text = text {1:-}| + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + | + ]]} + + feed('8zl') + screen:expect{grid=[[ + em in ipairs(items) do | + l text, hl_id_cell, count = unp{4:Very}item) {4:VERY}| + | + ll ~= nil then {4:Much} {4:MUCH}| + --^ -- -- -- -- -- -- -- -- -- -{4:Error}hl_id = h{4:ERROR}| + | + _ = 1, (count or 1) do | + local cell = line[colpos] | + cell{1:-}text = text {1:-}| + cell.hl_id = hl_id | + colpos = colpos+1 | + | + | + {1:~ }| + | + ]]} end) it('can have virtual text which combines foreground and background groups', function() -- cgit From e41b2e34b46a806b0fc59914263f8f4af9ac62f1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 28 May 2023 11:09:25 +0800 Subject: test(extmarks): add test for virt_text_hide with 'smoothscroll' (#23791) --- test/functional/ui/decorations_spec.lua | 37 +++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index b9080cbcf5..0247582cdd 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -827,26 +827,55 @@ describe('extmark decorations', function() end -- ?古古古古?古古 | | ]]} + end) - screen:try_resize(50, 2) + it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() + screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 12, 12, true, {'-- ' .. ('…'):rep(57)}) - feed('G') - meths.buf_set_extmark(0, ns, 12, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + meths.buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) + meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) screen:expect{grid=[[ ^-- …………………………………………………………………………………………………………{4:!!!!!}……| + {1:~ }| | ]]} feed('40zl') screen:expect{grid=[[ ^………{4:!!!!!}……………………………… | + {1:~ }| | ]]} feed('10zl') screen:expect{grid=[[ + ^………………………… | + {1:~ }| + | + ]]} + + command('set wrap smoothscroll') + screen:expect{grid=[[ + -- …………………………………………………………………………………………………………{4:!!!!!}……| ^………………………… | | ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}………………^… | + {1:~ }| + | + ]]} + screen:try_resize(40, 3) + screen:expect{grid=[[ + {1:<<<}{4:!!!!!}……………………………^… | + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + -- …………………………………………………………………………………………………| + ………{4:!!!!!}……………………………^… | + | + ]]} end) it('can have virtual text of overlay position and styling', function() -- cgit From f29acc507305a7f4323a3233dc3867dfbe00132b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 28 May 2023 16:28:10 +0800 Subject: test(extmarks): add tests for #14201 #20004 #20885 (#23794) --- test/functional/ui/decorations_spec.lua | 74 +++++++++++++++++++++++++++++++-- test/functional/ui/highlight_spec.lua | 8 ++-- 2 files changed, 74 insertions(+), 8 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 0247582cdd..fa4286c3ad 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -8,6 +8,7 @@ local exec_lua = helpers.exec_lua local exec = helpers.exec local expect_events = helpers.expect_events local meths = helpers.meths +local funcs = helpers.funcs local curbufmeths = helpers.curbufmeths local command = helpers.command local assert_alive = helpers.assert_alive @@ -651,7 +652,7 @@ describe('extmark decorations', function() [16] = {blend = 30, background = Screen.colors.Red1, foreground = Screen.colors.Magenta1}; [17] = {bold = true, foreground = Screen.colors.Brown, background = Screen.colors.LightGrey}; [18] = {background = Screen.colors.LightGrey}; - [19] = {foreground = Screen.colors.Cyan4, background = Screen.colors.LightGrey}; + [19] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGrey}; [20] = {foreground = tonumber('0x180606'), background = tonumber('0xf13f3f')}; [21] = {foreground = Screen.colors.Gray0, background = tonumber('0xf13f3f')}; [22] = {foreground = tonumber('0xb20000'), background = tonumber('0xf13f3f')}; @@ -662,6 +663,9 @@ describe('extmark decorations', function() [27] = {background = Screen.colors.Plum1}; [28] = {underline = true, foreground = Screen.colors.SlateBlue}; [29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray, underline = true}; + [30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true}; + [31] = {underline = true, foreground = Screen.colors.DarkCyan}; + [32] = {underline = true}; } ns = meths.create_namespace 'test' @@ -1367,7 +1371,56 @@ describe('extmark decorations', function() screen:expect_unchanged(true) end) - it('highlights the beginning of a TAB char correctly', function() + it('highlight is combined with syntax and sign linehl #20004', function() + screen:try_resize(50, 3) + insert([[ + function Func() + end]]) + feed('gg') + command('set ft=lua') + command('syntax on') + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' }) + command('hi default MyLine gui=underline') + command('sign define CurrentLine linehl=MyLine') + funcs.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 }) + screen:expect{grid=[[ + {30:^fun}{31:ction}{32: Func() }| + {6:end} | + | + ]]} + end) + + it('highlight works after TAB with sidescroll #14201', function() + screen:try_resize(50, 3) + command('set nowrap') + meths.buf_set_lines(0, 0, -1, true, {'\tword word word word'}) + meths.buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) + screen:expect{grid=[[ + ^ {4:wo}rd word word word | + {1:~ }| + | + ]]} + feed('7zl') + screen:expect{grid=[[ + {4:^wo}rd word word word | + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + {4:^wo}rd word word word | + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + {4:^o}rd word word word | + {1:~ }| + | + ]]} + end) + + it('highlights the beginning of a TAB char correctly #23734', function() screen:try_resize(50, 3) meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) @@ -1386,7 +1439,20 @@ describe('extmark decorations', function() ]]} end) - pending('highlight applies to a full Tab in visual block mode #23734', function() + it('highlight applies to a full TAB on line with matches #20885', function() + screen:try_resize(50, 3) + meths.buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) + funcs.matchadd('Underlined', 'match') + meths.buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' }) + meths.buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' }) + screen:expect{grid=[[ + {18: ^ -- }{29:match}{18:1} | + {18: -- }{29:match}{18:2} | + | + ]]} + end) + + pending('highlight applies to a full TAB in visual block mode', function() screen:try_resize(50, 8) meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) @@ -2193,7 +2259,7 @@ describe('decorations: virtual lines', function() screen:attach() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; - [2] = {foreground = Screen.colors.Cyan4}; + [2] = {foreground = Screen.colors.DarkCyan}; [3] = {background = Screen.colors.Yellow1}; [4] = {bold = true}; [5] = {background = Screen.colors.Yellow, foreground = Screen.colors.Blue}; diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 9a4be4573c..c68f4cf34c 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -426,7 +426,7 @@ describe('highlight', function() ^ | {2:~ }| | - ]],{ + ]], { [1] = {strikethrough = true}, [2] = {bold = true, foreground = Screen.colors.Blue1}, }) @@ -515,7 +515,7 @@ describe('highlight', function() {1:neovim} tabbed^ | {0:~ }| {5:-- INSERT --} | - ]],{ + ]], { [0] = {bold=true, foreground=Screen.colors.Blue}, [1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red, special = Screen.colors.Red}, @@ -527,7 +527,7 @@ describe('highlight', function() end) - it("'diff', syntax and extmark", function() + it("'diff', syntax and extmark #23722", function() local screen = Screen.new(25,10) screen:attach() exec([[ @@ -549,7 +549,7 @@ describe('highlight', function() {4:~ }| {8:[No Name] }| | - ]],{ + ]], { [0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}, [1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4}, [2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue}, -- cgit From 4dd43e31db8fa23b5189e074cff94f1491035aac Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 28 May 2023 17:22:25 +0800 Subject: fix(extmarks): don't show virt lines for end mark (#23792) --- test/functional/ui/decorations_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index fa4286c3ad..4960a1d3ed 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2978,6 +2978,30 @@ if (h->n_buckets < new_n_buckets) { // expand ]]} end) + it('does not show twice if end_row or end_col is specified #18622', function() + insert([[ + aaa + bbb + ccc + ddd]]) + meths.buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) + meths.buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + screen:expect{grid=[[ + aaa | + {1:VIRT LINE 1} | + bbb | + ccc | + dd^d | + {1:VIRT LINE 2} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + end) describe('decorations: signs', function() -- cgit From 9c41a81dec15ced3f66723b8aa87c2438a099128 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 28 May 2023 17:29:44 +0800 Subject: fix(extmarks): fix virt_text_hide off-by-one hiding (#23795) --- test/functional/ui/decorations_spec.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4960a1d3ed..975da35355 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -837,9 +837,10 @@ describe('extmark decorations', function() screen:try_resize(50, 3) command('set nowrap') meths.buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) screen:expect{grid=[[ - ^-- …………………………………………………………………………………………………………{4:!!!!!}……| + {4:^?????}……………………………………………………………………………………………………{4:!!!!!}……| {1:~ }| | ]]} @@ -849,7 +850,13 @@ describe('extmark decorations', function() {1:~ }| | ]]} - feed('10zl') + feed('3zl') + screen:expect{grid=[[ + {4:^!!!!!}……………………………… | + {1:~ }| + | + ]]} + feed('7zl') screen:expect{grid=[[ ^………………………… | {1:~ }| @@ -858,7 +865,7 @@ describe('extmark decorations', function() command('set wrap smoothscroll') screen:expect{grid=[[ - -- …………………………………………………………………………………………………………{4:!!!!!}……| + {4:?????}……………………………………………………………………………………………………{4:!!!!!}……| ^………………………… | | ]]} @@ -876,7 +883,7 @@ describe('extmark decorations', function() ]]} feed('') screen:expect{grid=[[ - -- …………………………………………………………………………………………………| + {4:?????}……………………………………………………………………………………………| ………{4:!!!!!}……………………………^… | | ]]} -- cgit From 9dd48f7832f4656af4a2579368641268bb6399e7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 29 May 2023 08:44:52 +0800 Subject: fix(substitute): properly check if preview is needed (#23809) --- test/functional/ui/inccommand_user_spec.lua | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 6329ece40a..9cc6e095c5 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -401,6 +401,40 @@ describe("'inccommand' for user commands", function() feed('e') assert_alive() end) + + it('no crash when adding highlight after :substitute #21495', function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command("Crash", function() end, { + preview = function(_, preview_ns, _) + vim.cmd("%s/text/cats/g") + vim.api.nvim_buf_add_highlight(0, preview_ns, "Search", 0, 0, -1) + return 1 + end, + }) + ]]) + feed(':C') + screen:expect([[ + {1: cats on line 1} | + more cats on line 2 | + oh no, even more cats | + will the cats ever stop | + oh well | + did the cats stop | + why won't it stop | + make the cats stop | + | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :C^ | + ]]) + assert_alive() + end) end) describe("'inccommand' with multiple buffers", function() -- cgit From 55f6a1cab031ecc28c5a7f2558a0cac9df2145e1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 30 May 2023 07:18:12 +0800 Subject: vim-patch:9.0.1588: Incsearch not triggered when pasting clipboard register (#23817) Problem: Incsearch not triggered when pasting clipboard register on the command line. Solution: Also set "literally" when using a clipboard register. (Ken Takata, closes vim/vim#12460) https://github.com/vim/vim/commit/9cf6ab133227ac7e9169941752293bb7178d8e38 Co-authored-by: K.Takata --- test/functional/ui/searchhl_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 3c8dceb8cb..1e42689200 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -512,6 +512,36 @@ describe('search highlighting', function() {1:~ }│{1:~ }| /file^ | ]]) + feed('') + + command('set rtp^=test/functional/fixtures') + -- incsearch works after c_CTRL-R inserts clipboard register + + command('let @* = "first"') + feed('/*') + screen:expect([[ + the {3:first} line │the {2:first} line | + in a little file │in a little file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /first^ | + ]]) + feed('') + + command('let @+ = "little"') + feed('/+') + screen:expect([[ + the first line │the first line | + in a {3:little} file │in a {2:little} file | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + /little^ | + ]]) + feed('') end) it('works with incsearch and offset', function() -- cgit From 70da793c5eda9f3e533a137ac0c0e31db1df0324 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Tue, 30 May 2023 14:56:12 +0200 Subject: fix(statusline): corrupted screen with minwid sign item in 'statuscolumn' (#23823) --- test/functional/ui/statuscolumn_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index c218bd8fd6..6624fb008d 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -424,6 +424,21 @@ describe('statuscolumn', function() ]]) end) + it('does not corrupt the screen with minwid sign item', function() + screen:try_resize(screen._width, 3) + screen:set_default_attr_ids({ + [0] = {foreground = Screen.colors.Brown}, + [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Gray}, + }) + command([[set stc=%6s\ %l]]) + exec_lua('vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {sign_text = "𒀀"})') + screen:expect([[ + {0: 𒀀 8}^aaaaa | + {0: }{1: }{0: 9}aaaaa | + | + ]]) + end) + for _, model in ipairs(mousemodels) do it("works with 'statuscolumn' clicks with mousemodel=" .. model, function() command('set mousemodel=' .. model) -- cgit From 7e3ff8afa435607c703706a99cf9006893bdb399 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 31 May 2023 06:50:37 +0800 Subject: test(extmarks): folding inline virt_text on empty line (#23847) --- test/functional/ui/decorations_spec.lua | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 975da35355..2d0223dec7 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2227,34 +2227,55 @@ bbbbbbb]]) end) it('does not crash at column 0 when folded in a wide window', function() - screen:try_resize(82, 4) + screen:try_resize(82, 5) command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') command('set cursorline') insert([[ aaaaa bbbbb + ccccc]]) meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) screen:expect{grid=[[ fooaaaaa | bbbbb | + bar | {16:cccc^c }| | ]]} command('1,2fold') screen:expect{grid=[[ {17:+-- 2 lines: aaaaa·······························································}| + bar | {16:cccc^c }| {1:~ }| | ]]} - feed('k') + feed('2k') screen:expect{grid=[[ {18:^+-- 2 lines: aaaaa·······························································}| + bar | ccccc | {1:~ }| | ]]} + command('3,4fold') + screen:expect{grid=[[ + {18:^+-- 2 lines: aaaaa·······························································}| + {17:+-- 2 lines: ccccc·······························································}| + {1:~ }| + {1:~ }| + | + ]]} + feed('j') + screen:expect{grid=[[ + {17:+-- 2 lines: aaaaa·······························································}| + {18:^+-- 2 lines: ccccc·······························································}| + {1:~ }| + {1:~ }| + | + ]]} end) end) -- cgit From 2bdef6dd2a7572602aeb2efec76812769bcee246 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 1 Jun 2023 16:20:31 +0800 Subject: fix(column): don't overflow sign column with extmark signs (#23854) --- test/functional/ui/decorations_spec.lua | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 2d0223dec7..54441984a3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -3342,8 +3342,8 @@ l5 insert(example_test3) feed 'gg' - helpers.command('sign define Oldsign text=O3') - helpers.command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command('sign define Oldsign text=O3') + command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) @@ -3366,6 +3366,39 @@ l5 ]]} end) + it('does not overflow with many old signs #23852', function() + screen:try_resize(20, 3) + + command('set signcolumn:auto:9') + command('sign define Oldsign text=O3') + command([[exe 'sign place 01 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 02 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 03 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 04 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 05 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 06 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 07 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 08 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + command([[exe 'sign place 09 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) + screen:expect{grid=[[ + O3O3O3O3O3O3O3O3O3^ | + {2:~ }| + | + ]]} + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + screen:expect_unchanged() + + meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + screen:expect{grid=[[ + O3O3O3O3O3O3O3O3S5^ | + {2:~ }| + | + ]]} + + assert_alive() + end) + it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) meths.set_option_value('signcolumn', 'auto', {}) -- cgit From ac1ad9651e88eef1eea92fe5bd1497344c83dc53 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 31 May 2023 21:13:58 +0200 Subject: vim-patch:9.0.1595: line pointer becomes invalid when using spell checking Problem: Line pointer becomes invalid when using spell checking. Solution: Call ml_get() at the right places. (Luuk van Baal, closes vim/vim#12456) https://github.com/vim/vim/commit/e84c773d42e8b6ef0f8ae9b6c7312e0fd47909af --- test/functional/ui/spell_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index 630d0d0948..d18e19e5b2 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -178,6 +178,30 @@ describe("'spell'", function() {0:~ }| | ]]) + -- Adding an empty line does not remove Cap in "mod_bot" area + feed('zbO') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + ^ | + {2:another} missing cap here | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + {0:~ }| + | + ]]) + -- Multiple empty lines does not remove Cap in the line after + feed('O') + screen:expect([[ + This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. | + ^ | + | + {2:another} missing cap here | + {10:+-- 2 lines: Not·······························································}| + {2:and} here. | + {0:~ }| + | + ]]) end) -- oldtest: Test_spell_compatible() -- cgit From 0e01e815520ead73b13277b68306cf03a2196ca5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Jun 2023 18:44:08 +0800 Subject: fix(folds): allow overlay virtual text on folded line (#23892) Also always check for fi_level before fi_lines. --- test/functional/ui/decorations_spec.lua | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 54441984a3..cbf0178d28 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -666,6 +666,7 @@ describe('extmark decorations', function() [30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true}; [31] = {underline = true, foreground = Screen.colors.DarkCyan}; [32] = {underline = true}; + [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray}; } ns = meths.create_namespace 'test' @@ -1147,6 +1148,46 @@ describe('extmark decorations', function() ]]} end) + it('can have virtual text on folded line', function() + insert([[ + 11111 + 22222 + 33333]]) + command('1,2fold') + command('set nowrap') + screen:try_resize(50, 3) + feed('zb') + -- XXX: the behavior of overlay virtual text at non-zero column is strange: + -- 1. With 'wrap' it is never shown. + -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) + screen:expect{grid=[[ + {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| + 3333^3 | + | + ]]} + feed('zl') + screen:expect{grid=[[ + {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| + 333^3 | + | + ]]} + feed('zl') + screen:expect{grid=[[ + {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| + 33^3 | + | + ]]} + feed('zl') + screen:expect{grid=[[ + {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| + 3^3 | + | + ]]} + end) + it('can have virtual text which combines foreground and background groups', function() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; -- cgit From 700cab00680fa25e0dbdf6f91f638f4da5a09909 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 4 Jun 2023 09:09:22 +0800 Subject: fix(events)!: trigger CursorMoved later on switching window (#23711) --- test/functional/ui/float_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 19ad340dd5..46c2127c30 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -79,7 +79,7 @@ describe('float window', function() api.nvim_buf_set_lines(buf, 0, -1, true, contents) local winnr = vim.fn.win_id2win(floatwin) api.nvim_command('wincmd p') - api.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c') + api.nvim_command('autocmd BufEnter * ++once '..winnr..'wincmd c') return buf, floatwin end crashes{'foo'} -- cgit From fdc8e966a9183c08f2afec0817d03b7417a883b3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 4 Jun 2023 10:49:02 +0800 Subject: fix(ui): don't send empty grid_line with redrawdebug=compositor (#23899) --- test/functional/ui/screen.lua | 1 + test/functional/ui/screen_basic_spec.lua | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 83424d3bea..2307fd106b 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -947,6 +947,7 @@ end function Screen:_handle_grid_line(grid, row, col, items) assert(self._options.ext_linegrid) + assert(#items > 0) local line = self._grids[grid].rows[row+1] local colpos = col+1 local hl_id = 0 diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 67e3b774b4..5d5be2e807 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -1096,3 +1096,18 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() feed('') eq(953, funcs.line('w0')) end) + +it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function() + clear() + local screen = Screen.new(30, 2) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, + }) + screen:attach() + command('set showcmd redrawdebug=compositor') + feed('d') + screen:expect{grid=[[ + ^ | + d | + ]]} +end) -- cgit From 7955c90621bb679f9c16b6788fbcb6145739886f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Jun 2023 06:58:44 +0800 Subject: fix(plines): folded lines with virt_lines attached to line above --- test/functional/ui/fold_spec.lua | 232 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 223 insertions(+), 9 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 520979a2c2..06668c0ba3 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -7,7 +7,6 @@ local insert = helpers.insert local funcs = helpers.funcs local meths = helpers.meths local exec = helpers.exec -local exec_lua = helpers.exec_lua local assert_alive = helpers.assert_alive @@ -1911,19 +1910,17 @@ describe("folded lines", function() end end) - it('fold attached virtual lines are drawn correctly #21837', function() + it('fold attached virtual lines are drawn and scrolled correctly #21837', function() funcs.setline(1, 'line 1') funcs.setline(2, 'line 2') funcs.setline(3, 'line 3') funcs.setline(4, 'line 4') feed("zfj") - exec_lua([[ - local ns = vim.api.nvim_create_namespace("ns") - vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} }) - vim.api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} }) - vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} }) - vim.api.nvim_buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} }) - ]]) + local ns = meths.create_namespace('ns') + meths.buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} }) + meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} }) + meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} }) if multigrid then screen:expect([[ ## grid 1 @@ -2031,6 +2028,223 @@ describe("folded lines", function() | ]]) end + + meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} }) + feed('G') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + line 1 | + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + line 1 | + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end end) it('Folded and Visual highlights are combined #19691', function() -- cgit From a3fba5cafcf124946ea65a68fc1b9dfbeb197525 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Jun 2023 17:11:58 +0800 Subject: fix(mouse): handle folded lines with virt_lines attached to line above (#23912) --- test/functional/ui/fold_spec.lua | 156 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 06668c0ba3..68a7c89b32 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -45,6 +45,7 @@ describe("folded lines", function() [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, [14] = {background = Screen.colors.Red}, [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red}, + [16] = {background = Screen.colors.LightGrey}, }) end) @@ -2029,6 +2030,17 @@ describe("folded lines", function() ]]) end + meths.input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) + eq({ + column = 1, + line = 3, + screencol = 1, + screenrow = 5, + wincol = 1, + winid = 1000, + winrow = 5, + }, funcs.getmousepos()) + meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} }) feed('G') if multigrid then @@ -2245,6 +2257,150 @@ describe("folded lines", function() | ]]) end + + feed('3') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^line 5 | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + + meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^l{16:ine 5} | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + virt_line below line 2 | + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^l{16:ine 5} | + {1:~ }| + {1:~ }| + {1:~ }| + {11:-- VISUAL LINE --} | + ]]) + end + + meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^l{16:ine 5} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + more virt_line below line 2 | + {5:+-- 2 lines: line 3·························}| + ^l{16:ine 5} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {11:-- VISUAL LINE --} | + ]]) + end + + meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {5:+-- 2 lines: line 3·························}| + {16:line }^5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + {5:+-- 2 lines: line 3·························}| + {16:line }^5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {11:-- VISUAL LINE --} | + ]]) + end end) it('Folded and Visual highlights are combined #19691', function() -- cgit From 7b973c71ea845c9bcc6d98e101ad5a7956cb5802 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Jun 2023 19:24:42 +0800 Subject: fix(statusline): redraw when VIsual_mode changes (#23933) --- test/functional/ui/statusline_spec.lua | 54 +++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 5afa912be6..c47b26f55e 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -627,11 +627,19 @@ it('K_EVENT does not trigger a statusline redraw unnecessarily', function() eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter')) end) -it('statusline is redrawn on recording state change #22683', function() +it('statusline is redrawn on various state changes', function() clear() local screen = Screen.new(40, 4) screen:attach() + + -- recording state change #22683 command('set ls=2 stl=%{repeat(reg_recording(),5)}') + screen:expect([[ + ^ | + ~ | + | + | + ]]) feed('qQ') screen:expect([[ ^ | @@ -639,6 +647,50 @@ it('statusline is redrawn on recording state change #22683', function() QQQQQ | recording @Q | ]]) + feed('q') + screen:expect([[ + ^ | + ~ | + | + | + ]]) + + -- Visual mode change #23932 + command('set ls=2 stl=%{mode(1)}') + screen:expect([[ + ^ | + ~ | + n | + | + ]]) + feed('v') + screen:expect([[ + ^ | + ~ | + v | + -- VISUAL -- | + ]]) + feed('V') + screen:expect([[ + ^ | + ~ | + V | + -- VISUAL LINE -- | + ]]) + feed('') + screen:expect([[ + ^ | + ~ | + ^V | + -- VISUAL BLOCK -- | + ]]) + feed('') + screen:expect([[ + ^ | + ~ | + n | + | + ]]) end) it('ruler is redrawn in cmdline with redrawstatus #22804', function() -- cgit From 0381f5af5bdc504f92be35dd89ac1328096eb8e6 Mon Sep 17 00:00:00 2001 From: Jonathon <32371757+jwhite510@users.noreply.github.com> Date: Wed, 7 Jun 2023 08:29:23 -0400 Subject: feat(diff): grouping optimization for linematch algorithm --- test/functional/ui/linematch_spec.lua | 186 ++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index 697677aa67..76197bc7e0 100644 --- a/test/functional/ui/linematch_spec.lua +++ b/test/functional/ui/linematch_spec.lua @@ -779,6 +779,192 @@ something end) end) + describe('setup a diff with 2 files and set linematch:30', function() + before_each(function() + feed(':set diffopt+=linematch:30') + local f1 = [[ +// abc d +// d +// d + ]] + local f2 = [[ + +abc d +d + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^ }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{9:abc d }│{1: }{10: 1 }{8:// }{9:abc d }| + {1: }{10: 3 }{9:d }│{1: }{10: 2 }{8:// }{9:d }| + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 3 }{4:// d }| + {1: }{10: 4 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('setup a diff with 2 files and set linematch:30, with ignore white', function() + before_each(function() + feed(':set diffopt+=linematch:30:set diffopt+=iwhiteall') + local f1 = [[ +void testFunction () { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + } + } +} + ]] + local f2 = [[ +void testFunction () { + // for (int j = 0; j < 10; i++) { + // } +} + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }^void testFunction () { │{1: }{10: 1 }void testFunction () { | + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 2 }{4: for (int i = 0; i < 10; i++) { }| + {1: }{10: 2 }{9: }{8:// for (int j = 0; j < 10; i}{9:++) { }│{1: }{10: 3 }{9: }{8:for (int j = 0; j < 10; j}{9:++) { }| + {1: }{10: 3 }{9: }{8:// }{9:} }│{1: }{10: 4 }{9: } }| + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 5 }{4: } }| + {1: }{10: 4 }} │{1: }{10: 6 }} | + {1: }{10: 5 } │{1: }{10: 7 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('a diff that would result in multiple groups before grouping optimization', function() + before_each(function() + feed(':set diffopt+=linematch:30') + local f1 = [[ +!A +!B +!C + ]] + local f2 = [[ +?Z +?A +?B +?C +?A +?B +?B +?C + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^?Z }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{8:?}{9:A }│{1: }{10: 1 }{8:!}{9:A }| + {1: }{10: 3 }{8:?}{9:B }│{1: }{10: 2 }{8:!}{9:B }| + {1: }{10: 4 }{8:?}{9:C }│{1: }{10: 3 }{8:!}{9:C }| + {1: }{10: 5 }{4:?A }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 6 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 7 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 8 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 9 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('a diff that would result in multiple groups before grouping optimization', function() + before_each(function() + feed(':set diffopt+=linematch:30') + local f1 = [[ +!A +!B +!C + ]] + local f2 = [[ +?A +?Z +?B +?C +?A +?B +?C +?C + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^?A }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{4:?Z }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 3 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 4 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 5 }{8:?}{9:A }│{1: }{10: 1 }{8:!}{9:A }| + {1: }{10: 6 }{8:?}{9:B }│{1: }{10: 2 }{8:!}{9:B }| + {1: }{10: 7 }{8:?}{9:C }│{1: }{10: 3 }{8:!}{9:C }| + {1: }{10: 8 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 9 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) describe('setup a diff with 2 files and set linematch:10', function() before_each(function() feed(':set diffopt+=linematch:10') -- cgit From 4c7cec4e293495e69c105f883905f78af4c151c0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 13 Jun 2023 11:30:19 +0800 Subject: fix(extmarks): handle inline virt_text with empty chunk (#24005) --- test/functional/ui/decorations_spec.lua | 47 ++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index cbf0178d28..36c414e58f 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1618,6 +1618,51 @@ describe('decorations: inline virtual text', function() ]]} end) + it('works with empty chunk', function() + insert(example_text) + feed 'gg' + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + | + ]]} + + meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{10:: }{3:string}, hl_id_cell, count = unpack| + (item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + | + ]]} + + feed('jf,') + screen:expect{grid=[[ + for _,item in ipairs(items) do | + local text{10:: }{3:string}^, hl_id_cell, count = unpack| + (item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + | + ]]} + end) + it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') meths.buf_set_extmark(0, ns, 0, 4, @@ -2013,7 +2058,7 @@ bbbbbbb]]) ]]} end) - it('cursor position is correct when inserting around virtual texts with both left and right gravity ', function() + it('cursor position is correct when inserting around virtual texts with both left and right gravity', function() insert('foo foo foo foo') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) -- cgit From a05bbc60eaf2d18cb117345becd9d2d13fa4ce4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 15 Jun 2023 09:03:39 +0800 Subject: fix(extmarks): don't position overlay virt_text halfway a char (#24027) --- test/functional/ui/decorations_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 36c414e58f..940974e0b0 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -667,6 +667,8 @@ describe('extmark decorations', function() [31] = {underline = true, foreground = Screen.colors.DarkCyan}; [32] = {underline = true}; [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray}; + [34] = {background = Screen.colors.Yellow}; + [35] = {background = Screen.colors.Yellow, bold = true, foreground = Screen.colors.Blue}; } ns = meths.create_namespace 'test' @@ -890,6 +892,25 @@ describe('extmark decorations', function() ]]} end) + it('overlay virtual text works on and after a TAB #24022', function() + screen:try_resize(40, 3) + meths.buf_set_lines(0, 0, -1, true, {'\t\tline 1'}) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + screen:expect{grid=[[ + {34:AA} ^ {34:BB} {34:CC}ne 1 | + {1:~ }| + | + ]]} + command('setlocal list listchars=tab:<->') + screen:expect{grid=[[ + {35:^AA}{1:----->}{35:BB}{1:----->}{34:CC}ne 1 | + {1:~ }| + | + ]]} + end) + it('can have virtual text of overlay position and styling', function() insert(example_text) feed 'gg' -- cgit From d81f78713b76e667491dba27ef6841f05d561d68 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 15 Jun 2023 11:14:50 +0800 Subject: test(decorations_spec): add test for extmark case of #21486 (#24028) --- test/functional/ui/decorations_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 940974e0b0..91fbbe2579 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1315,6 +1315,26 @@ describe('extmark decorations', function() ]]) end) + it('conceal works just before truncated double-width char #21486', function() + screen:try_resize(40, 4) + meths.buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'}) + meths.buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''}) + command('setlocal conceallevel=2') + screen:expect{grid=[[ + ^ | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:>} | + 古 | + | + ]]} + feed('j') + screen:expect{grid=[[ + | + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<>{1:>}| + 古 | + | + ]]} + end) + it('avoids redraw issue #20651', function() exec_lua[[ vim.cmd.normal'10oXXX' -- cgit From ded01a819ab0e10104aa29ab67cf67e4efd75e04 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 21 Jun 2023 18:28:12 +0800 Subject: fix(folds): don't show search or match highlighting on fold (#24084) --- test/functional/ui/fold_spec.lua | 80 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 68a7c89b32..71b9e49d2f 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2453,6 +2453,86 @@ describe("folded lines", function() ]]) end end) + + it('do not show search or match highlight #24084', function() + insert([[ + line 1 + line 2 + line 3 + line 4]]) + command('2,3fold') + feed('/line') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {2:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + /line^ | + ]]) + else + screen:expect([[ + {2:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /line^ | + ]]) + end + feed('') + funcs.matchadd('Search', 'line') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {6:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} ^4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + {6:line} 1 | + {5:+-- 2 lines: line 2·························}| + {6:line} ^4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() -- cgit From 0534ad8ca57bafa76769f49935a6cb00709d155b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Jun 2023 13:41:13 +0800 Subject: fix(extmarks): empty inline virt_text interfering with Visual highlight --- test/functional/ui/decorations_spec.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 91fbbe2579..0f118b621c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1675,9 +1675,11 @@ describe('decorations: inline virtual text', function() | ]]} + meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + feed('V') screen:expect{grid=[[ - ^for _,item in ipairs(items) do | + ^f{7:or _,item in ipairs(items) do} | local text{10:: }{3:string}, hl_id_cell, count = unpack| (item) | if hl_id_cell ~= nil then | @@ -1686,10 +1688,10 @@ describe('decorations: inline virtual text', function() for _ = 1, (count or 1) do | local cell = line[colpos] | cell.text = text | - | + {8:-- VISUAL LINE --} | ]]} - feed('jf,') + feed('jf,') screen:expect{grid=[[ for _,item in ipairs(items) do | local text{10:: }{3:string}^, hl_id_cell, count = unpack| -- cgit From 958cc22836f199c90eea680847843574ec54ebfe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Jun 2023 17:48:53 +0800 Subject: fix(extmarks): empty inline virt_text interfering with DiffText (#24101) --- test/functional/ui/decorations_spec.lua | 68 +++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 0f118b621c..6772ef036a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2216,6 +2216,51 @@ bbbbbbb]]) ]]} end) + it('hidden virtual text does not interfere with Visual highlight', function() + insert('abcdef') + command('set nowrap') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) + feed('V2zl') + screen:expect{grid=[[ + {10:X}{7:abcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + feed('zl') + screen:expect{grid=[[ + {7:abcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + feed('zl') + screen:expect{grid=[[ + {7:bcde}^f | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL LINE --} | + ]]} + end) + it('highlighting is correct when virtual text wraps with number', function() insert([[ test @@ -2279,9 +2324,11 @@ bbbbbbb]]) 9000 0009 ]]) + insert('aaa\tbbb') command("set diff") - meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) command("vnew") insert([[ 000 @@ -2290,6 +2337,7 @@ bbbbbbb]]) 000 000 ]]) + insert('aaabbb') command("set diff") feed('gg0') screen:expect { grid = [[ @@ -2298,12 +2346,26 @@ bbbbbbb]]) {9:000 }│{9:000}{5:9}{9: }| {9:000 }│{5:9}{9:000 }| {9:000 }│{9:000}{5:9}{9: }| - │ | + {9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }| {1:~ }│{1:~ }| {1:~ }│{1:~ }| {15:[No Name] [+] }{13:[No Name] [+] }| | ]]} + command('wincmd w | set nowrap') + feed('zl') + screen:expect { grid = [[ + {9:000 }│{14:test}{9:000 }| + {9:000 }│{9:00}{5:9}{9: }| + {9:000 }│{9:00}{5:9}{9: }| + {9:000 }│{9:000 }| + {9:000 }│{9:00}{5:9}{9: }| + {9:aaabbb }│{9:aaa}{5: }{9:bb^b }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {13:[No Name] [+] }{15:[No Name] [+] }| + | + ]]} end) it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() -- cgit From f4f1ce1d167c557e54153f74cf0f55245b8fd414 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Jun 2023 18:15:04 +0800 Subject: fix(extmarks): hide inline virt_text properly with 'smoothscroll' (#24106) --- test/functional/ui/decorations_spec.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6772ef036a..419a16e7b5 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2316,6 +2316,38 @@ bbbbbbb]]) ]]} end) + it('smoothscroll works correctly when virtual text wraps', function() + insert('foobar') + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + command('setlocal smoothscroll') + screen:expect{grid=[[ + foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XXXXXXXX}ba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}{10:XXXXX}ba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('in diff mode is highlighted correct', function() insert([[ 9000 -- cgit From f0884f21fa0cccc576f00bc18895cc80ba906031 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Jun 2023 20:39:35 +0800 Subject: feat(extmarks): support hl_mode "combine" for inline virt_text (#24099) --- test/functional/ui/decorations_spec.lua | 46 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 419a16e7b5..5de0106a8c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1587,13 +1587,15 @@ describe('decorations: inline virtual text', function() [9] = {background = Screen.colors.Plum1}; [10] = {foreground = Screen.colors.SlateBlue}; [11] = {blend = 30, background = Screen.colors.Red1}; - [12] = {background = Screen.colors.Yellow1}; + [12] = {background = Screen.colors.Yellow}; [13] = {reverse = true}; [14] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightMagenta}; [15] = {bold = true, reverse = true}; [16] = {foreground = Screen.colors.Red}; [17] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}; [18] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Red}; + [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.SlateBlue}; + [20] = {background = Screen.colors.LightGrey, foreground = Screen.colors.SlateBlue}; } ns = meths.create_namespace 'test' @@ -2000,13 +2002,15 @@ bbbbbbb]]) end) it('search highlight is correct', function() - insert('foo foo foo foo') - feed('0') - meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + insert('foo foo foo foo\nfoo foo foo foo') + feed('gg0') + meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) screen:expect { grid = [[ - ^foo foo {10:virtual text}foo foo | - {1:~ }| + ^foo foo f{10:AAABBB}oo foo | + foo foo f{10:CCCDDD}oo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2019,8 +2023,8 @@ bbbbbbb]]) feed('/foo') screen:expect { grid = [[ - {12:foo} {13:foo} {10:virtual text}{12:foo} {12:foo} | - {1:~ }| + {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} {12:foo} | + {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} {12:foo} | {1:~ }| {1:~ }| {1:~ }| @@ -2033,14 +2037,16 @@ bbbbbbb]]) end) it('visual select highlight is correct', function() - insert('foo foo foo foo') - feed('0') - meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + insert('foo foo foo foo\nfoo foo foo foo') + feed('gg0') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') screen:expect { grid = [[ - foo foo {10:virtual text}^foo foo | - {1:~ }| + foo foo {10:AAABBB}^foo foo | + foo foo {10:CCCDDD}foo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2051,11 +2057,11 @@ bbbbbbb]]) | ]]} - feed('v') - feed('2h') + feed('') + feed('2hj') screen:expect { grid = [[ - foo fo^o{7: }{10:virtual text}{7:f}oo foo | - {1:~ }| + foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo foo | + foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo foo | {1:~ }| {1:~ }| {1:~ }| @@ -2063,7 +2069,7 @@ bbbbbbb]]) {1:~ }| {1:~ }| {1:~ }| - {8:-- VISUAL --} | + {8:-- VISUAL BLOCK --} | ]]} end) -- cgit From 3688735c2b63337ab8d8b12ac08b4e6e064e98a2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 23 Jun 2023 06:40:26 +0800 Subject: fix(cmdline): don't redraw 'tabline' in Ex mode (#24123) Redrawing of 'statusline' and 'winbar' are actually already inhibited by RedawingDisabled in Ex mode. In Vim there is a check for `msg_scrolled == 0` (which is false in Ex mode) since Vim doesn't have msgsep. Add a `!exmode_active` check here in Nvim instead. --- test/functional/ui/cmdline_spec.lua | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index a9469bdf2d..dc29b765bd 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -944,6 +944,45 @@ describe('statusline is redrawn on entering cmdline', function() end) end) +it('tabline is not redrawn in Ex mode #24122', function() + clear() + local screen = Screen.new(60, 5) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- MsgSeparator + [2] = {reverse = true}, -- TabLineFill + }) + screen:attach() + + exec([[ + set showtabline=2 + set tabline=%!MyTabLine() + + function! MyTabLine() + + return "foo" + endfunction + ]]) + + feed('gQ') + screen:expect{grid=[[ + {2:foo }| + | + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :^ | + ]]} + + feed('echo 1') + screen:expect{grid=[[ + {1: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :echo 1 | + 1 | + :^ | + ]]} +end) + describe("cmdline height", function() it("does not crash resized screen #14263", function() clear() -- cgit From 31a51acdc3534f316dfedfaa37fea715f2a4814d Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sat, 24 Jun 2023 20:39:16 +1000 Subject: fix(extmarks): fix heap buffer overflow caused by inline virtual text (#23851) also fixes an edge case where the extends character would not be drawn if the real text exactly fits the grid. --- test/functional/ui/decorations_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 5de0106a8c..e8ad0d3f0d 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2506,6 +2506,28 @@ bbbbbbb]]) | ]]} end) + + it('list "extends" is drawn with only inline virtual text offscreen', function() + command('set nowrap') + command('set list') + command('set listchars+=extends:c') + meths.buf_set_extmark(0, ns, 0, 0, + { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) + insert(string.rep('a', 50)) + feed('gg0') + screen:expect { grid = [[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 8182384205d3c222e999ea9a78276cbf685f50fd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 24 Jun 2023 22:15:13 +0800 Subject: test(extmarks): add a test for #23848 (#24140) --- test/functional/ui/decorations_spec.lua | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e8ad0d3f0d..4c04bad3a0 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2507,6 +2507,42 @@ bbbbbbb]]) ]]} end) + it('does not crash at right edge of wide window #23848', function() + screen:try_resize(82, 5) + meths.buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'}) + screen:expect{grid=[[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + b | + {1:~ }| + {1:~ }| + | + ]]} + command('set nowrap') + screen:expect{grid=[[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('82i00') + screen:expect{grid=[[ + ^0000000000000000000000000000000000000000000000000000000000000000000000000000000000| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + command('set wrap') + screen:expect{grid=[[ + ^0000000000000000000000000000000000000000000000000000000000000000000000000000000000| + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + b | + {1:~ }| + | + ]]} + end) + it('list "extends" is drawn with only inline virtual text offscreen', function() command('set nowrap') command('set list') -- cgit From cd6458123fb4859e47ffcd144ebbddf389a09610 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 26 Jun 2023 11:52:52 +0800 Subject: fix(charset): fix wrong display of 0xffff (#24158) --- test/functional/ui/multibyte_spec.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index 9f413f8bff..5cecd423d7 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -17,10 +17,11 @@ describe("multibyte rendering", function() screen = Screen.new(60, 6) screen:attach({rgb=true}) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, + [1] = {bold = true, foreground = Screen.colors.Blue}, [2] = {background = Screen.colors.WebGray}, [3] = {background = Screen.colors.LightMagenta}, [4] = {bold = true}, + [5] = {foreground = Screen.colors.Blue}, }) end) @@ -119,6 +120,19 @@ describe("multibyte rendering", function() ]]) end) + it('0xffff is shown as 4 hex digits', function() + command([[call setline(1, "\uFFFF!!!")]]) + feed('$') + screen:expect{grid=[[ + {5:}!!^! | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('works with a lot of unicode (zalgo) text', function() screen:try_resize(65, 10) meths.buf_set_lines(0,0,-1,true, split(dedent [[ -- cgit From d90f5ab9ac0d9c9938510a187ddd8ecf28eb6d61 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Jun 2023 11:18:56 +0800 Subject: test(statusline): add test with control characters (#24197) --- test/functional/ui/statusline_spec.lua | 337 ++++++++++++++++++--------------- 1 file changed, 184 insertions(+), 153 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index c47b26f55e..7967fb6865 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -21,6 +21,10 @@ for _, model in ipairs(mousemodels) do before_each(function() clear() screen = Screen.new(40, 8) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText + [1] = {bold = true, reverse = true}; -- StatusLine + }) screen:attach() command('set laststatus=2 mousemodel=' .. model) exec([=[ @@ -30,163 +34,190 @@ for _, model in ipairs(mousemodels) do let g:testvar ..= '(' .. a:mods .. ')' endif endfunction + let g:testvar = '' ]=]) - end) - - it('works', function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 2 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 3 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 4 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 2 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 3 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 4 r', eval("g:testvar")) - end) - - it('works for winbar', function() - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 0, 17) - eq('0 1 r', eval("g:testvar")) - end) - - it('works for winbar in floating window', function() - meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5, - border = "single" }) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', - { scope = 'local' }) - meths.input_mouse('left', 'press', '', 0, 2, 23) - eq('0 1 l', eval("g:testvar")) - end) - - it('works when there are multiple windows', function() - command('split') - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 4, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('middle', 'press', '', 0, 3, 17) - eq('0 1 m', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - end) - - it('works with Lua function', function() - exec_lua([[ - function clicky_func(minwid, clicks, button, mods) - vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) - end - ]]) - meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - end) - - it('ignores unsupported click items', function() - command('tabnew | tabprevious') - meths.set_option_value('statusline', '%2TNot clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(1, meths.get_current_tabpage().id) - meths.set_option_value('statusline', '%2XNot clicky stuff%X', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(2, #meths.list_tabpages()) - end) - - it("right click works when statusline isn't focused #18994", function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 2 r', eval("g:testvar")) - end) - - it("works with modifiers #18994", function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks - meths.input_mouse('left', 'press', 'S', 0, 6, 17) - eq('0 1 l(s )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'S', 0, 6, 17) - eq('0 1 r(s )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'A', 0, 6, 17) - eq('0 1 l( a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'A', 0, 6, 17) - eq('0 1 r( a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'AS', 0, 6, 17) - eq('0 1 l(s a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'AS', 0, 6, 17) - eq('0 1 r(s a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'T', 0, 6, 17) - eq('0 1 l( m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'T', 0, 6, 17) - eq('0 1 r( m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'TS', 0, 6, 17) - eq('0 1 l(s m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'TS', 0, 6, 17) - eq('0 1 r(s m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'C', 0, 6, 17) - eq('0 1 l( c )', eval("g:testvar")) - -- is for tag jump - end) - - it("works for global statusline with vertical splits #19186", function() - command('set laststatus=3') - meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {}) - command('vsplit') - screen:expect([[ + end) + + it('works', function() + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.input_mouse('left', 'press', '', 0, 6, 16) + eq('', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 29) + eq('', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 2 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 3 l', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 4 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 28) + eq('0 1 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 28) + eq('0 2 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 28) + eq('0 3 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 28) + eq('0 4 r', eval("g:testvar")) + end) + + it('works with control characters and highlight', function() + meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:^I}{0:^A^I^A^I}{1:^A }| + | + ]]} + meths.input_mouse('right', 'press', '', 0, 6, 3) + eq('', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 8) + eq('', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 4) + eq('0 1 r', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 7) + eq('0 1 l', eval("g:testvar")) + end) + + it('works for winbar', function() + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 0, 17) + eq('0 1 r', eval("g:testvar")) + end) + + it('works for winbar in floating window', function() + meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5, + border = "single" }) + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + { scope = 'local' }) + meths.input_mouse('left', 'press', '', 0, 2, 23) + eq('0 1 l', eval("g:testvar")) + end) + + it('works when there are multiple windows', function() + command('split') + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 4, 17) + eq('0 1 r', eval("g:testvar")) + meths.input_mouse('middle', 'press', '', 0, 3, 17) + eq('0 1 m', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + end) + + it('works with Lua function', function() + exec_lua([[ + function clicky_func(minwid, clicks, button, mods) + vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) + end + ]]) + meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {}) + meths.input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval("g:testvar")) + end) + + it('ignores unsupported click items', function() + command('tabnew | tabprevious') + meths.set_option_value('statusline', '%2TNot clicky stuff%T', {}) + meths.input_mouse('left', 'press', '', 0, 6, 0) + eq(1, meths.get_current_tabpage().id) + meths.set_option_value('statusline', '%2XNot clicky stuff%X', {}) + meths.input_mouse('left', 'press', '', 0, 6, 0) + eq(2, #meths.list_tabpages()) + end) + + it("right click works when statusline isn't focused #18994", function() + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 1 r', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 17) + eq('0 2 r', eval("g:testvar")) + end) + + it("works with modifiers #18994", function() + meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks + meths.input_mouse('left', 'press', 'S', 0, 6, 17) + eq('0 1 l(s )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'S', 0, 6, 17) + eq('0 1 r(s )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'A', 0, 6, 17) + eq('0 1 l( a )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'A', 0, 6, 17) + eq('0 1 r( a )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'AS', 0, 6, 17) + eq('0 1 l(s a )', eval("g:testvar")) + meths.input_mouse('right', 'press', 'AS', 0, 6, 17) + eq('0 1 r(s a )', eval("g:testvar")) + meths.input_mouse('left', 'press', 'T', 0, 6, 17) + eq('0 1 l( m)', eval("g:testvar")) + meths.input_mouse('right', 'press', 'T', 0, 6, 17) + eq('0 1 r( m)', eval("g:testvar")) + meths.input_mouse('left', 'press', 'TS', 0, 6, 17) + eq('0 1 l(s m)', eval("g:testvar")) + meths.input_mouse('right', 'press', 'TS', 0, 6, 17) + eq('0 1 r(s m)', eval("g:testvar")) + meths.input_mouse('left', 'press', 'C', 0, 6, 17) + eq('0 1 l( c )', eval("g:testvar")) + -- is for tag jump + end) + + it("works for global statusline with vertical splits #19186", function() + command('set laststatus=3') + meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {}) + command('vsplit') + screen:expect{grid=[[ ^ │ | - ~ │~ | - ~ │~ | - ~ │~ | - ~ │~ | - ~ │~ | - Clicky stuff Clicky stuff| + {0:~ }│{0:~ }| + {0:~ }│{0:~ }| + {0:~ }│{0:~ }| + {0:~ }│{0:~ }| + {0:~ }│{0:~ }| + {1:Clicky stuff Clicky stuff}| | - ]]) - - -- clickable area on the right - meths.input_mouse('left', 'press', '', 0, 6, 35) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 35) - eq('0 1 r', eval("g:testvar")) - - -- clickable area on the left - meths.input_mouse('left', 'press', '', 0, 6, 5) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 5) - eq('0 1 r', eval("g:testvar")) - end) - - it('no memory leak with zero-width click labels', function() - command([[ - let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@' - ]]) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 39) - eq('0 1 r', eval("g:testvar")) - end) - - it('no memory leak with truncated click labels', function() - command([[ - let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '% Date: Thu, 29 Jun 2023 11:37:55 +0800 Subject: fix(column): handle unprintable chars in 'statuscolumn' (#24198) --- test/functional/ui/statuscolumn_spec.lua | 114 ++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 38 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 6624fb008d..d713580ca9 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local eq = helpers.eq +local exec = helpers.exec local eval = helpers.eval local exec_lua = helpers.exec_lua local feed = helpers.feed @@ -440,44 +441,81 @@ describe('statuscolumn', function() end) for _, model in ipairs(mousemodels) do - it("works with 'statuscolumn' clicks with mousemodel=" .. model, function() - command('set mousemodel=' .. model) - command([[ - function! MyClickFunc(minwid, clicks, button, mods) - let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) - if a:mods !=# ' ' - let g:testvar ..= '(' .. a:mods .. ')' - endif - endfunction - set stc=%0@MyClickFunc@%=%l%T - ]]) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 2 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 3 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 4 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 1 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 2 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 3 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 4 r 7', eval("g:testvar")) - command('set laststatus=2 winbar=%f') - command('let g:testvar=""') - -- Check that winbar click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 0, 0) - eq('', eval("g:testvar")) - -- Check that statusline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 12, 0) - eq('', eval("g:testvar")) - -- Check that cmdline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 13, 0) - eq('', eval("g:testvar")) + describe('with mousemodel=' .. model, function() + before_each(function() + command('set mousemodel=' .. model) + exec([[ + function! MyClickFunc(minwid, clicks, button, mods) + let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) + if a:mods !=# ' ' + let g:testvar ..= '(' .. a:mods .. ')' + endif + endfunction + let g:testvar = '' + ]]) + end) + + it('clicks work with mousemodel=' .. model, function() + meths.set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {}) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 1 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 2 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 3 l 4', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 0, 0) + eq('0 4 l 4', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 1 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 2 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 3 r 7', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 0) + eq('0 4 r 7', eval("g:testvar")) + command('set laststatus=2 winbar=%f') + command('let g:testvar = ""') + -- Check that winbar click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 0, 0) + eq('', eval("g:testvar")) + -- Check that statusline click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 12, 0) + eq('', eval("g:testvar")) + -- Check that cmdline click doesn't register as statuscolumn click + meths.input_mouse('right', 'press', '', 0, 13, 0) + eq('', eval("g:testvar")) + end) + + it('clicks and highlights work with control characters', function() + meths.set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + screen:expect{grid=[[ + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}^aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + | + ]], attr_ids={ + [0] = {foreground = Screen.colors.Blue, bold = true}; -- NonText + [1] = {foreground = Screen.colors.Brown}; -- LineNr + }} + meths.input_mouse('right', 'press', '', 0, 4, 3) + eq('', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 5, 8) + eq('', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 6, 4) + eq('0 1 r 10', eval("g:testvar")) + meths.input_mouse('left', 'press', '', 0, 7, 7) + eq('0 1 l 11', eval("g:testvar")) + end) end) end -- cgit From d7bb19e0138c7363ed40c142972c07e4e1912785 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 30 Jun 2023 08:36:09 +0800 Subject: fix(statusline): fill for double-width char after moving items (#24207) --- test/functional/ui/tabline_spec.lua | 73 +++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 12 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua index 2cdec62d01..befdb7c5d1 100644 --- a/test/functional/ui/tabline_spec.lua +++ b/test/functional/ui/tabline_spec.lua @@ -1,6 +1,9 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq +local insert = helpers.insert +local meths = helpers.meths +local assert_alive = helpers.assert_alive describe('ui/ext_tabline', function() local screen @@ -92,6 +95,10 @@ describe("tabline", function() clear() screen = Screen.new(42, 5) screen:attach() + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText + [1] = {reverse = true}; -- TabLineFill + }) end) it('redraws when tabline option is set', function() @@ -100,24 +107,18 @@ describe("tabline", function() screen:expect{grid=[[ {1:asdf }| ^ | - {2:~ }| - {2:~ }| + {0:~ }| + {0:~ }| | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {bold = true, foreground = Screen.colors.Blue1}; - }} + ]]} command('set tabline=jkl') screen:expect{grid=[[ {1:jkl }| ^ | - {2:~ }| - {2:~ }| + {0:~ }| + {0:~ }| | - ]], attr_ids={ - [1] = {reverse = true}; - [2] = {bold = true, foreground = Screen.colors.Blue}; - }} + ]]} end) it('click definitions do not leak memory #21765', function() @@ -125,4 +126,52 @@ describe("tabline", function() command('set showtabline=2') command('redrawtabline') end) + + it('clicks work with truncated double-width label #24187', function() + insert('tab1') + command('tabnew') + insert('tab2') + command('tabprev') + meths.set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {}) + screen:expect{grid=[[ + {1: Date: Mon, 3 Jul 2023 22:57:45 +0800 Subject: fix(plines): handle inline virtual text after last char (#24241) Also remove dead code in win_lbr_chartabsize(). --- test/functional/ui/decorations_spec.lua | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4c04bad3a0..8070ac550d 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1835,7 +1835,7 @@ describe('decorations: inline virtual text', function() ]]} end) - it('text is drawn correctly when inserting a wrapping virtual text on an empty line', function() + it('text is drawn correctly with a wrapping virtual text', function() feed('o') insert([[aaaaaaa @@ -1899,6 +1899,40 @@ bbbbbbb]]) {1:~ }| | ]]} + + feed('ggic') + screen:expect { grid = [[ + c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XX} | + aaaaaaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + bbbbbbb | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + end) + + it('regexp \\%V does not count trailing virtual text', function() + screen:try_resize(50, 4) + meths.buf_set_lines(0, 0, -1, true, {'foofoo', '', 'foofoo'}) + meths.buf_set_extmark(0, ns, 1, 0, { virt_text = {{'barbarbar', 'Special'}}, virt_text_pos = 'inline' }) + feed([[G5l/foo\n\%V]]) + screen:expect{grid=[[ + foo{12:^foo } | + {10:barbarbar} | + foofoo | + {16:search hit BOTTOM, continuing at TOP} | + ]]} + feed([[jIbaz/foo\nbaz\%V]]) + screen:expect{grid=[[ + foo{12:^foo } | + {12:baz}{10:barbarbar} | + foofoo | + {16:search hit BOTTOM, continuing at TOP} | + ]]} end) it('cursor position is correct with virtual text attached to hard tabs', function() -- cgit From e8b3ed74bca4bd6ececcc240f816451bef7fd58c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 4 Jul 2023 14:14:09 +0800 Subject: fix(ui-ext): "scroll_delta" handle topfill and skipcol (#24249) --- test/functional/ui/fold_spec.lua | 78 ++++++--- test/functional/ui/multigrid_spec.lua | 288 ++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+), 26 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 71b9e49d2f..2c8455753e 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1923,7 +1923,7 @@ describe("folded lines", function() meths.buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} }) meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} }) if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -1943,7 +1943,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 0, curcol = 0, linecount = 4, sum_scroll_delta = 0}; + }} else screen:expect([[ {5:^+-- 2 lines: line 1·························}| @@ -1959,7 +1961,7 @@ describe("folded lines", function() feed('jzfj') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -1979,7 +1981,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 2, curcol = 0, linecount = 4, sum_scroll_delta = 0}; + }} else screen:expect([[ {5:+-- 2 lines: line 1·························}| @@ -1996,7 +2000,7 @@ describe("folded lines", function() feed('kzo') funcs.setline(5, 'line 5') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2016,7 +2020,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1}; + }} else screen:expect([[ virt_line above line 1 | @@ -2044,7 +2050,7 @@ describe("folded lines", function() meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} }) feed('G') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2064,7 +2070,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 0}; + }} else screen:expect([[ line 1 | @@ -2080,7 +2088,7 @@ describe("folded lines", function() feed('') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2100,7 +2108,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 1, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 1}; + }} else screen:expect([[ line 2 | @@ -2116,7 +2126,7 @@ describe("folded lines", function() feed('') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2136,7 +2146,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; + }} else screen:expect([[ virt_line below line 2 | @@ -2152,7 +2164,7 @@ describe("folded lines", function() feed('') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2172,7 +2184,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3}; + }} else screen:expect([[ more virt_line below line 2 | @@ -2188,7 +2202,7 @@ describe("folded lines", function() feed('') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2208,7 +2222,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 4}; + }} else screen:expect([[ {5:+-- 2 lines: line 3·························}| @@ -2224,7 +2240,7 @@ describe("folded lines", function() feed('') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2244,7 +2260,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 4, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 5}; + }} else screen:expect([[ ^line 5 | @@ -2260,7 +2278,7 @@ describe("folded lines", function() feed('3') if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2280,7 +2298,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; + }} else screen:expect([[ virt_line below line 2 | @@ -2296,7 +2316,7 @@ describe("folded lines", function() meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2316,7 +2336,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 {11:-- VISUAL LINE --} | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; + }} else screen:expect([[ virt_line below line 2 | @@ -2332,7 +2354,7 @@ describe("folded lines", function() meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2352,7 +2374,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 {11:-- VISUAL LINE --} | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3}; + }} else screen:expect([[ more virt_line below line 2 | @@ -2368,7 +2392,7 @@ describe("folded lines", function() meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) if multigrid then - screen:expect([[ + screen:expect{grid=[[ ## grid 1 [2:---------------------------------------------]| [2:---------------------------------------------]| @@ -2388,7 +2412,9 @@ describe("folded lines", function() {1:~ }| ## grid 3 {11:-- VISUAL LINE --} | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 5, linecount = 5, sum_scroll_delta = 4}; + }} else screen:expect([[ {5:+-- 2 lines: line 3·························}| diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 8918c46de6..d643a77be7 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3341,6 +3341,294 @@ describe('ext_multigrid', function() [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, [4] = {win = {id = 1001}, topline = 6, botline = 10, curline = 6, curcol = 0, linecount = 11, sum_scroll_delta = 5}, }} + + command('close | 21vsplit | setlocal number smoothscroll') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {19: 1 }Lorem ipsu^m dolor| + {19: } sit amet, consec| + {19: }tetur | + {19: 2 }adipisicing elit,| + {19: } sed do eiusmod t| + {19: }empor | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + }} + + feed('5') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {1:<<<}{19: }empo^r | + {19: 3 }incididunt ut lab| + {19: }ore et dolore mag| + {19: }na aliqua. | + {19: 4 }Ut enim ad minim | + {19: }veniam, quis n{1:@@@}| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 5}; + }} + + feed('') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {1:<<<}{19: } sed do eiusmod t| + {19: }empo^r | + {19: 3 }incididunt ut lab| + {19: }ore et dolore mag| + {19: }na aliqua. | + {19: 4 }Ut enim ad min{1:@@@}| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; + }} + + command('set cpoptions+=n') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {1:<<<}d do eiusmod tempo| + ^r | + {19: 3 }incididunt ut lab| + ore et dolore magna a| + liqua. | + {19: 4 }Ut enim ad min{1:@@@}| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; + }} + + feed('4') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {1:<<<}ua^. | + {19: 4 }Ut enim ad minim | + veniam, quis nostrud | + {19: 5 }exercitation ulla| + mco laboris nisi ut a| + liquip ex | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 2, botline = 6, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; + }} + + feed('2') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {19: 3 }incididunt ut lab| + ore et dolore magna a| + liqua^. | + {19: 4 }Ut enim ad minim | + veniam, quis nostrud | + {19: 5 }exercitation u{1:@@@}| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; + }} + + command('setlocal numberwidth=12') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {19: 3 }incididun| + t ut labore et dolore| + magna aliqua^. | + {19: 4 }Ut enim a| + d minim veniam, quis | + nostrud | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; + }} + + feed('2') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {1:<<<}gna aliqua^. | + {19: 4 }Ut enim a| + d minim veniam, quis | + nostrud | + {19: 5 }exercitat| + ion ullamco labori{1:@@@}| + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; + }} + + feed('') + screen:expect{grid=[[ + ## grid 1 + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]| + {11:[No Name] [+] }{12:[No Name] [+] }| + [3:------------------------------------------------]| + ## grid 2 + Lorem ipsum dolor sit amet| + , consectetur | + adipisicing elit, sed do e| + iusmod tempor | + incididunt ut labore et do| + lore magna aliqua. | + ## grid 3 + | + ## grid 5 + {19: 4 }Ut enim a| + d minim veniam, quis | + nostru^d | + {19: 5 }exercitat| + ion ullamco laboris n| + isi ut aliquip ex | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 3, botline = 6, curline = 3, curcol = 36, linecount = 11, sum_scroll_delta = 9}; + }} end) it('does not crash when dragging mouse across grid boundary', function() -- cgit From a76b689b479e89d6feae687443d13ec38602a1a6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 4 Jul 2023 16:48:53 +0800 Subject: perf(ui-ext): approximate scroll_delta when scrolling too much (#24234) --- test/functional/ui/multigrid_spec.lua | 215 ++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index d643a77be7..2e66068037 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3631,6 +3631,221 @@ describe('ext_multigrid', function() }} end) + it('scroll_delta is approximated reasonably when scrolling many lines #24234', function() + command('setlocal number nowrap') + command('edit test/functional/fixtures/bigfile.txt') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19: 1 }^0000;;Cc;0;BN;;;;;N;NULL;;;; | + {19: 2 }0001;;Cc;0;BN;;;;;N;START OF HEADING;;| + {19: 3 }0002;;Cc;0;BN;;;;;N;START OF TEXT;;;; | + {19: 4 }0003;;Cc;0;BN;;;;;N;END OF TEXT;;;; | + {19: 5 }0004;;Cc;0;BN;;;;;N;END OF TRANSMISSIO| + {19: 6 }0005;;Cc;0;BN;;;;;N;ENQUIRY;;;; | + {19: 7 }0006;;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | + {19: 8 }0007;;Cc;0;BN;;;;;N;BELL;;;; | + {19: 9 }0008;;Cc;0;BN;;;;;N;BACKSPACE;;;; | + {19: 10 }0009;;Cc;0;S;;;;;N;CHARACTER TABULATIO| + {19: 11 }000A;;Cc;0;B;;;;;N;LINE FEED (LF);;;; | + {19: 12 }000B;;Cc;0;S;;;;;N;LINE TABULATION;;;;| + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + }} + feed('G') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19:30581 }E01E8;VARIATION SELECTOR-249;Mn;0;NSM;;;;;N;;;;| + {19:30582 }E01E9;VARIATION SELECTOR-250;Mn;0;NSM;;;;;N;;;;| + {19:30583 }E01EA;VARIATION SELECTOR-251;Mn;0;NSM;;;;;N;;;;| + {19:30584 }E01EB;VARIATION SELECTOR-252;Mn;0;NSM;;;;;N;;;;| + {19:30585 }E01EC;VARIATION SELECTOR-253;Mn;0;NSM;;;;;N;;;;| + {19:30586 }E01ED;VARIATION SELECTOR-254;Mn;0;NSM;;;;;N;;;;| + {19:30587 }E01EE;VARIATION SELECTOR-255;Mn;0;NSM;;;;;N;;;;| + {19:30588 }E01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;| + {19:30589 }F0000;;Co;0;L;;;;;| + {19:30590 }FFFFD;;Co;0;L;;;;;N| + {19:30591 }100000;;Co;0;L;;;;| + {19:30592 }^10FFFD;;Co;0;L;;;;;| + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 30580, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30580}; + }} + feed('gg') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19: 1 }^0000;;Cc;0;BN;;;;;N;NULL;;;; | + {19: 2 }0001;;Cc;0;BN;;;;;N;START OF HEADING;;| + {19: 3 }0002;;Cc;0;BN;;;;;N;START OF TEXT;;;; | + {19: 4 }0003;;Cc;0;BN;;;;;N;END OF TEXT;;;; | + {19: 5 }0004;;Cc;0;BN;;;;;N;END OF TRANSMISSIO| + {19: 6 }0005;;Cc;0;BN;;;;;N;ENQUIRY;;;; | + {19: 7 }0006;;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | + {19: 8 }0007;;Cc;0;BN;;;;;N;BELL;;;; | + {19: 9 }0008;;Cc;0;BN;;;;;N;BACKSPACE;;;; | + {19: 10 }0009;;Cc;0;S;;;;;N;CHARACTER TABULATIO| + {19: 11 }000A;;Cc;0;B;;;;;N;LINE FEED (LF);;;; | + {19: 12 }000B;;Cc;0;S;;;;;N;LINE TABULATION;;;;| + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + }} + command('setlocal wrap') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19: 1 }^0000;;Cc;0;BN;;;;;N;NULL;;;; | + {19: 2 }0001;;Cc;0;BN;;;;;N;START OF HEADING;;| + {19: };; | + {19: 3 }0002;;Cc;0;BN;;;;;N;START OF TEXT;;;; | + {19: 4 }0003;;Cc;0;BN;;;;;N;END OF TEXT;;;; | + {19: 5 }0004;;Cc;0;BN;;;;;N;END OF TRANSMISSIO| + {19: }N;;;; | + {19: 6 }0005;;Cc;0;BN;;;;;N;ENQUIRY;;;; | + {19: 7 }0006;;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | + {19: 8 }0007;;Cc;0;BN;;;;;N;BELL;;;; | + {19: 9 }0008;;Cc;0;BN;;;;;N;BACKSPACE;;;; | + {19: 10 }0009;;Cc;0;S;;;;;N;CHARACTER TABULA{1:@@@}| + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + }} + feed('G') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19:30587 }E01EE;VARIATION SELECTOR-255;Mn;0;NSM;;;;;N;;;;| + {19: }; | + {19:30588 }E01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;| + {19: }; | + {19:30589 }F0000;;Co;0;L;;;;;| + {19: }N;;;;; | + {19:30590 }FFFFD;;Co;0;L;;;;;N| + {19: };;;;; | + {19:30591 }100000;;Co;0;L;;;;| + {19: };N;;;;; | + {19:30592 }^10FFFD;;Co;0;L;;;;;| + {19: }N;;;;; | + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 30586, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30588}; + }} + command('autocmd CursorMoved * ++once call line("w$")') -- FIXME: this should not be needed + feed('gg') + screen:expect{grid=[[ + ## grid 1 + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]| + {11:test/functional/fixtures/bigfile.txt }| + [3:-----------------------------------------------------]| + ## grid 2 + {19: 1 }^0000;;Cc;0;BN;;;;;N;NULL;;;; | + {19: 2 }0001;;Cc;0;BN;;;;;N;START OF HEADING;;| + {19: };; | + {19: 3 }0002;;Cc;0;BN;;;;;N;START OF TEXT;;;; | + {19: 4 }0003;;Cc;0;BN;;;;;N;END OF TEXT;;;; | + {19: 5 }0004;;Cc;0;BN;;;;;N;END OF TRANSMISSIO| + {19: }N;;;; | + {19: 6 }0005;;Cc;0;BN;;;;;N;ENQUIRY;;;; | + {19: 7 }0006;;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; | + {19: 8 }0007;;Cc;0;BN;;;;;N;BELL;;;; | + {19: 9 }0008;;Cc;0;BN;;;;;N;BACKSPACE;;;; | + {19: 10 }0009;;Cc;0;S;;;;;N;CHARACTER TABULA{1:@@@}| + ## grid 3 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + }} + end) + it('does not crash when dragging mouse across grid boundary', function() screen:try_resize(48, 8) screen:expect{grid=[[ -- cgit From 1de82e16c1216e1dbe22cf7a8ec9ea9e9e69b631 Mon Sep 17 00:00:00 2001 From: fredizzimo Date: Wed, 5 Jul 2023 16:31:34 +0300 Subject: fix(ui): delay win_viewport until screen update #24182 Problem: Sometimes, when nvim sends the `win_viewport` event, for example when scrolling with visible folds on the screen, it reports the `scroll_delta` value one batch into "future". So when the client application is trying to show the new viewport it's not yet updated, resulting in temporary corruption / screen flickering. For more details see #23609, and starting from [this comment]( https://github.com/neovide/neovide/pull/1790#issuecomment-1518697747) in https://github.com/neovide/neovide/pull/1790,, where the issue was first detected. Note that some of the conclusions in those are not fully accurate, but the general observations are. Solution: When there are pending updates to a Window, delay the `win_viewport` UI event until the updates are sent. This ensures that there's no flush between sending the viewport and updating of the lines corresponding to the new viewport. Document the existing viewport behaviour (for cases where there are no extra flushes), give a hint about how applications can deal with the slightly surprising behaviour of the viewport event being sent after the updates. Fixes https://github.com/neovim/neovim/issues/23609 --- test/functional/ui/multigrid_spec.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 2e66068037..1778c8218b 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3808,7 +3808,6 @@ describe('ext_multigrid', function() ]], win_viewport={ [2] = {win = {id = 1000}, topline = 30586, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30588}; }} - command('autocmd CursorMoved * ++once call line("w$")') -- FIXME: this should not be needed feed('gg') screen:expect{grid=[[ ## grid 1 -- cgit From 25e62697c32e43d978e43776f9a01cd62bfe83be Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 6 Jul 2023 11:07:23 +0800 Subject: fix(column): fix wrong cursor with 'statuscolumn' and cpo+=n (#24268) --- test/functional/ui/statuscolumn_spec.lua | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index d713580ca9..6a1c20ff67 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -356,6 +356,64 @@ describe('statuscolumn', function() {2: }{1: │}{2: }{1: }aaaaaaaaaaaaaaaaaaaa | | ]]) + -- Also test fold and sign column when 'cpoptions' includes "n" + command('set cpoptions+=n') + feed('Hgjg0') + screen:expect([[ + {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2: }{5:^aaaaaaaaaaaaaaaaaaaa }| + {2: }{1: 3│}{0:>!}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 2│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2:+}{1: 4│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| + {2: }{1: 1│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + | + ]]) + command('set breakindent') + feed('J2gjg0') + screen:expect([[ + {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2: } {5:aaaaaaaaaaaaaaaaaaaa aaaaaaaaa}| + {2: } {5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2: } {5:^aaaaaaaaaaa }| + {2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: } aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: } aaaaaaaaaaaaaaaaaaaa | + {2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| + {2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: } aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: } aaaaaaaaaaaaaaaaaaaa | + | + ]]) + command('set nobreakindent') + feed('$g0') + screen:expect([[ + {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2: }{5:aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa}| + {2: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {2: }{5:^aaa }| + {2: }{1: 1│>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>>}{0:>!}{1:>> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 2│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2:+}{1: 3│}{2: }{1: }{3:+-- 1 line: aaaaaaaaaaaaaaaaa}| + {2: }{1: 4│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + {2: }{1: 5│}{2: }{1: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {2: }aaaaaaaaaaaaaaaaaaaa | + | + ]]) + command('silent undo') + feed('8gg') + command('set cpoptions-=n') -- Status column is re-evaluated for virt_lines, buffer line, and wrapped line exec_lua([[ vim.api.nvim_buf_set_extmark(0, ns, 5, 0, { -- cgit From 36941942d60915d9f78defd6aaf713a27952e16a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Jul 2023 07:21:12 +0800 Subject: fix(drawline): inline virt_text hl_mode inside syntax/extmark hl (#24273) --- test/functional/ui/decorations_spec.lua | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 8070ac550d..0c4df563cc 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2107,6 +2107,49 @@ bbbbbbb]]) ]]} end) + it('inside highlight range of another extmark', function() + insert('foo foo foo foo\nfoo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) + meths.buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) + screen:expect{grid=[[ + foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('inside highlight range of syntax', function() + insert('foo foo foo foo\nfoo foo foo foo') + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + command([[syntax match Search 'foo \zsfoo foo\ze foo']]) + screen:expect{grid=[[ + foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + it('cursor position is correct when inserting around a virtual text with right gravity set to false', function() insert('foo foo foo foo') meths.buf_set_extmark(0, ns, 0, 8, -- cgit From 811140e276a6312775bfcf9b368de25386f7a356 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 7 Jul 2023 09:49:58 +0800 Subject: fix(folds): fix missing virt_lines above when fold is hidden (#24274) --- test/functional/ui/fold_spec.lua | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 2c8455753e..d3119ccc42 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2427,6 +2427,83 @@ describe("folded lines", function() {11:-- VISUAL LINE --} | ]]) end + + feed('gg') + command('botright 1split | wincmd w') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + {3:[No Name] [+] }| + [4:---------------------------------------------]| + {2:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + ^line 1 | + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + ## grid 3 + | + ## grid 4 + line 1 | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; + }} + else + screen:expect([[ + ^line 1 | + line 2 | + virt_line below line 2 | + more virt_line below line 2 | + {3:[No Name] [+] }| + line 1 | + {2:[No Name] [+] }| + | + ]]) + end + + feed('') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + {3:[No Name] [+] }| + [4:---------------------------------------------]| + {2:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + virt_line above line 1 | + ^line 1 | + line 2 | + virt_line below line 2 | + ## grid 3 + | + ## grid 4 + line 1 | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; + }} + else + screen:expect([[ + virt_line above line 1 | + ^line 1 | + line 2 | + virt_line below line 2 | + {3:[No Name] [+] }| + line 1 | + {2:[No Name] [+] }| + | + ]]) + end end) it('Folded and Visual highlights are combined #19691', function() -- cgit From c4df2f08b689a17f838d40c6921a1d67c45995ad Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sat, 8 Jul 2023 11:53:30 +1000 Subject: fix(extmarks): fix wrong highlight after "combine" virt_text (#24281) --- test/functional/ui/decorations_spec.lua | 64 ++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 17 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 0c4df563cc..5eb9f9bc0a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1596,6 +1596,7 @@ describe('decorations: inline virtual text', function() [18] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Red}; [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.SlateBlue}; [20] = {background = Screen.colors.LightGrey, foreground = Screen.colors.SlateBlue}; + [21] = {reverse = true, foreground = Screen.colors.SlateBlue} } ns = meths.create_namespace 'test' @@ -2036,15 +2037,15 @@ bbbbbbb]]) end) it('search highlight is correct', function() - insert('foo foo foo foo\nfoo foo foo foo') + insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) screen:expect { grid = [[ - ^foo foo f{10:AAABBB}oo foo | - foo foo f{10:CCCDDD}oo foo | + ^foo foo f{10:AAABBB}oo bar | + foo foo f{10:CCCDDD}oo bar | {1:~ }| {1:~ }| {1:~ }| @@ -2057,8 +2058,23 @@ bbbbbbb]]) feed('/foo') screen:expect { grid = [[ - {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} {12:foo} | - {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} {12:foo} | + {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar | + {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /foo^ | + ]]} + + meths.buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + feed('') + screen:expect{ grid = [[ + {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | + {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | {1:~ }| {1:~ }| {1:~ }| @@ -2071,7 +2087,7 @@ bbbbbbb]]) end) it('visual select highlight is correct', function() - insert('foo foo foo foo\nfoo foo foo foo') + insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) @@ -2079,8 +2095,8 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') screen:expect { grid = [[ - foo foo {10:AAABBB}^foo foo | - foo foo {10:CCCDDD}foo foo | + foo foo {10:AAABBB}^foo bar | + foo foo {10:CCCDDD}foo bar | {1:~ }| {1:~ }| {1:~ }| @@ -2094,8 +2110,22 @@ bbbbbbb]]) feed('') feed('2hj') screen:expect { grid = [[ - foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo foo | - foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo foo | + foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo bar | + foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + + meths.buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + screen:expect { grid = [[ + foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | + foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | {1:~ }| {1:~ }| {1:~ }| @@ -2108,7 +2138,7 @@ bbbbbbb]]) end) it('inside highlight range of another extmark', function() - insert('foo foo foo foo\nfoo foo foo foo') + insert('foo foo foo bar\nfoo foo foo bar') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) @@ -2116,8 +2146,8 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) meths.buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) screen:expect{grid=[[ - foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | - foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | {1:~ }| {1:~ }| {1:~ }| @@ -2130,15 +2160,15 @@ bbbbbbb]]) end) it('inside highlight range of syntax', function() - insert('foo foo foo foo\nfoo foo foo foo') + insert('foo foo foo bar\nfoo foo foo bar') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - command([[syntax match Search 'foo \zsfoo foo\ze foo']]) + command([[syntax match Search 'foo \zsfoo foo\ze bar']]) screen:expect{grid=[[ - foo {12:foo }{10:AAA}{19:BBB}{12:foo} foo | - foo {12:foo }{19:CCC}{10:DDD}{12:foo} fo^o | + foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | + foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | {1:~ }| {1:~ }| {1:~ }| -- cgit From 06694203e51efbabc0b49e26704dff089011fd21 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 11 Jul 2023 13:16:31 +0800 Subject: fix(drawline): fix missing Visual hl on double-width fold char (#24308) --- test/functional/ui/fold_spec.lua | 212 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 196 insertions(+), 16 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index d3119ccc42..f00fba331e 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2509,18 +2509,18 @@ describe("folded lines", function() it('Folded and Visual highlights are combined #19691', function() command('hi! Visual guibg=Red') insert([[ - " foo - " {{{1 + " foofoofoofoofoofoo + " 口 {{{1 set nocp " }}}1 - " bar - " {{{1 + " barbarbarbarbarbar + " 口 {{{1 set foldmethod=marker " }}}1 - " baz]]) + " bazbazbazbazbazbaz]]) feed('gg') command('source') - feed('G3l') + feed('G15l') if multigrid then screen:expect([[ ## grid 1 @@ -2533,11 +2533,11 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {14:" fo}o | - {15:+-- }{5: 3 lines: "······························}| - {14:" ba}r | - {15:+-- }{5: 3 lines: "······························}| - {14:" b}^az | + {14:" foofoofoofoofo}ofoo | + {15:+-- 3 lines: " }{5:口···························}| + {14:" barbarbarbarba}rbar | + {15:+-- 3 lines: " }{5:口···························}| + {14:" bazbazbazbazb}^azbaz | {1:~ }| {1:~ }| ## grid 3 @@ -2545,11 +2545,191 @@ describe("folded lines", function() ]]) else screen:expect([[ - {14:" fo}o | - {15:+-- }{5: 3 lines: "······························}| - {14:" ba}r | - {15:+-- }{5: 3 lines: "······························}| - {14:" b}^az | + {14:" foofoofoofoofo}ofoo | + {15:+-- 3 lines: " }{5:口···························}| + {14:" barbarbarbarba}rbar | + {15:+-- 3 lines: " }{5:口···························}| + {14:" bazbazbazbazb}^azbaz | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + + feed('l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {14:" foofoofoofoofoo}foo | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" barbarbarbarbar}bar | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" bazbazbazbazba}^zbaz | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + {14:" foofoofoofoofoo}foo | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" barbarbarbarbar}bar | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" bazbazbazbazba}^zbaz | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + + feed('l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {14:" foofoofoofoofoof}oo | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" barbarbarbarbarb}ar | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" bazbazbazbazbaz}^baz | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + {14:" foofoofoofoofoof}oo | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" barbarbarbarbarb}ar | + {15:+-- 3 lines: " 口}{5:···························}| + {14:" bazbazbazbazbaz}^baz | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + + feed('2l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {14:" foofoofoofoofoofoo} | + {15:+-- 3 lines: " 口··}{5:·························}| + {14:" barbarbarbarbarbar} | + {15:+-- 3 lines: " 口··}{5:·························}| + {14:" bazbazbazbazbazba}^z | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + {14:" foofoofoofoofoofoo} | + {15:+-- 3 lines: " 口··}{5:·························}| + {14:" barbarbarbarbarbar} | + {15:+-- 3 lines: " 口··}{5:·························}| + {14:" bazbazbazbazbazba}^z | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + + feed('O16l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + " foofoofoofoofo{14:ofoo} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " barbarbarbarba{14:rbar} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " bazbazbazbazba^z{14:baz} | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + " foofoofoofoofo{14:ofoo} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " barbarbarbarba{14:rbar} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " bazbazbazbazba^z{14:baz} | + {1:~ }| + {1:~ }| + {11:-- VISUAL BLOCK --} | + ]]) + end + + feed('l') + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + " foofoofoofoofoo{14:foo} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " barbarbarbarbar{14:bar} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " bazbazbazbazbaz^b{14:az} | + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL BLOCK --} | + ]]) + else + screen:expect([[ + " foofoofoofoofoo{14:foo} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " barbarbarbarbar{14:bar} | + {5:+-- 3 lines: " }{15:口··}{5:·························}| + " bazbazbazbazbaz^b{14:az} | {1:~ }| {1:~ }| {11:-- VISUAL BLOCK --} | -- cgit From bf52fb7193ca08ceca292cfca9156380a6661979 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Jul 2023 08:50:34 +0800 Subject: fix(mouse): copy the line before syntax matching (#24320) --- test/functional/ui/mouse_spec.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index d8739e1c31..621855f051 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1024,13 +1024,15 @@ describe('ui/mouse/input', function() }) feed('ggdG') - feed_command('set concealcursor=ni') - feed_command('set nowrap') - feed_command('set shiftwidth=2 tabstop=4 list') - feed_command('setl listchars=tab:>-') - feed_command('syntax match NonText "\\*" conceal') - feed_command('syntax match NonText "cats" conceal cchar=X') - feed_command('syntax match NonText "x" conceal cchar=>') + command([[setlocal concealcursor=ni nowrap shiftwidth=2 tabstop=4 list listchars=tab:>-]]) + command([[syntax region X0 matchgroup=X1 start=/\*/ end=/\*/ concealends contains=X2]]) + command([[syntax match X2 /cats/ conceal cchar=X contained]]) + -- No heap-use-after-free with multi-line syntax pattern #24317 + command([[syntax match X3 /\n\@<=x/ conceal cchar=>]]) + command([[highlight link X0 Normal]]) + command([[highlight link X1 NonText]]) + command([[highlight link X2 NonText]]) + command([[highlight link X3 NonText]]) -- First column is there to retain the tabs. insert([[ -- cgit From 9359701eae7bd8a59e4a916e085cc686f609d693 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Jul 2023 07:02:06 +0800 Subject: test(extmarks): add test for virt_text_win_col with cpo+=n (#24328) --- test/functional/ui/decorations_spec.lua | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 5eb9f9bc0a..b526aa86c8 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1130,7 +1130,45 @@ describe('extmark decorations', function() | ]]} - command 'set nowrap' + command 'set number' + screen:expect{grid=[[ + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + {2: }m) | + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| + {2: }_id = hl_id_cell {4:Error} {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + | + ]]} + + command 'set cpoptions+=n' + screen:expect{grid=[[ + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + m) | + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| + _id = hl_id_cell {4:Error} {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + | + ]]} + + command 'set cpoptions-=n nonumber nowrap' screen:expect{grid=[[ for _,item in ipairs(items) do | local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| @@ -1149,7 +1187,7 @@ describe('extmark decorations', function() | ]]} - feed('8zl') + feed '8zl' screen:expect{grid=[[ em in ipairs(items) do | l text, hl_id_cell, count = unp{4:Very}item) {4:VERY}| -- cgit From 0ce39108684ed7b6af03e47da0a4e0a022e41936 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Jul 2023 08:32:17 +0800 Subject: fix(ui): cursor pos with left gravity inline virt_text at eol (#24329) Problem: Cursor is not after inline virtual text with left gravity when inserting after the end of the line. Solution: Add width of inline virtual text with left gravity to cursor virtcol in Insert mode even if on a NUL. --- test/functional/ui/decorations_spec.lua | 124 +++++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 26 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index b526aa86c8..cee1e32114 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2218,71 +2218,143 @@ bbbbbbb]]) ]]} end) - it('cursor position is correct when inserting around a virtual text with right gravity set to false', function() + it('cursor position is correct when inserting around a virtual text with left gravity', function() + screen:try_resize(50, 3) insert('foo foo foo foo') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) feed('0') feed('8l') - screen:expect { grid = [[ + screen:expect{grid=[[ foo foo {10:virtual text}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('i') - screen:expect { grid = [[ + screen:expect{grid=[[ foo foo {10:virtual text}^foo foo | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed([[]]) + screen:expect{grid=[[ + foo foo {10:virtual text}^foo foo | {1:~ }| + {8:-- (insert) --} | + ]]} + + feed('D') + screen:expect{grid=[[ + foo foo {10:virtual text}^ | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('') + screen:expect{grid=[[ + {10:virtual text}^ | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('a') + screen:expect{grid=[[ + {10:virtual text}a^ | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('') + screen:expect{grid=[[ + {10:virtual text}^a | {1:~ }| + | + ]]} + + feed('x') + screen:expect{grid=[[ + {10:^virtual text} | {1:~ }| - {1:~ }| - {8:-- INSERT --} | - ]]} + | + ]]} end) it('cursor position is correct when inserting around virtual texts with both left and right gravity', function() + screen:try_resize(50, 3) insert('foo foo foo foo') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) feed('08l') - screen:expect{ grid = [[ + screen:expect{grid=[[ foo foo {10:>><<}^foo foo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('i') - screen:expect { grid = [[ + screen:expect{grid=[[ foo foo {10:>>^<<}foo foo | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('a') + screen:expect{grid=[[ + foo foo {10:>>}a{10:^<<}foo foo | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed([[]]) + screen:expect{grid=[[ + foo foo {10:>>}a{10:<<}^foo foo | {1:~ }| + {8:-- (insert) --} | + ]]} + + feed('D') + screen:expect{grid=[[ + foo foo {10:>>}a{10:^<<} | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('') + screen:expect{grid=[[ + foo foo {10:>>^<<} | {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('') + screen:expect{grid=[[ + {10:>>^<<} | {1:~ }| - {1:~ }| + {8:-- INSERT --} | + ]]} + + feed('a') + screen:expect{grid=[[ + {10:>>}a{10:^<<} | {1:~ }| {8:-- INSERT --} | - ]]} + ]]} + + feed('') + screen:expect{grid=[[ + {10:>>}^a{10:<<} | + {1:~ }| + | + ]]} + + feed('x') + screen:expect{grid=[[ + {10:^>><<} | + {1:~ }| + | + ]]} end) it('draws correctly with no wrap multiple virtual text, where one is hidden', function() -- cgit From b60a2ab4cb7bb7d86dcda1dfe2396a9eda384e35 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 17 Jul 2023 10:15:45 +0800 Subject: fix(inccommand): block errors when parsing command line again (#24374) Revert the change to ex_getln.c from a741c7fd0465c949a0016fcbee5f4526b65f8c02 --- test/functional/ui/inccommand_spec.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 23b200bd24..dc4aeb9c83 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3086,8 +3086,7 @@ end) it('long :%s/ with inccommand does not collapse cmdline', function() clear() local screen = Screen.new(10,5) - common_setup(screen) - command('set inccommand=nosplit') + common_setup(screen, 'nosplit') feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A') screen:expect([[ @@ -3099,6 +3098,21 @@ it('long :%s/ with inccommand does not collapse cmdline', function() ]]) end) +it("with 'inccommand' typing invalid `={expr}` does not show error", function() + clear() + local screen = Screen.new(30, 6) + common_setup(screen, 'nosplit') + feed(':edit `=`') + screen:expect([[ + | + {15:~ }| + {15:~ }| + {15:~ }| + {15:~ }| + :edit `=`^ | + ]]) +end) + it("with 'inccommand' typing :filter doesn't segfault or leak memory #19057", function() clear() common_setup(nil, 'nosplit') -- cgit From 30a5c28c8740d2e07c20cb58822b7d7aa489b728 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Wed, 19 Jul 2023 17:56:25 +0200 Subject: feat(decoration_provider): log errors as error messages --- test/functional/ui/decorations_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index cee1e32114..ef55784ca8 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -37,6 +37,7 @@ describe('decorations providers', function() [15] = {special = Screen.colors.Blue, undercurl = true}, [16] = {special = Screen.colors.Red, undercurl = true}, [17] = {foreground = Screen.colors.Red}, + [18] = {bold = true, foreground = Screen.colors.SeaGreen}; } end) @@ -611,6 +612,27 @@ describe('decorations providers', function() assert(eok == false) ]]) end) + + it('errors gracefully', function() + insert(mulholland) + + setup_provider [[ + function on_do(...) + error "Foo" + end + ]] + + screen:expect{grid=[[ + {2:Error in decoration provider ns1.start:} | + {2:Error executing lua: [string ""]:4}| + {2:: Foo} | + {2:stack traceback:} | + {2: [C]: in function 'error'} | + {2: [string ""]:4: in function}| + {2: <[string ""]:3>} | + {18:Press ENTER or type command to continue}^ | + ]]} + end) end) local example_text = [[ -- cgit From a8cfdf43bc6226e32679ec59769ea3e48ca26193 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jul 2023 07:16:41 +0800 Subject: fix(events): trigger VimResume on next UI request (#24426) --- test/functional/ui/screen_basic_spec.lua | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 5d5be2e807..bc9517aa60 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -4,7 +4,6 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq -local eval = helpers.eval local funcs, meths = helpers.funcs, helpers.meths describe('screen', function() @@ -64,34 +63,6 @@ local function screen_tests(linegrid) } ) end) - describe(':suspend', function() - it('is forwarded to the UI', function() - local function check() - eq(true, screen.suspended) - end - - command('let g:ev = []') - command('autocmd VimResume * :call add(g:ev, "r")') - command('autocmd VimSuspend * :call add(g:ev, "s")') - - eq(false, screen.suspended) - command('suspend') - eq({ 's', 'r' }, eval('g:ev')) - - screen:expect(check) - screen.suspended = false - - feed('') - eq({ 's', 'r', 's', 'r' }, eval('g:ev')) - - screen:expect(check) - screen.suspended = false - - command('suspend') - eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev')) - end) - end) - describe('bell/visual bell', function() it('is forwarded to the UI', function() feed('') -- cgit From 59289fb987bd51b072f91ae0de8ee8515bf07e21 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 23 Jul 2023 21:36:32 +0800 Subject: fix(highlight): make CurSearch work properly with 'winhl' (#24448) --- test/functional/ui/searchhl_spec.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 1e42689200..ec1ebbe4ca 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -56,7 +56,7 @@ describe('search highlighting', function() }} end) - it('works', function() + local function test_search_hl() insert([[ some text more textstuff @@ -109,6 +109,26 @@ describe('search highlighting', function() {1:~ }| :nohlsearch | ]]) + end + + it("works when 'winhighlight' is not set", function() + test_search_hl() + end) + + it("works when 'winhighlight' doesn't change Search highlight", function() + command('setlocal winhl=NonText:Underlined') + local attrs = screen:get_default_attr_ids() + attrs[1] = {foreground = Screen.colors.SlateBlue, underline = true} + screen:set_default_attr_ids(attrs) + test_search_hl() + end) + + it("works when 'winhighlight' changes Search highlight", function() + command('setlocal winhl=Search:Underlined') + local attrs = screen:get_default_attr_ids() + attrs[2] = {foreground = Screen.colors.SlateBlue, underline = true} + screen:set_default_attr_ids(attrs) + test_search_hl() end) describe('CurSearch highlight', function() -- cgit From 01e273c340b5e51b593900c8feb894ba9a46c366 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 24 Jul 2023 15:18:24 +0800 Subject: fix(statuscolumn): don't update clicks if current width is 0 (#24459) --- test/functional/ui/statuscolumn_spec.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 6a1c20ff67..35cd479bb9 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -9,6 +9,7 @@ local exec_lua = helpers.exec_lua local feed = helpers.feed local meths = helpers.meths local pcall_err = helpers.pcall_err +local assert_alive = helpers.assert_alive local mousemodels = { "extend", "popup", "popup_setpos" } @@ -577,8 +578,8 @@ describe('statuscolumn', function() end) end - it('click labels do not leak memory', function() - command([[ + it('click labels do not leak memory #21878', function() + exec([[ set laststatus=2 setlocal statuscolumn=%0@MyClickFunc@abcd%T 4vsplit @@ -590,6 +591,18 @@ describe('statuscolumn', function() ]]) end) + it('click labels do not crash when initial width is 0 #24428', function() + exec([[ + set nonumber + bwipe! + setlocal statuscolumn=abcd + redraw + setlocal statuscolumn=%0@MyClickFunc@abcd%T + redraw + ]]) + assert_alive() + end) + it('works with foldcolumn', function() -- Fits maximum multibyte foldcolumn #21759 command([[set stc=%C%=%l\ fdc=9 fillchars=foldsep:𒀀]]) -- cgit From 5fb4c397a1da2737262ac7686666dc2596db50c2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 24 Jul 2023 18:16:53 +0800 Subject: fix(mouse): drag vsep of window with 'statuscolumn' (#24462) Problem: Cannot drag a vertical separator to the right of a window whose 'statuscolumn' is wider than itself. Solution: Never treat a click on a vertical separator as a click on 'statuscolumn'. --- test/functional/ui/mouse_spec.lua | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 621855f051..d126e27cde 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths local insert, feed_command = helpers.insert, helpers.feed_command local eq, funcs = helpers.eq, helpers.funcs +local poke_eventloop = helpers.poke_eventloop local command = helpers.command local exec = helpers.exec @@ -32,6 +33,7 @@ describe('ui/mouse/input', function() [5] = {bold = true, reverse = true}, [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, [7] = {bold = true, foreground = Screen.colors.SeaGreen4}, + [8] = {foreground = Screen.colors.Brown}, }) command("set mousemodel=extend") feed('itestingmousesupport and selection') @@ -798,6 +800,66 @@ describe('ui/mouse/input', function() feed('') end) + it('dragging vertical separator', function() + screen:try_resize(45, 5) + command('setlocal nowrap') + local oldwin = meths.get_current_win().id + command('rightbelow vnew') + screen:expect([[ + testing │{0:^$} | + mouse │{0:~ }| + support and selection │{0:~ }| + {4:[No Name] [+] }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'press', '', 0, 0, 22) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 0, 1, 12) + screen:expect([[ + testing │{0:^$} | + mouse │{0:~ }| + support and │{0:~ }| + {4:< Name] [+] }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'drag', '', 0, 2, 2) + screen:expect([[ + te│{0:^$} | + mo│{0:~ }| + su│{0:~ }| + {4:< }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'release', '', 0, 2, 2) + meths.set_option_value('statuscolumn', 'foobar', { win = oldwin }) + screen:expect([[ + {8:fo}│{0:^$} | + {8:fo}│{0:~ }| + {8:fo}│{0:~ }| + {4:< }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'press', '', 0, 0, 2) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 0, 1, 12) + screen:expect([[ + {8:foobar}testin│{0:^$} | + {8:foobar}mouse │{0:~ }| + {8:foobar}suppor│{0:~ }| + {4:< Name] [+] }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'drag', '', 0, 2, 22) + screen:expect([[ + {8:foobar}testing │{0:^$} | + {8:foobar}mouse │{0:~ }| + {8:foobar}support and sele│{0:~ }| + {4:[No Name] [+] }{5:[No Name] }| + | + ]]) + meths.input_mouse('left', 'release', '', 0, 2, 22) + end) + local function wheel(use_api) feed('ggdG') insert([[ -- cgit From 643bea31b8673f5db70816ecac61f76087019fb5 Mon Sep 17 00:00:00 2001 From: Alexandre Teoi Date: Wed, 26 Jul 2023 00:22:57 -0300 Subject: fix(inccommand): restrict cmdpreview undo calls (#24289) Problem: The cmdpreview saved undo nodes on cmdpreview_prepare() from ex_getln.c may become invalid (free) if the preview function makes undo operations, causing heap-use-after-free errors. Solution: Save the buffer undo list on cmdpreview_prepare)_ and start a new empty one. On cmdpreview_restore_state(), undo all the entries in the new undo list and restore the original one. With this approach, the preview function will be allowed to undo only its own changes. Fix #20036 Fix #20248 --- test/functional/ui/inccommand_user_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 9cc6e095c5..8a1030fa25 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -435,6 +435,28 @@ describe("'inccommand' for user commands", function() ]]) assert_alive() end) + + it("no crash if preview callback executes undo", function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command('Foo', function() end, { + nargs = '?', + preview = function(_, _, _) + vim.cmd.undo() + end, + }) + ]]) + + -- Clear undo history + command('set undolevels=-1') + feed('ggyyp') + command('set undolevels=1000') + + feed('yypp:Fo') + assert_alive() + feed(':Fo') + assert_alive() + end) end) describe("'inccommand' with multiple buffers", function() -- cgit From 14d047ad2f448885de39966d1963f15d3fa21089 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Jul 2023 11:58:26 +0800 Subject: test(inccommand): add a test for #20248 (#24489) --- test/functional/ui/inccommand_user_spec.lua | 56 ++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 8a1030fa25..62c4cac709 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -436,7 +436,7 @@ describe("'inccommand' for user commands", function() assert_alive() end) - it("no crash if preview callback executes undo", function() + it('no crash if preview callback executes undo #20036', function() command('set inccommand=nosplit') exec_lua([[ vim.api.nvim_create_user_command('Foo', function() end, { @@ -457,6 +457,60 @@ describe("'inccommand' for user commands", function() feed(':Fo') assert_alive() end) + + it('breaking undo chain in Insert mode works properly #20248', function() + command('set inccommand=nosplit') + command('inoremap . .u') + exec_lua([[ + vim.api.nvim_create_user_command('Test', function() end, { + nargs = 1, + preview = function(opts, _, _) + vim.cmd('norm i' .. opts.args) + return 1 + end + }) + ]]) + feed(':Test a.a.a.a.') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + a.a.a.a. | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :Test a.a.a.a.^ | + ]]) + feed('') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + ^ | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]) + end) end) describe("'inccommand' with multiple buffers", function() -- cgit From a47be0b2d90b26905866faf5b7cc82d9c17be9bb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 24 Jul 2023 11:56:26 +0100 Subject: fix(window): prevent win_size_restore from changing cmdheight Currently it only skips if `Rows` changed, but it's possible for the height of the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which can cause the value of `&cmdheight` to change when the sizes are restored. This is a Vim bug, so I've submitted a PR there too. No telling when it'll be merged though, given the current lack of activity there. `ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`. Not ideal, as we also care about the height of the last statusline for other values of `&ls`. Meh. Introduce `last_stl_height` for getting the height of the last statusline and use it in `win_size_save/restore` and `last_status` (means `last_status_rec`'s `statusline` argument will now be true if `&ls` is 3, but that does not change the behaviour). Also corrects the logic in `comp_col` to not assume there's a last statusline if `&ls` is 1 and the last window is floating. --- test/functional/ui/cmdline_spec.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index dc29b765bd..a8cc8e00f0 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -984,14 +984,46 @@ it('tabline is not redrawn in Ex mode #24122', function() end) describe("cmdline height", function() + before_each(clear) + it("does not crash resized screen #14263", function() - clear() local screen = Screen.new(25, 10) screen:attach() command('set cmdheight=9999') screen:try_resize(25, 5) assert_alive() end) + + it('unchanged when trying to restore window sizes', function() + command('set showtabline=0 cmdheight=2 laststatus=0') + feed('q:') -- Closing cmdwin tries to restore sizes + command('set cmdheight=1 | quit') + eq(1, eval('&cmdheight')) + + command('set showtabline=2 cmdheight=3') + feed('q:') + command('set showtabline=0 | quit') + eq(3, eval('&cmdheight')) + + command('set cmdheight=1 laststatus=2') + feed('q:') + command('set laststatus=0 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2') + feed('q:') + command('set laststatus=1 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2 | belowright vsplit | wincmd _') + local restcmds = eval('winrestcmd()') + feed('q:') + command('set laststatus=1 | quit') + -- As we have 2 windows, &ls = 1 should still have a statusline on the last + -- window. As such, the number of available rows hasn't changed and the window + -- sizes should be restored. + eq(restcmds, eval('winrestcmd()')) + end) end) describe('cmdheight=0', function() -- cgit From c1c2a1b5dd1d73e5e97b94e6626aaac25a3db9bc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Jul 2023 15:41:58 +0800 Subject: fix(inccommand): don't save information of a buffer twice (#24501) Problem: 'inccommand' doesn't restore 'undolevels' properly for a buffer shown in multiple windows. Solution: Don't save information of a buffer twice. --- test/functional/ui/inccommand_spec.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index dc4aeb9c83..00dfa3fd49 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -174,9 +174,12 @@ describe(":substitute, 'inccommand' preserves", function() it("'undolevels' (inccommand="..case..")", function() feed_command("set undolevels=139") feed_command("setlocal undolevels=34") + feed_command("split") -- Show the buffer in multiple windows feed_command("set inccommand=" .. case) insert("as") - feed(":%s/as/glork/") + feed(":%s/as/glork/") + poke_eventloop() + feed("") eq(meths.get_option_value('undolevels', {scope='global'}), 139) eq(meths.get_option_value('undolevels', {buf=0}), 34) end) -- cgit From ef44e597294e4d0d9128ef69b6aa7481a54e17cb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 5 Aug 2023 22:42:34 +0800 Subject: fix(inccommand): don't set an invalid 'undolevels' value (#24575) Problem: Cannot break undo by setting 'undolevels' to itself in 'inccommand' preview callback. Solution: Don't set an invalid 'undolevels' value. Co-authored-by: Michael Henry --- test/functional/ui/inccommand_user_spec.lua | 38 ++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 62c4cac709..da7508fad1 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -239,7 +239,8 @@ describe("'inccommand' for user commands", function() [1] = {background = Screen.colors.Yellow1}, [2] = {foreground = Screen.colors.Blue1, bold = true}, [3] = {reverse = true}, - [4] = {reverse = true, bold = true} + [4] = {reverse = true, bold = true}, + [5] = {foreground = Screen.colors.Blue}, }) screen:attach() exec_lua(setup_replace_cmd) @@ -458,9 +459,8 @@ describe("'inccommand' for user commands", function() assert_alive() end) - it('breaking undo chain in Insert mode works properly #20248', function() + local function test_preview_break_undo() command('set inccommand=nosplit') - command('inoremap . .u') exec_lua([[ vim.api.nvim_create_user_command('Test', function() end, { nargs = 1, @@ -490,6 +490,26 @@ describe("'inccommand' for user commands", function() {2:~ }| :Test a.a.a.a.^ | ]]) + feed('u') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + a.a.a. | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :Test a.a.a.a.{5:^[}u^ | + ]]) feed('') screen:expect([[ text on line 1 | @@ -510,6 +530,18 @@ describe("'inccommand' for user commands", function() {2:~ }| | ]]) + end + + describe('breaking undo chain in Insert mode works properly', function() + it('when using i_CTRL-G_u #20248', function() + command('inoremap . .u') + test_preview_break_undo() + end) + + it('when setting &l:undolevels to itself #24575', function() + command('inoremap . .let &l:undolevels = &l:undolevels') + test_preview_break_undo() + end) end) end) -- cgit From 5a25dcc5a4c73f50902432e32335ab073950cceb Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Sat, 12 Aug 2023 18:14:37 +0900 Subject: fix(diff): filler lines for hunks bigger than linematch limit (#24676) Apply linematch filler computation only if the hunk is actually linematched. Fixes #24580 --- test/functional/ui/linematch_spec.lua | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index 76197bc7e0..ef47ea7ed0 100644 --- a/test/functional/ui/linematch_spec.lua +++ b/test/functional/ui/linematch_spec.lua @@ -1178,4 +1178,48 @@ describe('regressions', function() helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' }) helpers.exec 'windo diffthis' end) + + it("properly computes filler lines for hunks bigger than linematch limit", function() + clear() + feed(':set diffopt+=linematch:10') + screen = Screen.new(100, 20) + screen:attach() + local lines = {} + for i = 0, 29 do + lines[#lines + 1] = tostring(i) + end + helpers.curbufmeths.set_lines(0, -1, false, lines) + helpers.exec 'vnew' + helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' }) + helpers.exec 'windo diffthis' + feed('') + screen:expect{grid=[[ + {1: }{2:------------------------------------------------}│{1: }{3:^1 }| + {1: }{2:------------------------------------------------}│{1: }{3:2 }| + {1: }{2:------------------------------------------------}│{1: }{3:3 }| + {1: }{2:------------------------------------------------}│{1: }{3:4 }| + {1: }{2:------------------------------------------------}│{1: }{3:5 }| + {1: }{2:------------------------------------------------}│{1: }{3:6 }| + {1: }{2:------------------------------------------------}│{1: }{3:7 }| + {1: }{2:------------------------------------------------}│{1: }{3:8 }| + {1: }{2:------------------------------------------------}│{1: }{3:9 }| + {1: }{2:------------------------------------------------}│{1: }{3:10 }| + {1: }{2:------------------------------------------------}│{1: }{3:11 }| + {1: }{2:------------------------------------------------}│{1: }{3:12 }| + {1: }{2:------------------------------------------------}│{1: }{3:13 }| + {1: }{2:------------------------------------------------}│{1: }{3:14 }| + {1: }{2:------------------------------------------------}│{1: }{3:15 }| + {1: }{2:------------------------------------------------}│{1: }{3:16 }| + {1: }{2:------------------------------------------------}│{1: }{3:17 }| + {1: }29 │{1: }{3:18 }| + {4:[No Name] [+] }{5:[No Name] [+] }| + | + ]], attr_ids={ + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey}; + [2] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1}; + [3] = {background = Screen.colors.LightBlue}; + [4] = {reverse = true}; + [5] = {reverse = true, bold = true}; + }} + end) end) -- cgit From 9f7e7455c01718c696e132513fd449235bd4f865 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 17 Aug 2023 23:16:19 +0100 Subject: vim-patch:9.0.1726: incorrect heights in win_size_restore() (#24765) Problem: incorrect heights in win_size_restore() Solution: avoid restoring incorrect heights in win_size_restore() https://github.com/vim/vim/commit/876f5fb570d8401aa4c58af4a5da91f10520aa9d I already merged this prior, so just replace the new test with the old one, but add a test case for the global statusline. --- test/functional/ui/cmdline_spec.lua | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index a8cc8e00f0..7d87ba4972 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -994,35 +994,13 @@ describe("cmdline height", function() assert_alive() end) - it('unchanged when trying to restore window sizes', function() - command('set showtabline=0 cmdheight=2 laststatus=0') - feed('q:') -- Closing cmdwin tries to restore sizes - command('set cmdheight=1 | quit') - eq(1, eval('&cmdheight')) - - command('set showtabline=2 cmdheight=3') - feed('q:') - command('set showtabline=0 | quit') - eq(3, eval('&cmdheight')) - - command('set cmdheight=1 laststatus=2') - feed('q:') - command('set laststatus=0 | quit') - eq(1, eval('&cmdheight')) - - command('set laststatus=2') + it('unchanged when restoring window sizes with global statusline', function() + command('set cmdheight=2 laststatus=2') feed('q:') - command('set laststatus=1 | quit') + command('set cmdheight=1 laststatus=3 | quit') + -- Available lines changed, so closing cmdwin should skip restoring window sizes, leaving the + -- cmdheight unchanged. eq(1, eval('&cmdheight')) - - command('set laststatus=2 | belowright vsplit | wincmd _') - local restcmds = eval('winrestcmd()') - feed('q:') - command('set laststatus=1 | quit') - -- As we have 2 windows, &ls = 1 should still have a statusline on the last - -- window. As such, the number of available rows hasn't changed and the window - -- sizes should be restored. - eq(restcmds, eval('winrestcmd()')) end) end) -- cgit From 71ad771ea4b77119abcff706b9666fa534963819 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 12:08:18 +0800 Subject: fix(ui_compositor): only reset skipstart at first column (#24776) Problem: A double-width char in a floating window causes an extra space to be drawn to the left of its boundary. Solution: Only reset skipstart at the first column. Fix #24775 --- test/functional/ui/float_spec.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 46c2127c30..c2bcac2449 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8377,6 +8377,7 @@ describe('float window', function() # TODO: 测试字典信息的准确性 # FIXME: 测试字典信息的准确性]]) local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf, 0, -1, true, {'口', '口'}) local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) if multigrid then screen:expect{grid=[[ @@ -8397,15 +8398,15 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 4 - {1: }| - {1: }| + ## grid 5 + {1:口 }| + {1:口 }| {1: }| - ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 0, 11, true } }} + ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 0, 11, true } }} else screen:expect([[ - # TODO: 测 {1: }信息的准确性 | - # FIXME: 测{1: } 信息的准确^性 | + # TODO: 测 {1:口 }信息的准确性 | + # FIXME: 测{1:口 } 信息的准确^性 | {0:~ }{1: }{0: }| {0:~ }| {0:~ }| -- cgit From 81d5550d77d24a924e8c23873fccbf405bc39447 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 14:00:12 +0800 Subject: vim-patch:9.0.1731: blockwise Visual highlight not working with virtual text (#24779) Problem: blockwise Visual highlight not working with virtual text Solution: Reset the correct variable at the end of virtual selection and Check for double-width char inside virtual text. closes: vim/vim#12606 https://github.com/vim/vim/commit/6e940d9a1d4ff122aad1b0821c784a60b507d45c Need to remove area_active and use wlv.fromcol and wlv.tocol directly. --- test/functional/ui/decorations_spec.lua | 148 +++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ef55784ca8..3a4a64361d 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2146,7 +2146,7 @@ bbbbbbb]]) ]]} end) - it('visual select highlight is correct', function() + it('Visual select highlight is correct', function() insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) @@ -2803,6 +2803,152 @@ bbbbbbb]]) | ]]} end) + + it('blockwise Visual highlight with double-width virtual text (replace)', function() + screen:try_resize(60, 6) + insert('123456789\n123456789\n123456789') + meths.buf_set_extmark(0, ns, 1, 1, { + virt_text = { { '-口-', 'Special' } }, + virt_text_pos = 'inline', + hl_mode = 'replace', + }) + feed('gg0') + screen:expect{grid=[[ + ^123456789 | + 1{10:-口-}23456789 | + 123456789 | + {1:~ }| + {1:~ }| + | + ]]} + feed('2jl') + screen:expect{grid=[[ + {7:12}3456789 | + {7:1}{10:-口-}23456789 | + {7:1}^23456789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + {7:123}456789 | + {7:1}{10:-口-}23456789 | + {7:12}^3456789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('4l') + screen:expect{grid=[[ + {7:1234567}89 | + {7:1}{10:-口-}{7:23}456789 | + {7:123456}^789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('Ol') + screen:expect{grid=[[ + 1{7:234567}89 | + 1{10:-口-}{7:23}456789 | + 1^2{7:34567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + 12{7:34567}89 | + 1{10:-口-}{7:23}456789 | + 12^3{7:4567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + 123{7:4567}89 | + 1{10:-口-}{7:23}456789 | + 123^4{7:567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + end) + + it('blockwise Visual highlight with double-width virtual text (combine)', function() + screen:try_resize(60, 6) + insert('123456789\n123456789\n123456789') + meths.buf_set_extmark(0, ns, 1, 1, { + virt_text = { { '-口-', 'Special' } }, + virt_text_pos = 'inline', + hl_mode = 'combine', + }) + feed('gg0') + screen:expect{grid=[[ + ^123456789 | + 1{10:-口-}23456789 | + 123456789 | + {1:~ }| + {1:~ }| + | + ]]} + feed('2jl') + screen:expect{grid=[[ + {7:12}3456789 | + {7:1}{20:-}{10:口-}23456789 | + {7:1}^23456789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + {7:123}456789 | + {7:1}{20:-口}{10:-}23456789 | + {7:12}^3456789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('4l') + screen:expect{grid=[[ + {7:1234567}89 | + {7:1}{20:-口-}{7:23}456789 | + {7:123456}^789 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('Ol') + screen:expect{grid=[[ + 1{7:234567}89 | + 1{20:-口-}{7:23}456789 | + 1^2{7:34567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + 12{7:34567}89 | + 1{10:-}{20:口-}{7:23}456789 | + 12^3{7:4567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + feed('l') + screen:expect{grid=[[ + 123{7:4567}89 | + 1{10:-}{20:口-}{7:23}456789 | + 123^4{7:567}89 | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 551998b7eed7dd411e4d14f65b108ae8a93c4081 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 15:00:03 +0800 Subject: vim-patch:9.0.1725: cursor pos wrong after concealed text with 'virtualedit' Problem: Wrong cursor position when clicking after concealed text with 'virtualedit'. Solution: Store virtual columns in ScreenCols[] instead of text columns, and always use coladvance() when clicking. This also fixes incorrect curswant when clicking on a TAB, so now Test_normal_click_on_ctrl_char() asserts the same results as the ones before patch 9.0.0048. closes: vim/vim#12808 https://github.com/vim/vim/commit/e500ae8e29ad921378085f5d70ee5c0c537be1ba Remove the mouse_adjust_click() function. There is a difference in behavior with the old mouse_adjust_click() approach: when clicking on the character immediately after concealed text that is completely hidden, cursor is put on the clicked character rather than at the start of the concealed text. The new behavior is better, but it causes unnecessary scrolling in a functional test (which is an existing issue unrelated to these patches), so adjust the test. Now fully merged: vim-patch:9.0.0177: cursor position wrong with 'virtualedit' and mouse click --- test/functional/ui/mouse_spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index d126e27cde..657cc0c325 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1089,7 +1089,6 @@ describe('ui/mouse/input', function() command([[setlocal concealcursor=ni nowrap shiftwidth=2 tabstop=4 list listchars=tab:>-]]) command([[syntax region X0 matchgroup=X1 start=/\*/ end=/\*/ concealends contains=X2]]) command([[syntax match X2 /cats/ conceal cchar=X contained]]) - -- No heap-use-after-free with multi-line syntax pattern #24317 command([[syntax match X3 /\n\@<=x/ conceal cchar=>]]) command([[highlight link X0 Normal]]) command([[highlight link X1 NonText]]) @@ -1497,7 +1496,6 @@ describe('ui/mouse/input', function() ]]) end) -- level 2 - wrapped - it('(level 3) click on non-wrapped lines', function() feed_command('let &conceallevel=3', 'echo') @@ -1535,6 +1533,7 @@ describe('ui/mouse/input', function() ]]) feed('<20,2>') + feed('zH') -- FIXME: unnecessary horizontal scrolling screen:expect([[ Section{0:>>--->--->---}t1 | {0:>--->--->---} t2 t3 t4 | -- cgit From 1d3d50e8f0e1c3438ad77a8727ad8d3f1333c79a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 19:31:15 +0800 Subject: test(ui/mouse_spec): mouse click with matchadd() concealed text --- test/functional/ui/mouse_spec.lua | 102 ++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 32 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 657cc0c325..9c22d112d3 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1073,38 +1073,7 @@ describe('ui/mouse/input', function() ]]) end) - describe('on concealed text', function() - -- Helpful for reading the test expectations: - -- :match Error /\^/ - - before_each(function() - screen:try_resize(25, 7) - screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - c = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, - sm = {bold = true}, - }) - feed('ggdG') - - command([[setlocal concealcursor=ni nowrap shiftwidth=2 tabstop=4 list listchars=tab:>-]]) - command([[syntax region X0 matchgroup=X1 start=/\*/ end=/\*/ concealends contains=X2]]) - command([[syntax match X2 /cats/ conceal cchar=X contained]]) - command([[syntax match X3 /\n\@<=x/ conceal cchar=>]]) - command([[highlight link X0 Normal]]) - command([[highlight link X1 NonText]]) - command([[highlight link X2 NonText]]) - command([[highlight link X3 NonText]]) - - -- First column is there to retain the tabs. - insert([[ - |Section *t1* - | *t2* *t3* *t4* - |x 私は猫が大好き *cats* ✨🐈✨ - ]]) - - feed('ggGxgg') - end) - + local function test_mouse_click_conceal() it('(level 1) click on non-wrapped lines', function() feed_command('let &conceallevel=1', 'echo') @@ -1637,6 +1606,75 @@ describe('ui/mouse/input', function() ]]) end) -- level 3 - wrapped + end + + describe('on concealed text', function() + -- Helpful for reading the test expectations: + -- :match Error /\^/ + + before_each(function() + screen:try_resize(25, 7) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + c = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + sm = { bold = true }, + }) + feed('ggdG') + + command([[setlocal concealcursor=ni nowrap shiftwidth=2 tabstop=4 list listchars=tab:>-]]) + command([[highlight link X0 Normal]]) + command([[highlight link X1 NonText]]) + command([[highlight link X2 NonText]]) + command([[highlight link X3 NonText]]) + + -- First column is there to retain the tabs. + insert([[ + |Section *t1* + | *t2* *t3* *t4* + |x 私は猫が大好き *cats* ✨🐈✨ + ]]) + + feed('ggGxgg') + end) + + describe('(syntax)', function() + before_each(function() + command([[syntax region X0 matchgroup=X1 start=/\*/ end=/\*/ concealends contains=X2]]) + command([[syntax match X2 /cats/ conceal cchar=X contained]]) + command([[syntax match X3 /\n\@<=x/ conceal cchar=>]]) + end) + test_mouse_click_conceal() + end) + + describe('(matchadd())', function() + before_each(function() + funcs.matchadd('Conceal', [[\*]]) + funcs.matchadd('Conceal', [[cats]], 10, -1, { conceal = 'X' }) + funcs.matchadd('Conceal', [[\n\@<=x]], 10, -1, { conceal = '>' }) + end) + test_mouse_click_conceal() + end) + + -- FIXME: cannot make extmark conceal behave exactly like syntax conceal without cchar + pending('(extmarks)', function() + before_each(function() + local ns = meths.create_namespace('conceal') + meths.buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) + meths.buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' }) + meths.buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' }) + meths.buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' }) + meths.buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' }) + meths.buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' }) + meths.buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' }) + end) + test_mouse_click_conceal() + end) + end) it('getmousepos works correctly', function() -- cgit From 5a6c7c805b8bb1d1ed9fe829ed33f18ffa6f4f47 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 19 Aug 2023 03:55:11 +0800 Subject: fix(extmarks): make empty "conceal" respect &conceallevel = 1 (#24785) This treats extmark conceal more like matchadd() conceal. --- test/functional/ui/decorations_spec.lua | 41 ++++++++++++++++++++++++++------- test/functional/ui/mouse_spec.lua | 3 +-- 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 3a4a64361d..395176f005 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1361,18 +1361,43 @@ describe('extmark decorations', function() assert_alive() end) - it('conceal #19007', function() + it('conceal with conceal char #19007', function() screen:try_resize(50, 5) insert('foo\n') - command('let &conceallevel=2') meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'}) + command('set conceallevel=2') + screen:expect([[ + {26:X} | + ^ | + {1:~ }| + {1:~ }| + | + ]]) + command('set conceallevel=1') + screen:expect_unchanged() + end) + + it('conceal without conceal char #24782', function() + screen:try_resize(50, 5) + insert('foobar\n') + meths.buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''}) + command('set listchars=conceal:?') + command('let &conceallevel=1') screen:expect([[ - {26:X} | - ^ | - {1:~ }| - {1:~ }| - | - ]]) + {26:?}bar | + ^ | + {1:~ }| + {1:~ }| + | + ]]) + command('let &conceallevel=2') + screen:expect([[ + bar | + ^ | + {1:~ }| + {1:~ }| + | + ]]) end) it('conceal works just before truncated double-width char #21486', function() diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 9c22d112d3..a8d01cfbf1 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1655,8 +1655,7 @@ describe('ui/mouse/input', function() test_mouse_click_conceal() end) - -- FIXME: cannot make extmark conceal behave exactly like syntax conceal without cchar - pending('(extmarks)', function() + describe('(extmarks)', function() before_each(function() local ns = meths.create_namespace('conceal') meths.buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) -- cgit From 421713523e154009223c31cdbfe8486262c6f5e4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 19 Aug 2023 20:34:58 +0800 Subject: vim-patch:9.0.1745: Missing test coverage for blockwise Visual highlight (#24790) Problem: Missing test coverage for blockwise Visual highlight with virtual that starts with a double-width char. Solution: Add a new virtual text to the test. Some other small fixes. closes: vim/vim#12835 https://github.com/vim/vim/commit/fc3058495d3ff58c8f2b9dd4452d0840f2d1fa42 --- test/functional/ui/decorations_spec.lua | 46 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 395176f005..ed562555e3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2831,146 +2831,156 @@ bbbbbbb]]) it('blockwise Visual highlight with double-width virtual text (replace)', function() screen:try_resize(60, 6) - insert('123456789\n123456789\n123456789') + insert('123456789\n123456789\n123456789\n123456789') meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace', }) + meths.buf_set_extmark(0, ns, 2, 2, { + virt_text = { { '口', 'Special' } }, + virt_text_pos = 'inline', + hl_mode = 'replace', + }) feed('gg0') screen:expect{grid=[[ ^123456789 | 1{10:-口-}23456789 | + 12{10:口}3456789 | 123456789 | - {1:~ }| {1:~ }| | ]]} - feed('2jl') + feed('3jl') screen:expect{grid=[[ {7:12}3456789 | {7:1}{10:-口-}23456789 | + {7:12}{10:口}3456789 | {7:1}^23456789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ {7:123}456789 | {7:1}{10:-口-}23456789 | + {7:12}{10:口}3456789 | {7:12}^3456789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('4l') screen:expect{grid=[[ {7:1234567}89 | {7:1}{10:-口-}{7:23}456789 | + {7:12}{10:口}{7:345}6789 | {7:123456}^789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('Ol') screen:expect{grid=[[ 1{7:234567}89 | 1{10:-口-}{7:23}456789 | + 1{7:2}{10:口}{7:345}6789 | 1^2{7:34567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ 12{7:34567}89 | 1{10:-口-}{7:23}456789 | + 12{10:口}{7:345}6789 | 12^3{7:4567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ 123{7:4567}89 | 1{10:-口-}{7:23}456789 | + 12{10:口}{7:345}6789 | 123^4{7:567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} end) it('blockwise Visual highlight with double-width virtual text (combine)', function() screen:try_resize(60, 6) - insert('123456789\n123456789\n123456789') + insert('123456789\n123456789\n123456789\n123456789') meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine', }) + meths.buf_set_extmark(0, ns, 2, 2, { + virt_text = { { '口', 'Special' } }, + virt_text_pos = 'inline', + hl_mode = 'combine', + }) feed('gg0') screen:expect{grid=[[ ^123456789 | 1{10:-口-}23456789 | + 12{10:口}3456789 | 123456789 | - {1:~ }| {1:~ }| | ]]} - feed('2jl') + feed('3jl') screen:expect{grid=[[ {7:12}3456789 | {7:1}{20:-}{10:口-}23456789 | + {7:12}{10:口}3456789 | {7:1}^23456789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ {7:123}456789 | {7:1}{20:-口}{10:-}23456789 | + {7:12}{20:口}3456789 | {7:12}^3456789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('4l') screen:expect{grid=[[ {7:1234567}89 | {7:1}{20:-口-}{7:23}456789 | + {7:12}{20:口}{7:345}6789 | {7:123456}^789 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('Ol') screen:expect{grid=[[ 1{7:234567}89 | 1{20:-口-}{7:23}456789 | + 1{7:2}{20:口}{7:345}6789 | 1^2{7:34567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ 12{7:34567}89 | 1{10:-}{20:口-}{7:23}456789 | + 12{20:口}{7:345}6789 | 12^3{7:4567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} feed('l') screen:expect{grid=[[ 123{7:4567}89 | 1{10:-}{20:口-}{7:23}456789 | + 12{20:口}{7:345}6789 | 123^4{7:567}89 | {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | ]]} end) -- cgit From 893437512c51fb31b4f99b90357e2b15e5b0c73b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 16:14:54 +0800 Subject: vim-patch:8.2.4208: using setbufvar() may change the window title Problem: Using setbufvar() may change the window title. Solution: Do not redraw when creating the autocommand window. (closes vim/vim#9613) https://github.com/vim/vim/commit/dff97e65eb1bb24c44c2b7430a480888d8afb3f4 Co-authored-by: Bram Moolenaar --- test/functional/ui/title_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua index 2247d2e80f..66c0ff5c9c 100644 --- a/test/functional/ui/title_spec.lua +++ b/test/functional/ui/title_spec.lua @@ -49,7 +49,7 @@ describe('title', function() end) it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() - command([[inoremap =setbufvar(]]..buf2..[[, '&autoindent', 1) ? '' : '']]) + command([[inoremap =setbufvar(]]..buf2..[[, '&autoindent', 1) ?? '']]) feed('i') command('redraw!') screen:expect(function() -- cgit From b84a67f50ed6141f72d433094a1a611ae4f67924 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 22 Aug 2023 22:48:55 +0800 Subject: vim-patch:9.0.0579: using freed memory when 'tagfunc' wipes out buffer (#24838) Problem: Using freed memory when 'tagfunc' wipes out buffer that holds 'complete'. Solution: Make a copy of the option. Make sure cursor position is valid. https://github.com/vim/vim/commit/0ff01835a40f549c5c4a550502f62a2ac9ac447c Cherry-pick a cmdwin change from patch 9.0.0500. Co-authored-by: Bram Moolenaar --- test/functional/ui/cmdline_spec.lua | 8 ++++---- test/functional/ui/popupmenu_spec.lua | 2 +- test/functional/ui/searchhl_spec.lua | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 7d87ba4972..4b92ab730d 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -316,7 +316,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]]} @@ -326,7 +326,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]], cmdline={nil, { @@ -339,7 +339,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]], cmdline={nil, { @@ -352,7 +352,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ | {2:[No Name] }| - {1::}make^ | + {1::}mak^e | {3:[Command Line] }| | ]]} diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 76038472bd..ea65cf35bd 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3239,7 +3239,7 @@ describe('builtin popupmenu', function() | {3:[No Name] }| {1::}sign define | - {1::}sign define^ | + {1::}sign defin^e | {1:~ }| {1:~ }| {1:~ }| diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index ec1ebbe4ca..7fd66d6f8a 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -52,7 +52,7 @@ describe('search highlighting', function() {1:~ }| /text^ | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 8, linecount = 2, sum_scroll_delta = 0}; }} end) -- cgit From a1d71ad55e0f7149f284178b2d04ac78263b09ff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 23 Aug 2023 10:12:00 +0800 Subject: vim-patch:9.0.1783: Display issues with virt text smoothscroll and showbreak Problem: Wrong display with wrapping virtual text or unprintable chars, 'showbreak' and 'smoothscroll'. Solution: Don't skip cells taken by 'showbreak' in screen lines before "w_skipcol". Combined "n_skip" and "skip_cells". closes: vim/vim#12597 https://github.com/vim/vim/commit/b557f4898208105b674df605403cac1b1292707b --- test/functional/ui/decorations_spec.lua | 328 +++++++++++++++++++++++++++++++- 1 file changed, 325 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ed562555e3..9bbd28c3cb 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2021,7 +2021,7 @@ bbbbbbb]]) ]]} end) - it('cursor position is correct with virtual text attached to hard tabs', function() + it('cursor position is correct with virtual text attached to hard TABs', function() command('set noexpandtab') feed('i') feed('') @@ -2692,7 +2692,7 @@ bbbbbbb]]) ]]} end) - it('correctly draws when overflowing virtual text is followed by tab with no wrap', function() + it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function() command('set nowrap') feed('itest') meths.buf_set_extmark( @@ -2984,6 +2984,328 @@ bbbbbbb]]) {8:-- VISUAL BLOCK --} | ]]} end) + + local function test_virt_inline_showbreak_smoothscroll() + screen:try_resize(30, 6) + exec([[ + highlight! link LineNr Normal + call setline(1, repeat('a', 28)) + setlocal number showbreak=+ breakindent breakindentopt=shift:2 + setlocal scrolloff=0 smoothscroll + normal! $ + ]]) + meths.buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) + feed(':') -- Have a screen line that doesn't start with spaces + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}a1231231231231231231231| + {1:+}23123123123123123123123| + {1:+}12312312312312312312312| + {1:+}3^a | + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}a1231231231231231231231| + {1:+}23123123123123123123123| + {1:+}12312312312312312312312| + {1:+}3^a | + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}23123123123123123123123| + {1:+}12312312312312312312312| + {1:+}3^a | + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}12312312312312312312312| + {1:+}3^a | + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}3^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('zbi') + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}a^1231231231231231231231| + {1:+}23123123123123123123123| + {1:+}12312312312312312312312| + {1:+}3a | + {8:-- INSERT --} | + ]]} + feed('') + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}^12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}a | + {8:-- INSERT --} | + ]]} + feed('l') + feed(':') -- Have a screen line that doesn't start with spaces + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}^a | + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('023x$') + screen:expect{grid=[[ + 1 aaa12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}23123123123123123123123| + {1:+}^a | + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + : | + ]]} + feed('zbi') + screen:expect{grid=[[ + 1 aaa^12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:+}a | + {1:~ }| + {8:-- INSERT --} | + ]]} + feed('') + screen:expect{grid=[[ + 1 ^12312312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123a | + {1:~ }| + {1:~ }| + {8:-- INSERT --} | + ]]} + feed('') + screen:expect{grid=[[ + 1 12312312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123^a | + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}31231231231231231231231| + {1:+}23123123123123123123^a | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:+}23123123123123123123^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end + + describe('with showbreak, smoothscroll', function() + it('and cpoptions-=n', function() + test_virt_inline_showbreak_smoothscroll() + end) + + it('and cpoptions+=n', function() + command('set cpoptions+=n') + -- because of 'breakindent' the screen states are the same + test_virt_inline_showbreak_smoothscroll() + end) + end) + + it('before TABs with smoothscroll', function() + screen:try_resize(30, 6) + exec([[ + call setline(1, repeat("\t", 4) .. 'a') + setlocal list listchars=tab:<-> scrolloff=0 smoothscroll + normal! $ + ]]) + meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + {1:<------><------><------>}121212| + 121212121212121212121212121212| + 1212121212121212121212121212{1:<-}| + {1:----->}^a | + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}212121212121212121212121212| + 1212121212121212121212121212{1:<-}| + {1:----->}^a | + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}2121212121212121212121212{1:<-}| + {1:----->}^a | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<-->}^a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('zbh') + screen:expect{grid=[[ + {1:<------><------><------>}121212| + 121212121212121212121212121212| + 1212121212121212121212121212{1:^<-}| + {1:----->}a | + {1:~ }| + | + ]]} + feed('i') + screen:expect{grid=[[ + {1:<------><------><------>}^121212| + 121212121212121212121212121212| + 1212121212121212121212121212{1:<-}| + {1:----->}a | + {1:~ }| + {8:-- INSERT --} | + ]]} + feed(':setlocal nolist') + screen:expect{grid=[[ + ^121212| + 121212121212121212121212121212| + 1212121212121212121212121212 | + a | + {1:~ }| + {8:-- INSERT --} | + ]]} + feed('l') + screen:expect{grid=[[ + 121212| + 121212121212121212121212121212| + 1212121212121212121212121212 | + ^ a | + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}212121212121212121212121212| + 1212121212121212121212121212 | + ^ a | + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<}2121212121212121212121212 | + ^ a | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed('') + screen:expect{grid=[[ + {1:<<<} ^ a | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() @@ -3643,7 +3965,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) - it('works with hard tabs', function() + it('works with hard TABs', function() insert(example_text2) feed 'gg' meths.buf_set_extmark(0, ns, 1, 0, { -- cgit From 908f247c224db88ffd25e207314d41031519b128 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 23 Aug 2023 11:28:17 +0800 Subject: fix(plines): count 'showbreak' for virtual text at eol --- test/functional/ui/decorations_spec.lua | 595 ++++++++------------------------ 1 file changed, 148 insertions(+), 447 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9bbd28c3cb..4e3214da71 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1658,7 +1658,7 @@ describe('decorations: inline virtual text', function() local screen, ns before_each( function() clear() - screen = Screen.new(50, 10) + screen = Screen.new(50, 3) screen:attach() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; @@ -1689,6 +1689,7 @@ describe('decorations: inline virtual text', function() it('works', function() + screen:try_resize(50, 10) insert(example_text) feed 'gg' screen:expect{grid=[[ @@ -1748,6 +1749,7 @@ describe('decorations: inline virtual text', function() end) it('works with empty chunk', function() + screen:try_resize(50, 10) insert(example_text) feed 'gg' screen:expect{grid=[[ @@ -1796,198 +1798,134 @@ describe('decorations: inline virtual text', function() it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '4l' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10: virtual text virtual text }^5678 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('adjusts cursor location correctly when inserting around inline virtual text', function() insert('12345678') feed '$' - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10: virtual text }567^8 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('has correct highlighting with multi-byte characters', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:múlti-byté chñröcters 修补}567^8 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('has correct cursor position when inserting around virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '3l' feed 'a' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:^virtual text}5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} feed '' screen:expect{grid=[[ 123^4{10:virtual text}5678 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} feed '^' feed '4l' feed 'i' - screen:expect { grid = [[ + screen:expect{grid=[[ 1234{10:^virtual text}5678 | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} end) it('has correct cursor position with virtual text on an empty line', function() - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ {10:^virtual text} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('text is drawn correctly with a wrapping virtual text', function() + screen:try_resize(50, 8) feed('o') insert([[aaaaaaa bbbbbbb]]) - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, - { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | ^aaaaaaa | {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| bbbbbbb | {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('j') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | aaaaaaa | {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| ^bbbbbbb | {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('ggic') - screen:expect { grid = [[ + screen:expect{grid=[[ c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XX} | aaaaaaa | @@ -1995,10 +1933,8 @@ bbbbbbb]]) bbbbbbb | {1:~ }| {1:~ }| - {1:~ }| - {1:~ }| {8:-- INSERT --} | - ]]} + ]]} end) it('regexp \\%V does not count trailing virtual text', function() @@ -2028,97 +1964,53 @@ bbbbbbb]]) feed('') feed('test') feed('') - meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('0') - screen:expect { grid = [[ + screen:expect{grid=[[ ^ {10:virtual text} test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} ^ test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} ^test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} t^est | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} feed('l') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:virtual text} te^st | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('cursor position is correct with virtual text on an empty line', function() command('set linebreak') insert('one twoword') feed('0') - meths.buf_set_extmark(0, ns, 0, 3, - { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) - screen:expect { grid = [[ + meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ ^one{10:: virtual text} twoword | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('search highlight is correct', function() @@ -2128,47 +2020,26 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - screen:expect { grid = [[ + screen:expect{grid=[[ ^foo foo f{10:AAABBB}oo bar | foo foo f{10:CCCDDD}oo bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('/foo') - screen:expect { grid = [[ + screen:expect{grid=[[ {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| /foo^ | - ]]} + ]]} meths.buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('') - screen:expect{ grid = [[ + screen:expect{grid=[[ {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| /foo^ | - ]]} + ]]} end) it('Visual select highlight is correct', function() @@ -2179,47 +2050,26 @@ bbbbbbb]]) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') - screen:expect { grid = [[ + screen:expect{grid=[[ foo foo {10:AAABBB}^foo bar | foo foo {10:CCCDDD}foo bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | - ]]} + ]]} feed('') feed('2hj') - screen:expect { grid = [[ + screen:expect{grid=[[ foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | - ]]} + ]]} meths.buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - screen:expect { grid = [[ + screen:expect{grid=[[ foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- VISUAL BLOCK --} | - ]]} + ]]} end) it('inside highlight range of another extmark', function() @@ -2233,13 +2083,6 @@ bbbbbbb]]) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | ]]} end) @@ -2254,22 +2097,13 @@ bbbbbbb]]) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | ]]} end) it('cursor position is correct when inserting around a virtual text with left gravity', function() - screen:try_resize(50, 3) insert('foo foo foo foo') - meths.buf_set_extmark(0, ns, 0, 8, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) feed('0') feed('8l') screen:expect{grid=[[ @@ -2329,161 +2163,131 @@ bbbbbbb]]) end) it('cursor position is correct when inserting around virtual texts with both left and right gravity', function() - screen:try_resize(50, 3) + screen:try_resize(30, 4) + command('setlocal showbreak=+ breakindent breakindentopt=shift:2') insert('foo foo foo foo') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + feed('08l') screen:expect{grid=[[ - foo foo {10:>><<}^foo foo | - {1:~ }| - | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>><<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<}^foo foo | + | ]]} - feed('i') screen:expect{grid=[[ - foo foo {10:>>^<<}foo foo | - {1:~ }| - {8:-- INSERT --} | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<}foo foo | + {8:-- INSERT --} | ]]} - feed('a') screen:expect{grid=[[ - foo foo {10:>>}a{10:^<<}foo foo | - {1:~ }| - {8:-- INSERT --} | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<<}foo foo | + {8:-- INSERT --} | ]]} - feed([[]]) screen:expect{grid=[[ - foo foo {10:>>}a{10:<<}^foo foo | - {1:~ }| - {8:-- (insert) --} | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>}a{10:<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<<}^foo foo | + {8:-- (insert) --} | ]]} - feed('D') screen:expect{grid=[[ - foo foo {10:>>}a{10:^<<} | - {1:~ }| - {8:-- INSERT --} | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<<} | + {8:-- INSERT --} | ]]} - feed('') screen:expect{grid=[[ - foo foo {10:>>^<<} | - {1:~ }| - {8:-- INSERT --} | + foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<<<<<<<<} | + {8:-- INSERT --} | ]]} - feed('') screen:expect{grid=[[ - {10:>>^<<} | - {1:~ }| - {8:-- INSERT --} | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>^<<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<} | + {8:-- INSERT --} | ]]} - feed('a') screen:expect{grid=[[ - {10:>>}a{10:^<<} | - {1:~ }| - {8:-- INSERT --} | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>}a{10:^<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<} | + {8:-- INSERT --} | ]]} - feed('') screen:expect{grid=[[ - {10:>>}^a{10:<<} | - {1:~ }| - | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>}^a{10:<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<<} | + | ]]} - feed('x') screen:expect{grid=[[ - {10:^>><<} | - {1:~ }| - | + {10:^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>><<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<} | + | ]]} end) it('draws correctly with no wrap multiple virtual text, where one is hidden', function() insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 50, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 2, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('$') - screen:expect { grid = [[ + screen:expect{grid=[[ opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('draws correctly with no wrap and a long virtual text', function() insert('abcdefghi') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 2, - { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('tabs are the correct length with no wrap following virtual text', function() command('set nowrap') feed('itesta') - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg$') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) - it('highlighting does not extend when no wrap is enabled with a long virtual text', function() + it('highlighting does not extend with no wrap and a long virtual text', function() insert('abcdef') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 3, - { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('$') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('hidden virtual text does not interfere with Visual highlight', function() @@ -2494,131 +2298,76 @@ bbbbbbb]]) screen:expect{grid=[[ {10:X}{7:abcde}^f | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- VISUAL LINE --} | ]]} feed('zl') screen:expect{grid=[[ {7:abcde}^f | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- VISUAL LINE --} | ]]} feed('zl') screen:expect{grid=[[ {7:bcde}^f | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {8:-- VISUAL LINE --} | ]]} end) it('highlighting is correct when virtual text wraps with number', function() + screen:try_resize(50, 5) insert([[ test test]]) command('set number') - meths.buf_set_extmark(0, ns, 0, 1, - { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') - screen:expect { grid = [[ + screen:expect{grid=[[ {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {2: }{10:XXXXXXXXXX}est | {2: 2 }test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('highlighting is correct when virtual text is proceeded with a match', function() insert([[test]]) - meths.buf_set_extmark(0, ns, 0, 2, - { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') command('match ErrorMsg /e/') - screen:expect { grid = [[ + screen:expect{grid=[[ ^t{4:e}{10:virtual text}st | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} command('match ErrorMsg /s/') - screen:expect { grid = [[ + screen:expect{grid=[[ ^te{10:virtual text}{4:s}t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('smoothscroll works correctly when virtual text wraps', function() insert('foobar') - meths.buf_set_extmark(0, ns, 0, 3, - { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) command('setlocal smoothscroll') screen:expect{grid=[[ foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XXXXXXXX}ba^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| | ]]} feed('') screen:expect{grid=[[ {1:<<<}{10:XXXXX}ba^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | ]]} end) it('in diff mode is highlighted correct', function() + screen:try_resize(50, 10) insert([[ 9000 0009 @@ -2642,7 +2391,7 @@ bbbbbbb]]) insert('aaabbb') command("set diff") feed('gg0') - screen:expect { grid = [[ + screen:expect{grid=[[ {9:^000 }│{5:9}{14:test}{9:000 }| {9:000 }│{9:000}{5:9}{9: }| {9:000 }│{9:000}{5:9}{9: }| @@ -2653,10 +2402,10 @@ bbbbbbb]]) {1:~ }│{1:~ }| {15:[No Name] [+] }{13:[No Name] [+] }| | - ]]} + ]]} command('wincmd w | set nowrap') feed('zl') - screen:expect { grid = [[ + screen:expect{grid=[[ {9:000 }│{14:test}{9:000 }| {9:000 }│{9:00}{5:9}{9: }| {9:000 }│{9:00}{5:9}{9: }| @@ -2667,56 +2416,32 @@ bbbbbbb]]) {1:~ }│{1:~ }| {13:[No Name] [+] }{15:[No Name] [+] }| | - ]]} + ]]} end) it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() command('set nowrap') insert('a') - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') - screen:expect { grid = [[ + screen:expect{grid=[[ {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function() command('set nowrap') feed('itest') - meths.buf_set_extmark( - 0, - ns, - 0, - 0, - { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' } - ) + meths.buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }) feed('0') - screen:expect({ - grid = [[ + screen:expect({grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]], - }) + ]]}) end) it('does not crash at column 0 when folded in a wide window', function() @@ -2811,37 +2536,21 @@ bbbbbbb]]) command('set nowrap') command('set list') command('set listchars+=extends:c') - meths.buf_set_extmark(0, ns, 0, 0, - { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) insert(string.rep('a', 50)) feed('gg0') - screen:expect { grid = [[ + screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| {1:~ }| | - ]]} + ]]} end) it('blockwise Visual highlight with double-width virtual text (replace)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { - virt_text = { { '-口-', 'Special' } }, - virt_text_pos = 'inline', - hl_mode = 'replace', - }) - meths.buf_set_extmark(0, ns, 2, 2, { - virt_text = { { '口', 'Special' } }, - virt_text_pos = 'inline', - hl_mode = 'replace', - }) + meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('gg0') screen:expect{grid=[[ ^123456789 | @@ -2910,16 +2619,8 @@ bbbbbbb]]) it('blockwise Visual highlight with double-width virtual text (combine)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { - virt_text = { { '-口-', 'Special' } }, - virt_text_pos = 'inline', - hl_mode = 'combine', - }) - meths.buf_set_extmark(0, ns, 2, 2, { - virt_text = { { '口', 'Special' } }, - virt_text_pos = 'inline', - hl_mode = 'combine', - }) + meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('gg0') screen:expect{grid=[[ ^123456789 | -- cgit From 466c18b8185c44f4fbf67ae91a2ffe27c1919306 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 24 Aug 2023 07:19:18 +0800 Subject: vim-patch:9.0.1785: wrong cursor position with 'showbreak' and lcs-eol (#24852) Problem: wrong cursor position with 'showbreak' and lcs-eol Solution: Add size of 'showbreak' before when 'listchars' "eol" is used. Also fix wrong cursor position with wrapping virtual text on empty line and 'showbreak'. closes: vim/vim#12891 https://github.com/vim/vim/commit/1193951bebcff50d88403ce17dec5d3be14f131d --- test/functional/ui/decorations_spec.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4e3214da71..6c1a7a6a2c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2886,6 +2886,15 @@ bbbbbbb]]) {1:~ }| | ]]} + feed('zbx') + screen:expect{grid=[[ + 1 ^12312312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123 | + {1:~ }| + {1:~ }| + | + ]]} end describe('with showbreak, smoothscroll', function() -- cgit From a9418ef8cfc00943fcd6f8f2236783442e09e91b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 24 Aug 2023 11:28:10 +0800 Subject: fix(ui): wrong display with 0-width inline virt_text at eol (#24854) --- test/functional/ui/decorations_spec.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6c1a7a6a2c..0a3a2e4e29 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1748,7 +1748,7 @@ describe('decorations: inline virtual text', function() ]]} end) - it('works with empty chunk', function() + it('works with 0-width chunk', function() screen:try_resize(50, 10) insert(example_text) feed 'gg' @@ -1766,7 +1766,22 @@ describe('decorations: inline virtual text', function() ]]} meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'}) + meths.buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'}) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + local text{10:: }, hl_id_cell, count = unpack(item)| + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + | + ]]} + + meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'}) feed('V') screen:expect{grid=[[ ^f{7:or _,item in ipairs(items) do} | -- cgit From 008154954791001efcc46c28146e21403f3a698b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 21 Aug 2023 14:52:17 +0200 Subject: refactor(change): do API changes to buffer without curbuf switch Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired. --- test/functional/ui/diff_spec.lua | 92 ++++++++ test/functional/ui/float_spec.lua | 472 ++++++++++++++++++-------------------- 2 files changed, 315 insertions(+), 249 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index 0f551e3044..92b7235885 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -1251,6 +1251,98 @@ AAAB]] ]]} end) end) + + it('redraws with a change to non-current buffer', function() + write_file(fname, "aaa\nbbb\nccc\n\nxx", false) + write_file(fname_2, "aaa\nbbb\nccc\n\nyy", false) + reread() + local buf = meths.get_current_buf() + command('botright new') + screen:expect{grid=[[ + {1: }aaa │{1: }aaa | + {1: }bbb │{1: }bbb | + {1: }ccc │{1: }ccc | + {1: } │{1: } | + {1: }{8:xx}{9: }│{1: }{8:yy}{9: }| + {6:~ }│{6:~ }| + {3:}| {5:<}{1: BORDAA }{5:>}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1743,16 +1743,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:_________}| {1: halloj! }| {1: BORDAA }| {5:---------}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1794,15 +1794,15 @@ describe('float window', function() ^ | ## grid 3 | - ## grid 5 + ## grid 4 {1: halloj! }{25: }| {1: BORDAA }{26: }| {25: }{26: }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1880,16 +1880,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔}{11:Left}{5:═════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1923,16 +1923,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔═}{11:Center}{5:══╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1966,16 +1966,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔════}{11:Right}{5:╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2009,16 +2009,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔═════}🦄BB{5:╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 2, 5, true } + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2117,17 +2117,17 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔═════════╗}| {5:║}{1:aaa aab }{5:║}| {5:║}{1:abb acc }{5:║}| {5:║}{1:^ }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; + [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2170,23 +2170,23 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- }{8:match 1 of 4} | - ## grid 5 + ## grid 4 {5:╔═════════╗}| {5:║}{1:aaa aab }{5:║}| {5:║}{1:abb acc }{5:║}| {5:║}{1:acc^ }{5:║}| {5:╚═════════╝}| - ## grid 6 + ## grid 5 {1: aaa }| {1: aab }| {1: abb }| {13: acc }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 }; - [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 }; + [4] = { { id = 1001 }, "NW", 1, 0, 5, true, 50 }; + [5] = { { id = -1 }, "NW", 4, 4, 0, false, 100 }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2229,17 +2229,17 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:╔═════════╗}| {5:║}{1:aaa aab }{5:║}| {5:║}{1:abb acc }{5:║}| {5:║}{1:ac^c }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; + [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2287,22 +2287,22 @@ describe('float window', function() {0:~ }| ## grid 3 :popup Test | - ## grid 5 + ## grid 4 {5:╔═════════╗}| {5:║}{1:aaa aab }{5:║}| {5:║}{1:abb acc }{5:║}| {5:║}{1:ac^c }{5:║}| {5:╚═════════╝}| - ## grid 6 + ## grid 5 {1: foo }| {1: bar }| {1: baz }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 5, true }; - [6] = { { id = -1 }, "NW", 5, 4, 2, false, 250 }; + [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; + [5] = { { id = -1 }, "NW", 4, 4, 2, false, 250 }; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2347,15 +2347,15 @@ describe('float window', function() {0:~ }| ## grid 3 1,1 All | - ## grid 5 + ## grid 4 {1:^aaa aab }| {1:abb acc }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2389,15 +2389,15 @@ describe('float window', function() {0:~ }| ## grid 3 1,5 All | - ## grid 5 + ## grid 4 {1:aaa ^aab }| {1:abb acc }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2596,10 +2596,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:x}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 2, 0, 4, false} + [4] = {{id = 1001}, "NW", 2, 0, 4, false} }} else screen:expect([[ @@ -2633,10 +2633,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:x}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 2, 0, 15, false} + [4] = {{id = 1001}, "NW", 2, 0, 15, false} }} else screen:expect([[ @@ -3132,13 +3132,13 @@ describe('float window', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 6 + ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [6] = {{id = 1003}, "NW", 4, 1, 14, true} + [5] = {{id = 1002}, "NW", 4, 1, 14, true} }} else screen:expect([[ @@ -3189,13 +3189,13 @@ describe('float window', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 6 + ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [6] = {{id = 1003}, "NE", 4, 0, 14, true} + [5] = {{id = 1002}, "NE", 4, 0, 14, true} }} else screen:expect([[ @@ -3246,13 +3246,13 @@ describe('float window', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 6 + ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [6] = {{id = 1003}, "SE", 4, 1, 14, true} + [5] = {{id = 1002}, "SE", 4, 1, 14, true} }} else screen:expect([[ @@ -3303,13 +3303,13 @@ describe('float window', function() {0:~ }| {0:~ }| {0:~ }| - ## grid 6 + ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [6] = {{id = 1003}, "SW", 4, 0, 14, true} + [5] = {{id = 1002}, "SW", 4, 0, 14, true} }} else screen:expect([[ @@ -3379,12 +3379,10 @@ describe('float window', function() | ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 3, 2, true } + [4] = { { id = 1001 }, "NW", 2, 3, 2, true } }} else screen:expect{grid=[[ @@ -3414,12 +3412,10 @@ describe('float window', function() | ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 2, 2, true } + [4] = { { id = 1001 }, "NW", 2, 2, 2, true }, }} else screen:expect{grid=[[ @@ -3448,12 +3444,10 @@ describe('float window', function() more text | ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 1, 32, true } + [4] = { { id = 1001 }, "NW", 2, 1, 32, true } }} else -- note: appears misaligned due to cursor @@ -3492,12 +3486,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 2, 7, true } + [4] = { { id = 1001 }, "NW", 2, 2, 7, true } }} else screen:expect{grid=[[ @@ -3540,12 +3532,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "SW", 2, 1, 7, true } + [4] = { { id = 1001 }, "SW", 2, 1, 7, true } }} else screen:expect{grid=[[ @@ -3567,15 +3557,15 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| - [2:----]{5:│}[6:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]| [3:-------------------------]| ## grid 2 exam| @@ -3589,9 +3579,9 @@ describe('float window', function() the | ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| - ## grid 6 + ## grid 5 ^ | {0:~ }| {0:~ }| @@ -3602,9 +3592,7 @@ describe('float window', function() {0:~ }| {0:~ }| ]], float_pos={ - [5] = { { - id = 1002 - }, "SW", 2, 8, 0, true } + [4] = { { id = 1001 }, "SW", 2, 8, 0, true } }} else screen:expect{grid=[[ @@ -3648,12 +3636,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 2, 5, true } + [4] = { { id = 1001 }, "NW", 2, 2, 5, true } }} else screen:expect{grid=[[ @@ -3696,12 +3682,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 3, 7, true } + [4] = { { id = 1001 }, "NW", 2, 3, 7, true } }} else screen:expect{grid=[[ @@ -3744,12 +3728,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some info! }| ]], float_pos={ - [5] = { { - id = 1002 - }, "NW", 2, 2, 0, true } + [4] = { { id = 1001 }, "NW", 2, 2, 0, true } }} else screen:expect{grid=[[ @@ -3815,10 +3797,10 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:some floaty text }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 3, 1, true} + [4] = {{id = 1001}, "NW", 1, 3, 1, true} }} else screen:expect([[ @@ -3874,7 +3856,7 @@ describe('float window', function() meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) local win = meths.open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) local expected_pos = { - [5]={{id=1002}, 'NW', 1, 2, 10, true}, + [4]={{id=1001}, 'NW', 1, 2, 10, true}, } if multigrid then screen:expect{grid=[[ @@ -3895,7 +3877,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -3929,7 +3911,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -3959,7 +3941,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -3986,7 +3968,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:float }| @@ -4011,7 +3993,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:^float }| @@ -4045,7 +4027,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:such }| {1:very }| {1:^float }| @@ -4084,7 +4066,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4121,7 +4103,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4158,7 +4140,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4195,7 +4177,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4232,7 +4214,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4269,7 +4251,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4306,7 +4288,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4343,7 +4325,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4371,7 +4353,7 @@ describe('float window', function() | ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -4403,7 +4385,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^such }| {1:very }| {1:float }| @@ -5063,12 +5045,12 @@ describe('float window', function() {13:aa }| {1:word }| {1:longtext }| - ## grid 6 + ## grid 5 {15:some info }| {15:about item }| ]], float_pos={ [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}, - [6] = {{id = 1002}, "NW", 2, 1, 12, true, 50}, + [5] = {{id = 1001}, "NW", 2, 1, 12, true, 50}, }} else screen:expect([[ @@ -5104,11 +5086,11 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- INSERT --} | - ## grid 6 + ## grid 5 {15:some info }| {15:about item }| ]], float_pos={ - [6] = {{id = 1002}, "NW", 2, 1, 12, true}, + [5] = {{id = 1001}, "NW", 2, 1, 12, true}, }} else screen:expect([[ @@ -5256,14 +5238,14 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 here | float | ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7580,18 +7562,18 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:foo }| {1:bar }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 5, 0, 0) + meths.input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7610,18 +7592,18 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:^foo }| {1:bar }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 5, 1, 2) + meths.input_mouse('left', 'drag', '', 4, 1, 2) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7640,15 +7622,15 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- VISUAL --} | - ## grid 5 + ## grid 4 {27:foo}{1: }| {27:ba}{1:^r }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7708,20 +7690,20 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:┌────────────────────┐}| {5:│}{1:foo }{5:│}| {5:│}{1:bar }{5:│}| {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 5, 1, 1) + meths.input_mouse('left', 'press', '', 4, 1, 1) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7740,20 +7722,20 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:┌────────────────────┐}| {5:│}{1:^foo }{5:│}| {5:│}{1:bar }{5:│}| {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 5, 2, 3) + meths.input_mouse('left', 'drag', '', 4, 2, 3) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7772,17 +7754,17 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- VISUAL --} | - ## grid 5 + ## grid 4 {5:┌────────────────────┐}| {5:│}{27:foo}{1: }{5:│}| {5:│}{27:ba}{1:^r }{5:│}| {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7843,19 +7825,19 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {3:floaty bar }| {1:foo }| {1:bar }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 5, 1, 0) + meths.input_mouse('left', 'press', '', 4, 1, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7874,19 +7856,19 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {3:floaty bar }| {1:^foo }| {1:bar }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 5, 2, 2) + meths.input_mouse('left', 'drag', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -7905,16 +7887,16 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- VISUAL --} | - ## grid 5 + ## grid 4 {3:floaty bar }| {27:foo}{1: }| {27:ba}{1:^r }| {1:baz }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -7959,11 +7941,11 @@ describe('float window', function() if multigrid then screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7974,7 +7956,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 ^foo | bar | baz | @@ -7982,14 +7964,14 @@ describe('float window', function() {0:~ }| ]]) - meths.input_mouse('left', 'press', '', 5, 2, 2) + meths.input_mouse('left', 'press', '', 4, 2, 2) screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8000,7 +7982,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 foo | bar | ba^z | @@ -8008,14 +7990,14 @@ describe('float window', function() {0:~ }| ]]) - meths.input_mouse('left', 'drag', '', 5, 1, 1) + meths.input_mouse('left', 'drag', '', 4, 1, 1) screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| - [2:-------------------]{5:│}[5:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8026,7 +8008,7 @@ describe('float window', function() {0:~ }| ## grid 3 {3:-- VISUAL --} | - ## grid 5 + ## grid 4 foo | b^a{27:r} | {27:baz} | @@ -8125,11 +8107,11 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {1:test }| {1: }| {1:popup text }| - ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -8168,11 +8150,11 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {9:test }| {9: }| {9:popup text }| - ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -8212,12 +8194,12 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {13:test }| {13: }| {13:popup text }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50}; + [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; }} else screen:expect([[ @@ -8264,11 +8246,11 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {9:test }| {9: }| {10:popup text}{9: }| - ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -8307,11 +8289,11 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {9:test }| {9: }| {11:popup text}{9: }| - ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -8328,7 +8310,7 @@ describe('float window', function() -- Test scrolling by mouse if multigrid then - meths.input_mouse('wheel', 'down', '', 5, 2, 2) + meths.input_mouse('wheel', 'down', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 [2:--------------------------------------------------]| @@ -8351,11 +8333,11 @@ describe('float window', function() laborum^. | ## grid 3 | - ## grid 5 + ## grid 4 {11:popup text}{9: }| {12:~ }| {12:~ }| - ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else meths.input_mouse('wheel', 'down', '', 0, 4, 7) screen:expect([[ @@ -8398,11 +8380,11 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {1:口 }| {1:口 }| {1: }| - ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 0, 11, true } }} + ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 0, 11, true } }} else screen:expect([[ # TODO: 测 {1:口 }信息的准确性 | @@ -8480,14 +8462,12 @@ describe('float window', function() {3:~ }| ## grid 3 | - ## grid 6 + ## grid 5 {5: x x x xx}| {5: x x x x}| {5: }| ]], float_pos={ - [6] = { { - id = 1003 - }, "NW", 1, 0, 11, true } + [5] = { { id = 1002 }, "NW", 1, 0, 11, true } }} else screen:expect([[ @@ -8521,14 +8501,12 @@ describe('float window', function() {3:~ }| ## grid 3 | - ## grid 6 + ## grid 5 {5: x x x xx}| {5: x x x x}| {5: }| ]], float_pos={ - [6] = { { - id = 1003 - }, "NW", 1, 0, 12, true } + [5] = { { id = 1002 }, "NW", 1, 0, 12, true } }} else screen:expect([[ @@ -8590,11 +8568,11 @@ describe('float window', function() {1:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {2:^long }| {2:longer }| {2:longest}| - ## grid 6 + ## grid 5 {2:---------}| {2:- -}| {2:- -}| @@ -8604,11 +8582,11 @@ describe('float window', function() [1] = {foreground = Screen.colors.Blue1, bold = true}; [2] = {background = Screen.colors.LightMagenta}; }, float_pos={ + [4] = { { + id = 1001 + }, "NW", 1, 1, 1, true }, [5] = { { id = 1002 - }, "NW", 1, 1, 1, true }, - [6] = { { - id = 1003 }, "NW", 1, 0, 0, true } }} else @@ -8658,11 +8636,11 @@ describe('float window', function() {1:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {2:^l}| {2:o}| {2:n}| - ## grid 6 + ## grid 5 {2:---}| {2:- -}| {2:- -}| @@ -8672,12 +8650,8 @@ describe('float window', function() [1] = {foreground = Screen.colors.Blue1, bold = true}; [2] = {background = Screen.colors.LightMagenta}; }, float_pos={ - [5] = { { - id = 1002 - }, "NW", 1, 1, 1, true }, - [6] = { { - id = 1003 - }, "NW", 1, 0, 0, true } + [4] = { { id = 1001 }, "NW", 1, 1, 1, true }, + [5] = { { id = 1002 }, "NW", 1, 0, 0, true } }} else screen:expect([[ @@ -9088,7 +9062,7 @@ describe('float window', function() {0:~ }| {0:~ }| ## grid 3 - ## grid 5 + ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| {5:│}{1: }{5:│}| @@ -9096,10 +9070,10 @@ describe('float window', function() {5:│}{1: }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50}; + [4] = {{id = 1001}, "SW", 1, 9, 0, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9144,16 +9118,16 @@ describe('float window', function() {0:~ }| {0:~ }| ## grid 3 - ## grid 5 + ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| {5:│}{1: }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50}; + [4] = {{id = 1001}, "SW", 1, 9, 0, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9240,7 +9214,7 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| {5:│}{1: }{5:│}| @@ -9248,10 +9222,10 @@ describe('float window', function() {5:│}{1: }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; + [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9300,7 +9274,7 @@ describe('float window', function() ## grid 3 | {8:Press ENTER or type command to continue}^ | - ## grid 5 + ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| {5:│}{1: }{5:│}| @@ -9308,10 +9282,10 @@ describe('float window', function() {5:│}{1: }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; + [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9351,16 +9325,16 @@ describe('float window', function() {0:~ }| ## grid 3 | - ## grid 5 + ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| {5:│}{1: }{5:│}| {5:└────────────────────────────────────────┘}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50}; + [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; }, win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ -- cgit From 362df0f7938a0e6147ecf886655a0689430d426d Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Sat, 26 Aug 2023 21:39:05 +1000 Subject: fix(extmarks): wrong display when changing text with virt_lines (#24879) --- test/functional/ui/decorations_spec.lua | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 0a3a2e4e29..36d6fea1de 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -3784,6 +3784,63 @@ if (h->n_buckets < new_n_buckets) { // expand ]]} end) + it('works when using dd or yyp #23915 #23916', function() + insert([[ + line1 + line2 + line3 + line4 + line5]]) + meths.buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}}) + screen:expect{grid=[[ + line1 | + foo | + bar | + baz | + line2 | + line3 | + line4 | + line^5 | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('gg') + feed('dd') + screen:expect{grid=[[ + ^line2 | + foo | + bar | + baz | + line3 | + line4 | + line5 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed('yyp') + screen:expect{grid=[[ + line2 | + foo | + bar | + baz | + ^line2 | + line3 | + line4 | + line5 | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) + end) describe('decorations: signs', function() -- cgit From afd0c648a89ff88c9bff1b24c37e139813ec13c9 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sat, 26 Aug 2023 15:10:04 +0200 Subject: fix(statuscolumn): force full redraw when signcolumn is invalid (#24859) Fix #24655 --- test/functional/ui/statuscolumn_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 35cd479bb9..ee235cd6b5 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -727,6 +727,8 @@ describe('statuscolumn', function() end return vim.v.lnum .. '%=' .. sign end + vim.o.number = true + vim.o.numberwidth = 2 vim.o.statuscolumn = "%!v:lua.StatusCol()" ]]) command('sign place 1 line=2 name=sign') -- cgit From 35570e4a11bef061777d741929f74fa66ba3f45a Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Fri, 25 Aug 2023 10:53:35 +0300 Subject: feat(float): implement footer Problem: Now way to show text at the bottom part of floating window border (a.k.a. "footer"). Solution: Allows `footer` and `footer_pos` config fields similar to `title` and `title_pos`. --- test/functional/ui/float_spec.lua | 395 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 395 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 85795e7e17..6cdd6e51fa 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1851,6 +1851,39 @@ describe('float window', function() eq('center', title_pos) end) + it('validates footer footer_pos', function() + local buf = meths.create_buf(false,false) + eq("footer requires border to be set", + pcall_err(meths.open_win,buf, false, { + relative='editor', width=9, height=2, row=2, col=5, footer='Footer', + })) + eq("footer_pos requires footer to be set", + pcall_err(meths.open_win,buf, false, { + relative='editor', width=9, height=2, row=2, col=5, + border='single', footer_pos='left', + })) + end) + + it('validate footer_pos in nvim_win_get_config', function() + local footer_pos = exec_lua([[ + local bufnr = vim.api.nvim_create_buf(false, false) + local opts = { + relative = 'editor', + col = 2, + row = 5, + height = 2, + width = 9, + border = 'double', + footer = 'Test', + footer_pos = 'center' + } + + local win_id = vim.api.nvim_open_win(bufnr, true, opts) + return vim.api.nvim_win_get_config(win_id).footer_pos + ]]) + + eq('center', footer_pos) + end) it('border with title', function() local buf = meths.create_buf(false, false) @@ -2033,6 +2066,368 @@ describe('float window', function() end end) + it('border with footer', function() + local buf = meths.create_buf(false, false) + meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + ' BORDAA '}) + local win = meths.open_win(buf, false, { + relative='editor', width=9, height=2, row=2, col=5, border="double", + footer = "Left",footer_pos = "left", + }) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═════════╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚}{11:Left}{5:═════╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═════════╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚}{11:Left}{5:═════╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {footer= "Center",footer_pos="center"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═════════╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚═}{11:Center}{5:══╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═════════╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚═}{11:Center}{5:══╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {footer= "Right",footer_pos="right"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═════════╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚════}{11:Right}{5:╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═════════╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚════}{11:Right}{5:╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═════════╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚═════}🦄BB{5:╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═════════╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚═════}🦄BB{5:╝}{0: }| + | + ]]} + end + end) + + it('border with title and footer', function() + local buf = meths.create_buf(false, false) + meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + ' BORDAA '}) + local win = meths.open_win(buf, false, { + relative='editor', width=9, height=2, row=2, col=5, border="double", + title = "Left", title_pos = "left", footer = "Right", footer_pos = "right", + }) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔}{11:Left}{5:═════╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚════}{11:Right}{5:╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔}{11:Left}{5:═════╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚════}{11:Right}{5:╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═}{11:Center}{5:══╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚═}{11:Center}{5:══╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═}{11:Center}{5:══╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚═}{11:Center}{5:══╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔════}{11:Right}{5:╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚}{11:Left}{5:═════╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔════}{11:Right}{5:╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚}{11:Left}{5:═════╝}{0: }| + | + ]]} + end + + meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right",footer= { {"🦄"},{"BB"}},footer_pos="right"}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔═════}🦄BB{5:╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚═════}🦄BB{5:╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔═════}🦄BB{5:╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚═════}🦄BB{5:╝}{0: }| + | + ]]} + end + end) + it('terminates border on edge of viewport when window extends past viewport', function() local buf = meths.create_buf(false, false) meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) -- cgit From 1f49c980368616345d8d0e121fed66a2013f9e96 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 27 Aug 2023 20:04:44 +0800 Subject: vim-patch:9.0.1792: problem with gj/gk/gM and virtual text (#24898) Problem: Normal mode "gM", "gj", "gk" commands behave incorrectly with virtual text. Solution: Use linetabsize() instead of linetabsize_str(). closes: vim/vim#12909 https://github.com/vim/vim/commit/d809c0a90387a23aed21ba37d0b65332fb5dafe7 --- test/functional/ui/decorations_spec.lua | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 36d6fea1de..0dd8fd8ad9 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1811,6 +1811,98 @@ describe('decorations: inline virtual text', function() ]]} end) + it('Normal mode "gM" command works properly', function() + command([[call setline(1, '123456789')]]) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 7, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + feed('gM') + screen:expect{grid=[[ + 12{10:bbb}34^567{10:bbb}89 | + {1:~ }| + | + ]]} + end) + + local function test_normal_gj_gk() + screen:try_resize(60, 6) + command([[call setline(1, repeat([repeat('a', 55)], 2))]]) + meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 1, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + feed('gj') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + ^aaaaa | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + feed('gj') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + feed('gj') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + ^aaaaa | + {1:~ }| + | + ]]} + feed('gk') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + feed('gk') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + ^aaaaa | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + feed('gk') + screen:expect{grid=[[ + ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| + aaaaa | + {1:~ }| + | + ]]} + end + + describe('Normal mode "gj" "gk" commands work properly', function() + it('with virtualedit=', function() + test_normal_gj_gk() + end) + + it('with virtualedit=all', function() + command('set virtualedit=all') + test_normal_gj_gk() + end) + end) + it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) -- cgit From 128091a256d64db2f983d70a888b379d7e63f131 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 24 Aug 2023 07:27:18 +0800 Subject: fix(ui): wrong cursor position with left gravity inline virt text at eol --- test/functional/ui/decorations_spec.lua | 141 +++++++++++++++++++++----------- 1 file changed, 94 insertions(+), 47 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 0dd8fd8ad9..c6d5c20649 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2209,111 +2209,119 @@ bbbbbbb]]) end) it('cursor position is correct when inserting around a virtual text with left gravity', function() - insert('foo foo foo foo') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) - feed('0') - feed('8l') + screen:try_resize(27, 4) + insert(('a'):rep(15)) + meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + command('setlocal showbreak=+ breakindent breakindentopt=shift:2') + feed('08l') screen:expect{grid=[[ - foo foo {10:virtual text}^foo foo | - {1:~ }| - | + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}^aaaaaaa | + | ]]} - feed('i') screen:expect{grid=[[ - foo foo {10:virtual text}^foo foo | - {1:~ }| - {8:-- INSERT --} | + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}^aaaaaaa | + {8:-- INSERT --} | ]]} - feed([[]]) screen:expect{grid=[[ - foo foo {10:virtual text}^foo foo | - {1:~ }| - {8:-- (insert) --} | + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}^aaaaaaa | + {8:-- (insert) --} | ]]} - feed('D') screen:expect{grid=[[ - foo foo {10:virtual text}^ | - {1:~ }| - {8:-- INSERT --} | + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:^~ }| + {8:-- INSERT --} | + ]]} + command('setlocal list listchars=eol:$') + screen:expect{grid=[[ + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+^$} | + {8:-- INSERT --} | ]]} - feed('') screen:expect{grid=[[ - {10:virtual text}^ | - {1:~ }| - {8:-- INSERT --} | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>}{1:^$} | + {1:~ }| + {8:-- INSERT --} | ]]} - feed('a') screen:expect{grid=[[ - {10:virtual text}a^ | - {1:~ }| - {8:-- INSERT --} | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>}a{1:^$} | + {1:~ }| + {8:-- INSERT --} | ]]} - feed('') screen:expect{grid=[[ - {10:virtual text}^a | - {1:~ }| - | + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>}^a{1:$} | + {1:~ }| + | ]]} - feed('x') screen:expect{grid=[[ - {10:^virtual text} | - {1:~ }| - | + {10:^>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>>>>>>>>>>>>>>>}{1:$} | + {1:~ }| + | ]]} end) it('cursor position is correct when inserting around virtual texts with both left and right gravity', function() screen:try_resize(30, 4) command('setlocal showbreak=+ breakindent breakindentopt=shift:2') - insert('foo foo foo foo') + insert(('a'):rep(15)) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) - feed('08l') screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>><<<<<<<<<<<<<<<<<}| - {1:+}{10:<<<<<<<<<<<<<<<}^foo foo | + {1:+}{10:<<<<<<<<<<<<<<<}^aaaaaaa | | ]]} feed('i') screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| - {1:+}{10:<<<<<<<<<<<<<<<}foo foo | + {1:+}{10:<<<<<<<<<<<<<<<}aaaaaaa | {8:-- INSERT --} | ]]} feed('a') screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| - {1:+}{10:<<<<<<<<<<<<<<<<}foo foo | + {1:+}{10:<<<<<<<<<<<<<<<<}aaaaaaa | {8:-- INSERT --} | ]]} feed([[]]) screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>>}a{10:<<<<<<<<<<<<<<<<}| - {1:+}{10:<<<<<<<<<<<<<<<<}^foo foo | + {1:+}{10:<<<<<<<<<<<<<<<<}^aaaaaaa | {8:-- (insert) --} | ]]} feed('D') screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}| {1:+}{10:<<<<<<<<<<<<<<<<} | {8:-- INSERT --} | ]]} feed('') screen:expect{grid=[[ - foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}| + aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}| {1:+}{10:<<<<<<<<<<<<<<<} | {8:-- INSERT --} | @@ -2346,6 +2354,27 @@ bbbbbbb]]) {1:+}{10:<<<<<<<} | | ]]} + feed('i') + screen:expect{grid=[[ + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:>>^<<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<<<<<} | + {8:-- INSERT --} | + ]]} + screen:try_resize(32, 4) + screen:expect{grid=[[ + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<<<} | + {8:-- INSERT --} | + ]]} + command('setlocal nobreakindent') + screen:expect{grid=[[ + {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}| + {1:+}{10:^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<}| + {1:+}{10:<} | + {8:-- INSERT --} | + ]]} end) it('draws correctly with no wrap multiple virtual text, where one is hidden', function() @@ -3002,6 +3031,24 @@ bbbbbbb]]) {1:~ }| | ]]} + feed('26iaa') + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}^12312312312312312312312| + {1:+}31231231231231231231231| + {1:+}23123123123123123123123| + {1:~ }| + {8:-- INSERT --} | + ]]} + feed([[:setlocal breakindentopt=]]) + screen:expect{grid=[[ + 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}^1231231231231231231231231| + {1:+}2312312312312312312312312| + {1:+}3123123123123123123 | + {1:~ }| + {8:-- INSERT --} | + ]]} end describe('with showbreak, smoothscroll', function() -- cgit From c70aa84b2a79e8ac83a930dd5bf473940274cf1c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Aug 2023 05:51:19 +0800 Subject: vim-patch:9.0.1800: Cursor position still wrong with 'showbreak' and virtual text Problem: Cursor position still wrong with 'showbreak' and virtual text after last character or 'listchars' "eol". Solution: Remove unnecessary w_wcol adjustment in curs_columns(). Also fix first char of virtual text not shown at the start of a screen line. closes: vim/vim#12478 closes: vim/vim#12532 closes: vim/vim#12904 https://github.com/vim/vim/commit/6a3897232aecd3e8b9e8b23955e55c1993e5baec --- test/functional/ui/decorations_spec.lua | 44 ++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index c6d5c20649..5ca554e753 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2668,7 +2668,45 @@ bbbbbbb]]) ]]} end) - it('list "extends" is drawn with only inline virtual text offscreen', function() + it('lcs-extends is drawn with inline virtual text at end of screen line', function() + exec([[ + setlocal nowrap list listchars=extends:! + call setline(1, repeat('a', 51)) + ]]) + meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + feed('20l') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:b}{1:!}| + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bb}{1:!}| + {1:~ }| + | + ]]} + feed('zl') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbb}a| + {1:~ }| + | + ]]} + end) + + it('lcs-extends is drawn with only inline virtual text offscreen', function() command('set nowrap') command('set list') command('set listchars+=extends:c') @@ -2826,9 +2864,9 @@ bbbbbbb]]) screen:try_resize(30, 6) exec([[ highlight! link LineNr Normal - call setline(1, repeat('a', 28)) setlocal number showbreak=+ breakindent breakindentopt=shift:2 setlocal scrolloff=0 smoothscroll + call setline(1, repeat('a', 28)) normal! $ ]]) meths.buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) @@ -3066,8 +3104,8 @@ bbbbbbb]]) it('before TABs with smoothscroll', function() screen:try_resize(30, 6) exec([[ - call setline(1, repeat("\t", 4) .. 'a') setlocal list listchars=tab:<-> scrolloff=0 smoothscroll + call setline(1, repeat("\t", 4) .. 'a') normal! $ ]]) meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) -- cgit From 062db5c136700c35ff700fa4567b6ec8042539c7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Aug 2023 06:02:11 +0800 Subject: vim-patch:9.0.1802: Multiline regex with Visual selection fails with virtual text Problem: Multiline regex with Visual selection fails when Visual selection contains virtual text after last char. Solution: Only include virtual text after last char when getting full line length. closes: vim/vim#12908 https://github.com/vim/vim/commit/e3daa06be1a3ba7ced0735582467d092275e591c --- test/functional/ui/decorations_spec.lua | 149 +++++++++++++++++--------------- 1 file changed, 79 insertions(+), 70 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 5ca554e753..63f8c1e82c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1976,91 +1976,100 @@ describe('decorations: inline virtual text', function() end) it('text is drawn correctly with a wrapping virtual text', function() - screen:try_resize(50, 8) - feed('o') - insert([[aaaaaaa - -bbbbbbb]]) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) - feed('gg0') + screen:try_resize(60, 8) + exec([[ + call setline(1, ['', 'aaa', '', 'bbbbbb']) + normal gg0 + ]]) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 61), 'Special' } }, virt_text_pos = 'inline' }) + feed('$') screen:expect{grid=[[ - {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {10:X} | - aaaaaaa | - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - bbbbbbb | - {1:~ }| - {1:~ }| - | - ]]} - + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + aaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + bbbbbb | + {1:~ }| + {1:~ }| + | + ]]} feed('j') screen:expect{grid=[[ - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {10:X} | - ^aaaaaaa | - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - bbbbbbb | - {1:~ }| - {1:~ }| - | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + aa^a | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + bbbbbb | + {1:~ }| + {1:~ }| + | ]]} - feed('j') screen:expect{grid=[[ - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {10:X} | - aaaaaaa | - {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - bbbbbbb | - {1:~ }| - {1:~ }| - | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + aaa | + {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + bbbbbb | + {1:~ }| + {1:~ }| + | ]]} - feed('j') screen:expect{grid=[[ - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {10:X} | - aaaaaaa | - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - ^bbbbbbb | - {1:~ }| - {1:~ }| - | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + aaa | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + bbbbb^b | + {1:~ }| + {1:~ }| + | ]]} - - feed('ggic') + feed('02l2k') screen:expect{grid=[[ - c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - {10:XX} | - aaaaaaa | - {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| - bbbbbbb | - {1:~ }| - {1:~ }| - {8:-- INSERT --} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {7:aa}^a | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + {7:bbb}bbb | + {1:~ }| + {1:~ }| + {8:-- VISUAL BLOCK --} | ]]} - end) - - it('regexp \\%V does not count trailing virtual text', function() - screen:try_resize(50, 4) - meths.buf_set_lines(0, 0, -1, true, {'foofoo', '', 'foofoo'}) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text = {{'barbarbar', 'Special'}}, virt_text_pos = 'inline' }) - feed([[G5l/foo\n\%V]]) + feed([[/aaa\n\%V]]) + screen:expect{grid=[[ + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {12:^aaa } | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:X} | + bbbbbb | + {1:~ }| + {1:~ }| + {16:search hit BOTTOM, continuing at TOP} | + ]]} + feed('3ggic') screen:expect{grid=[[ - foo{12:^foo } | - {10:barbarbar} | - foofoo | - {16:search hit BOTTOM, continuing at TOP} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {12:aaa } | + c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XX} | + bbbbbb | + {1:~ }| + {1:~ }| + {8:-- INSERT --} | ]]} - feed([[jIbaz/foo\nbaz\%V]]) + feed([[/aaa\nc\%V]]) screen:expect{grid=[[ - foo{12:^foo } | - {12:baz}{10:barbarbar} | - foofoo | - {16:search hit BOTTOM, continuing at TOP} | + {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {12:^aaa } | + {12:c}{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| + {10:XX} | + bbbbbb | + {1:~ }| + {1:~ }| + {16:search hit BOTTOM, continuing at TOP} | ]]} end) -- cgit From 839d919098ed2cf3dfb93b6337a3d2ea2bd210a0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 31 Aug 2023 08:35:08 +0800 Subject: vim-patch:9.0.1825: wrong cursor position with virt text and 'linebreak' (#24957) Problem: Wrong cursor position with virtual text before a whitespace character and 'linebreak'. Solution: Always set "col_adj" to "size - 1" and apply 'linebreak' after adding the size of 'breakindent' and 'showbreak'. closes: vim/vim#12956 https://github.com/vim/vim/commit/6e55e85f92aff43c1b3cb564201440f3552d63f0 N/A patches: vim-patch:9.0.1826: keytrans() doesn't translate recorded key typed in a GUI --- test/functional/ui/decorations_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 63f8c1e82c..ba8d548a57 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -3217,6 +3217,33 @@ describe('decorations: inline virtual text', function() | ]]} end) + + it('before a space with linebreak', function() + screen:try_resize(50, 6) + exec([[ + setlocal linebreak showbreak=+ breakindent breakindentopt=shift:2 + call setline(1, repeat('a', 50) .. ' ' .. repeat('c', 45)) + normal! $ + ]]) + meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:+}bbbbbbbbbb | + {1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | + {1:~ }| + {1:~ }| + | + ]]} + feed('05x$') + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb| + {1:+}bbbbb | + {1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 592a8f1e90d5abaa695280bf6d41a547b3631d0d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 1 Sep 2023 06:45:27 +0800 Subject: vim-patch:9.0.1828: cursor wrong with virt text before double-width char (#24967) Problem: Wrong cursor position with virtual text before double-width char at window edge. Solution: Check for double-width char before adding virtual text size. closes: vim/vim#12977 https://github.com/vim/vim/commit/ac2d8815ae7a93c54b07cba76475cfb3f26a3ac6 --- test/functional/ui/decorations_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ba8d548a57..62dbd57202 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -3244,6 +3244,19 @@ describe('decorations: inline virtual text', function() | ]]} end) + + it('before double-width char that wraps', function() + exec([[ + call setline(1, repeat('a', 40) .. '口' .. '12345') + normal! $ + ]]) + meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' }) + screen:expect{grid=[[ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| + 口1234^5 | + | + ]]} + end) end) describe('decorations: virtual lines', function() -- cgit From 2b475cb5cc2196a32085fbbdfd7357cbb02a1cb0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 11 Sep 2023 08:29:33 +0800 Subject: fix(mouse): click on 'statuscolumn' with 'rightleft' (#25090) --- test/functional/ui/statuscolumn_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index ee235cd6b5..742976cbe2 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -532,6 +532,24 @@ describe('statuscolumn', function() eq('0 3 r 7', eval("g:testvar")) meths.input_mouse('right', 'press', '', 0, 3, 0) eq('0 4 r 7', eval("g:testvar")) + + command('rightbelow vsplit') + meths.input_mouse('left', 'press', '', 0, 0, 27) + eq('0 1 l 4', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 27) + eq('0 1 r 7', eval("g:testvar")) + command('setlocal rightleft') + meths.input_mouse('left', 'press', '', 0, 0, 52) + eq('0 1 l 4', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 52) + eq('0 1 r 7', eval("g:testvar")) + command('wincmd H') + meths.input_mouse('left', 'press', '', 0, 0, 25) + eq('0 1 l 4', eval("g:testvar")) + meths.input_mouse('right', 'press', '', 0, 3, 25) + eq('0 1 r 7', eval("g:testvar")) + command('close') + command('set laststatus=2 winbar=%f') command('let g:testvar = ""') -- Check that winbar click doesn't register as statuscolumn click -- cgit From 65738202f8be3ca63b75197d48f2c7a9324c035b Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Tue, 12 Sep 2023 04:29:39 +0900 Subject: fix(decorations): better approximation of botline #24794 Problem: * The guessed botline might be smaller than the actual botline e.g. when there are folds and the user is typing in insert mode. This may result in incorrect treesitter highlights for injections. * botline can be larger than the last line number of the buffer, which results in errors when placing extmarks. Solution: * Take a more conservative approximation. I am not sure if it is sufficient to guarantee correctness, but it seems to be good enough for the case mentioned above. * Clamp it to the last line number. Co-authored-by: Lewis Russell --- test/functional/ui/decorations_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 62dbd57202..a75290b400 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -103,7 +103,7 @@ describe('decorations providers', function() ]]} check_trace { { "start", 4 }; - { "win", 1000, 1, 0, 8 }; + { "win", 1000, 1, 0, 6 }; { "line", 1000, 1, 0 }; { "line", 1000, 1, 1 }; { "line", 1000, 1, 2 }; @@ -128,7 +128,7 @@ describe('decorations providers', function() check_trace { { "start", 5 }; { "buf", 1, 5 }; - { "win", 1000, 1, 0, 8 }; + { "win", 1000, 1, 0, 6 }; { "line", 1000, 1, 6 }; { "end", 5 }; } @@ -195,7 +195,7 @@ describe('decorations providers', function() check_trace { { "start", 5 }; - { "win", 1000, 1, 0, 5 }; + { "win", 1000, 1, 0, 3 }; { "line", 1000, 1, 0 }; { "line", 1000, 1, 1 }; { "line", 1000, 1, 2 }; -- cgit From b04286a187d57c50f01cd36cd4668b7a69026579 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 22 Nov 2020 10:10:37 +0100 Subject: feat(extmark): support proper multiline ranges The removes the previous restriction that nvim_buf_set_extmark() could not be used to highlight arbitrary multi-line regions The problem can be summarized as follows: let's assume an extmark with a hl_group is placed covering the region (5,0) to (50,0) Now, consider what happens if nvim needs to redraw a window covering the lines 20-30. It needs to be able to ask the marktree what extmarks cover this region, even if they don't begin or end here. Therefore the marktree needs to be augmented with the information covers a point, not just what marks begin or end there. To do this, we augment each node with a field "intersect" which is a set the ids of the marks which overlap this node, but only if it is not part of the set of any parent. This ensures the number of nodes that need to be explicitly marked grows only logarithmically with the total number of explicitly nodes (and thus the number of of overlapping marks). Thus we can quickly iterate all marks which overlaps any query position by looking up what leaf node contains that position. Then we only need to consider all "start" marks within that leaf node, and the "intersect" set of that node and all its parents. Now, and the major source of complexity is that the tree restructuring operations (to ensure that each node has T-1 <= size <= 2*T-1) also need to update these sets. If a full inner node is split in two, one of the new parents might start to completely overlap some ranges and its ids will need to be moved from its children's sets to its own set. Similarly, if two undersized nodes gets joined into one, it might no longer completely overlap some ranges, and now the children which do needs to have the have the ids in its set instead. And then there are the pivots! Yes the pivot operations when a child gets moved from one parent to another. --- test/functional/ui/decorations_spec.lua | 73 +++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 7 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index a75290b400..4262f7ce77 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -691,6 +691,7 @@ describe('extmark decorations', function() [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray}; [34] = {background = Screen.colors.Yellow}; [35] = {background = Screen.colors.Yellow, bold = true, foreground = Screen.colors.Blue}; + [36] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.Red}; } ns = meths.create_namespace 'test' @@ -1652,6 +1653,70 @@ describe('extmark decorations', function() {24:-- VISUAL BLOCK --} | ]]) end) + + it('supports multiline highlights', function() + insert(example_text) + feed 'gg' + for _,i in ipairs {1,2,3,5,6,7} do + for _,j in ipairs {2,5,10,15} do + meths.buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'}) + end + end + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + {1: }l{1:oc}al {1:te}xt,{1: h}l_id_cell, count = unpack(item) | + {1: }i{1:f }hl_{1:id}_ce{1:ll} ~= nil then | + {1: } {1: } hl{1:_i}d ={1: h}l_id_cell | + end | + {1: }f{1:or} _ {1:= }1, {1:(c}ount or 1) do | + {1: } {1: } lo{1:ca}l c{1:el}l = line[colpos] | + {1: } {1: } ce{1:ll}.te{1:xt} = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + {1:~ }| + | + ]]} + feed'5' + screen:expect{grid=[[ + ^ {1: }f{1:or} _ {1:= }1, {1:(c}ount or 1) do | + {1: } {1: } lo{1:ca}l c{1:el}l = line[colpos] | + {1: } {1: } ce{1:ll}.te{1:xt} = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + meths.buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'}) + screen:expect{grid=[[ + {4:^ }{36: }{4:f}{36:or}{4: _ }{36:= }{4:1, }{36:(c}{4:ount or 1) do} | + {4: }{36: }{4: }{36: }{4: lo}{36:ca}{4:l c}{36:el}{4:l = line[colpos]} | + {4: }{36: }{4: }{36: }{4: ce}{36:ll}{4:.te}{36:xt}{4: = text} | + {4: ce}ll.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: inline virtual text', function() @@ -4136,7 +4201,6 @@ l5 end) it('can add multiple signs (single extmark)', function() - pending('TODO(lewis6991): Support ranged signs') insert(example_test3) feed 'gg' @@ -4158,7 +4222,6 @@ l5 end) it('can add multiple signs (multiple extmarks)', function() - pending('TODO(lewis6991): Support ranged signs') insert(example_test3) feed'gg' @@ -4219,7 +4282,6 @@ l5 end) it('can add multiple signs (multiple extmarks) 3', function() - pending('TODO(lewis6991): Support ranged signs') insert(example_test3) feed 'gg' @@ -4289,7 +4351,6 @@ l5 end) it('works with old signs (with range)', function() - pending('TODO(lewis6991): Support ranged signs') insert(example_test3) feed 'gg' @@ -4304,7 +4365,7 @@ l5 screen:expect{grid=[[ S3S4S1^l1 | - S2S3x l2 | + x S2S3l2 | S5S3{1: }l3 | S3{1: }l4 | S3{1: }l5 | @@ -4317,8 +4378,6 @@ l5 end) it('can add a ranged sign (with start out of view)', function() - pending('TODO(lewis6991): Support ranged signs') - insert(example_test3) command 'set signcolumn=yes:2' feed 'gg' -- cgit From f5953edbac14febce9d4f8a3c35bdec1eae26fbe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 14 Sep 2023 07:42:22 +0800 Subject: fix(float): update position of anchored windows first (#25133) --- test/functional/ui/float_spec.lua | 193 +++++++++++++++++++++++++++++++++++++- test/functional/ui/screen.lua | 2 +- 2 files changed, 193 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6cdd6e51fa..4e2cee391a 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -3279,7 +3279,6 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) if multigrid then screen:expect{grid=[[ @@ -3725,6 +3724,198 @@ describe('float window', function() end end) + it('anchored to another floating window updated in the same call #14735', function() + feed('i') + + exec([[ + let b1 = nvim_create_buf(v:true, v:false) + let b2 = nvim_create_buf(v:true, v:false) + let b3 = nvim_create_buf(v:true, v:false) + let b4 = nvim_create_buf(v:true, v:false) + let b5 = nvim_create_buf(v:true, v:false) + let b6 = nvim_create_buf(v:true, v:false) + let b7 = nvim_create_buf(v:true, v:false) + let b8 = nvim_create_buf(v:true, v:false) + call setbufline(b1, 1, '1') + call setbufline(b2, 1, '2') + call setbufline(b3, 1, '3') + call setbufline(b4, 1, '4') + call setbufline(b5, 1, '5') + call setbufline(b6, 1, '6') + call setbufline(b7, 1, '7') + call setbufline(b8, 1, '8') + let o1 = #{relative: 'editor', row: 1, col: 10, width: 5, height: 1} + let w1 = nvim_open_win(b1, v:false, o1) + let o2 = extendnew(o1, #{col: 30}) + let w2 = nvim_open_win(b2, v:false, o2) + let o3 = extendnew(o1, #{relative: 'win', win: w1, anchor: 'NE', col: 0}) + let w3 = nvim_open_win(b3, v:false, o3) + let o4 = extendnew(o3, #{win: w2}) + let w4 = nvim_open_win(b4, v:false, o4) + let o5 = extendnew(o3, #{win: w3, anchor: 'SE', row: 0}) + let w5 = nvim_open_win(b5, v:false, o5) + let o6 = extendnew(o5, #{win: w4}) + let w6 = nvim_open_win(b6, v:false, o6) + let o7 = extendnew(o5, #{win: w5, anchor: 'SW', col: 5}) + let w7 = nvim_open_win(b7, v:false, o7) + let o8 = extendnew(o7, #{win: w6}) + let w8 = nvim_open_win(b8, v:false, o8) + ]]) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + | + | + ^ | + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:1 }| + ## grid 6 + {1:2 }| + ## grid 7 + {1:3 }| + ## grid 8 + {1:4 }| + ## grid 9 + {1:5 }| + ## grid 10 + {1:6 }| + ## grid 11 + {1:7 }| + ## grid 12 + {1:8 }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 1, 10, true, 50}; + [6] = {{id = 1003}, "NW", 1, 1, 30, true, 50}; + [7] = {{id = 1004}, "NE", 5, 1, 0, true, 50}; + [8] = {{id = 1005}, "NE", 6, 1, 0, true, 50}; + [9] = {{id = 1006}, "SE", 7, 0, 0, true, 50}; + [10] = {{id = 1007}, "SE", 8, 0, 0, true, 50}; + [11] = {{id = 1008}, "SW", 9, 0, 5, true, 50}; + [12] = {{id = 1009}, "SW", 10, 0, 5, true, 50}; + }} + else + screen:expect([[ + {1:7 } {1:8 } | + {1:5 } {1:1 } {1:6 } {1:2 } | + {1:3 } {1:4 } | + ^ | + {0:~ }| + {0:~ }| + | + ]]) + end + + -- Reconfigure in different directions + exec([[ + let o1 = extendnew(o1, #{anchor: 'NW'}) + call nvim_win_set_config(w8, o1) + let o2 = extendnew(o2, #{anchor: 'NW'}) + call nvim_win_set_config(w4, o2) + let o3 = extendnew(o3, #{win: w8}) + call nvim_win_set_config(w2, o3) + let o4 = extendnew(o4, #{win: w4}) + call nvim_win_set_config(w1, o4) + let o5 = extendnew(o5, #{win: w2}) + call nvim_win_set_config(w6, o5) + let o6 = extendnew(o6, #{win: w1}) + call nvim_win_set_config(w3, o6) + let o7 = extendnew(o7, #{win: w6}) + call nvim_win_set_config(w5, o7) + let o8 = extendnew(o8, #{win: w3}) + call nvim_win_set_config(w7, o8) + ]]) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + | + | + ^ | + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:1 }| + ## grid 6 + {1:2 }| + ## grid 7 + {1:3 }| + ## grid 8 + {1:4 }| + ## grid 9 + {1:5 }| + ## grid 10 + {1:6 }| + ## grid 11 + {1:7 }| + ## grid 12 + {1:8 }| + ]], float_pos={ + [5] = {{id = 1002}, "NE", 8, 1, 0, true, 50}; + [6] = {{id = 1003}, "NE", 12, 1, 0, true, 50}; + [7] = {{id = 1004}, "SE", 5, 0, 0, true, 50}; + [8] = {{id = 1005}, "NW", 1, 1, 30, true, 50}; + [9] = {{id = 1006}, "SW", 10, 0, 5, true, 50}; + [10] = {{id = 1007}, "SE", 6, 0, 0, true, 50}; + [11] = {{id = 1008}, "SW", 7, 0, 5, true, 50}; + [12] = {{id = 1009}, "NW", 1, 1, 10, true, 50}; + }} + else + screen:expect([[ + {1:5 } {1:7 } | + {1:6 } {1:8 } {1:3 } {1:4 } | + {1:2 } {1:1 } | + ^ | + {0:~ }| + {0:~ }| + | + ]]) + end + + -- Not clear how cycles should behave, but they should not hang or crash + exec([[ + let o1 = extendnew(o1, #{relative: 'win', win: w7}) + call nvim_win_set_config(w1, o1) + let o2 = extendnew(o2, #{relative: 'win', win: w8}) + call nvim_win_set_config(w2, o2) + let o3 = extendnew(o3, #{win: w1}) + call nvim_win_set_config(w3, o3) + let o4 = extendnew(o4, #{win: w2}) + call nvim_win_set_config(w4, o4) + let o5 = extendnew(o5, #{win: w3}) + call nvim_win_set_config(w5, o5) + let o6 = extendnew(o6, #{win: w4}) + call nvim_win_set_config(w6, o6) + let o7 = extendnew(o7, #{win: w5}) + call nvim_win_set_config(w7, o7) + let o8 = extendnew(o8, #{win: w6}) + call nvim_win_set_config(w8, o8) + redraw + ]]) + end) + it('can be placed relative text in a window', function() screen:try_resize(30,5) local firstwin = meths.get_current_win().id diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 2307fd106b..be7c2f291c 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1270,7 +1270,7 @@ end function Screen:render(headers, attr_state, preview) headers = headers and (self._options.ext_multigrid or self._options._debug_float) local rv = {} - for igrid,grid in pairs(self._grids) do + for igrid,grid in vim.spairs(self._grids) do if headers then local suffix = "" if igrid > 1 and self.win_position[igrid] == nil -- cgit From b52bd8a2dea829f23721c15ee9ce51ccf766df43 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Sep 2023 12:35:27 +0800 Subject: fix(extmarks): properly handle virt_text on next screen line (#25166) TODO: virt_text_hide doesn't work for the first char on a wrapped screen line, and it's not clear how to fix that. --- test/functional/ui/decorations_spec.lua | 103 ++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 33 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 4262f7ce77..8a94eaef1b 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -859,6 +859,43 @@ describe('extmark decorations', function() ]]} end) + it('overlay virtual text works with wrapped lines #25158', function() + screen:try_resize(50, 6) + insert(('ab'):rep(100)) + for i = 0, 9 do + meths.buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) + meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide = true}) + end + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {4:89}abababababababababababababababababababa{4:012345678}| + {4:9}babababababababababababababababababababababababab| + ababababababababababababababababababababababababa^b| + {1:~ }| + | + ]]} + + command('set number') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:0123}| + {2: }{4:456789}abababababababababababababababababababa{4:0}| + {2: }{4:123456789}babababababababababababababababababab| + {2: }ababababababababababababababababababababababab| + {2: }abababababababa^b | + | + ]]} + + command('set cpoptions+=n') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:0123}| + {4:456789}abababababababababababababababababababa{4:01234}| + {4:56789}babababababababababababababababababababababab| + ababababababababababababababababababababababababab| + aba^b | + | + ]]} + end) + it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() screen:try_resize(50, 3) command('set nowrap') @@ -1028,12 +1065,12 @@ describe('extmark decorations', function() it('can have virtual text of right_align and fixed win_col position', function() insert(example_text) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 15, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) -- empty virt_text should not change anything @@ -1191,40 +1228,40 @@ describe('extmark decorations', function() | ]]} - command 'set cpoptions-=n nonumber nowrap' + command 'set cpoptions-=n nowrap' screen:expect{grid=[[ - for _,item in ipairs(items) do | - local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| - if | - hl_id_cell ~= nil then {4:Much} {4:MUCH}| - --^ -- -- -- -- -- -- --{4:Error}- -- -- h{4:ERROR}| - end | - for _ = 1, (count or 1) do | - local cell = line[colpos] | - {1:-} cell.text = text {1:-}| - cell.hl_id = hl_id | - colpos = colpos+1 | - end | - end | + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 } --^ -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + {2: 13 }end | {1:~ }| | ]]} - feed '8zl' + feed '12zl' screen:expect{grid=[[ - em in ipairs(items) do | - l text, hl_id_cell, count = unp{4:Very}item) {4:VERY}| - | - ll ~= nil then {4:Much} {4:MUCH}| - --^ -- -- -- -- -- -- -- -- -- -{4:Error}hl_id = h{4:ERROR}| - | - _ = 1, (count or 1) do | - local cell = line[colpos] | - cell{1:-}text = text {1:-}| - cell.hl_id = hl_id | - colpos = colpos+1 | - | - | + {2: 1 }n ipairs(items) do | + {2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| + {2: 3 } | + {2: 4 }= nil then {4:Much} {4:MUCH}| + {2: 5 }^- -- -- -- -- -- -- -- -- -- --{4:Error}d = h{4:ERROR}| + {2: 6 } | + {2: 7 }1, (count or 1) do | + {2: 8 }l cell = line[colpos] | + {2: 9 }.tex{1:-} = text {1:-}| + {2: 10 }.hl_id = hl_id | + {2: 11 }os = colpos+1 | + {2: 12 } | + {2: 13 } | {1:~ }| | ]]} @@ -1243,7 +1280,7 @@ describe('extmark decorations', function() -- 1. With 'wrap' it is never shown. -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) + meths.buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| -- cgit From b65cd7ff1a0ab037daffd95d5c537898a32ea038 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Sep 2023 14:54:42 +0800 Subject: fix(extmarks): fix wrong virt_text position after wrapped TAB (#25168) --- test/functional/ui/decorations_spec.lua | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 8a94eaef1b..5f9ac2265c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -894,6 +894,16 @@ describe('extmark decorations', function() aba^b | | ]]} + + feed('0g$hi') + screen:expect{grid=[[ + {2: 1 }ababababababababababababababababababababab{4:01} | + {4:^23456789}abababababababababababababababababababa{4:0}| + {4:123456789}babababababababababababababababababababab| + ababababababababababababababababababababababababab| + abababab | + {24:-- INSERT --} | + ]]} end) it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() @@ -1265,6 +1275,44 @@ describe('extmark decorations', function() {1:~ }| | ]]} + + feed('fhi') + screen:expect{grid=[[ + {2: 1 }n ipairs(items) do | + {2: 2 }xt, hl_id_cell, count = unpack({4:Very}) {4:VERY}| + {2: 3 } | + {2: 4 }= nil then {4:Much} {4:MUCH}| + {2: 5 }- -- -- -- -- -- -- -- -- -- --{4:Error}^hl_id{4:ERROR}| + {2: 6 } | + {2: 7 }1, (count or 1) do | + {2: 8 }l cell = line[colpos] | + {2: 9 }.tex{1:-} = text {1:-}| + {2: 10 }.hl_id = hl_id | + {2: 11 }os = colpos+1 | + {2: 12 } | + {2: 13 } | + {1:~ }| + {24:-- INSERT --} | + ]]} + + feed('0') + screen:expect{grid=[[ + {2: 1 }for _,item in ipairs(items) do | + {2: 2 } local text, hl_id_cell, cou{4:Very} unpack{4:VERY}| + {2: 3 } if | + {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| + {2: 5 }^ -- -- -- -- -- -- -- --{4:Error}- -- {4:ERROR}| + {2: 6 } end | + {2: 7 } for _ = 1, (count or 1) do | + {2: 8 } local cell = line[colpos] | + {2: 9 } {1:-} cell.text = text {1:-}| + {2: 10 } cell.hl_id = hl_id | + {2: 11 } colpos = colpos+1 | + {2: 12 } end | + {2: 13 }end | + {1:~ }| + | + ]]} end) it('can have virtual text on folded line', function() @@ -1273,7 +1321,6 @@ describe('extmark decorations', function() 22222 33333]]) command('1,2fold') - command('set nowrap') screen:try_resize(50, 3) feed('zb') -- XXX: the behavior of overlay virtual text at non-zero column is strange: @@ -1287,6 +1334,8 @@ describe('extmark decorations', function() 3333^3 | | ]]} + command('set nowrap') + screen:expect_unchanged() feed('zl') screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| -- cgit From a6e4793bafa0edda2ef5e948cd071dc9626688d8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Sep 2023 15:56:52 +0800 Subject: fix(extmarks): draw virt_text below diff filler lines properly (#25170) fix(extmarks): draw virt_text properly below diff filler lines --- test/functional/ui/decorations_spec.lua | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 5f9ac2265c..85093566a5 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -692,6 +692,11 @@ describe('extmark decorations', function() [34] = {background = Screen.colors.Yellow}; [35] = {background = Screen.colors.Yellow, bold = true, foreground = Screen.colors.Blue}; [36] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.Red}; + [37] = {background = Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}; + [38] = {background = Screen.colors.LightBlue}; + [39] = {foreground = Screen.colors.Blue1, background = Screen.colors.LightCyan1, bold = true}; + [40] = {reverse = true}; + [41] = {bold = true, reverse = true}; } ns = meths.create_namespace 'test' @@ -1356,6 +1361,38 @@ describe('extmark decorations', function() ]]} end) + it('virtual text works below diff filler lines', function() + screen:try_resize(53, 8) + insert([[ + aaaaa + bbbbb + ccccc + ddddd + eeeee]]) + command('rightbelow vnew') + insert([[ + bbbbb + ccccc + ddddd + eeeee]]) + command('windo diffthis') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) + screen:expect{grid=[[ + {37: }{38:aaaaa }│{37: }{39:------------------------}| + {37: }bbbbb │{37: }{28:AA}bbb {28:BB} {28:CC}| + {37: }ccccc │{37: }ccccc | + {37: }ddddd │{37: }ddddd | + {37: }eeeee │{37: }eeee^e | + {1:~ }│{1:~ }| + {40:[No Name] [+] }{41:[No Name] [+] }| + | + ]]} + command('windo set wrap') + screen:expect_unchanged() + end) + it('can have virtual text which combines foreground and background groups', function() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; -- cgit From a916523574135549865d698732a6c9eaae7c7811 Mon Sep 17 00:00:00 2001 From: glepnir Date: Sun, 10 Sep 2023 15:09:20 +0800 Subject: fix(ui): doesn't trigger au event when enter is false --- test/functional/ui/float_spec.lua | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6cdd6e51fa..0cf8a124ff 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -415,6 +415,46 @@ describe('float window', function() eq(winids, eval('winids')) end) + it("open does not trigger BufEnter #15300", function() + local res = exec_lua[[ + local times = {} + local buf = vim.api.nvim_create_buf(fasle, true) + vim.api.nvim_create_autocmd('BufEnter', { + callback = function(opt) + if opt.buf == buf then + times[#times + 1] = 1 + end + end + }) + local win_id + local fconfig = { + relative = 'editor', + row = 10, + col = 10, + width = 10, + height = 10, + } + --enter is false doesn't trigger + win_id = vim.api.nvim_open_win(buf, false, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 0 and true or nil + + --enter is true trigger + win_id = vim.api.nvim_open_win(buf, true, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 2 and true or nil + + --enter is true and fconfig.noautocmd is true doesn't trigger + fconfig.noautocmd = true + win_id = vim.api.nvim_open_win(buf, true, fconfig) + vim.api.nvim_win_close(win_id, true) + times[#times + 1] = #times == 2 and true or nil + + return times + ]] + eq({true, 1, true}, res) + end) + it('no crash with bufpos and non-existent window', function() command('new') local closed_win = meths.get_current_win().id -- cgit From 35e50d79c630b05f67a840ebe21b4043ba9a6066 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 15 Sep 2023 20:30:50 +0800 Subject: fix(extmarks): overlay virt_text position after 'showbreak' (#25175) Also make virt_text_hide work properly. --- test/functional/ui/decorations_spec.lua | 55 +++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 85093566a5..daa4b4bdb3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -869,7 +869,7 @@ describe('extmark decorations', function() insert(('ab'):rep(100)) for i = 0, 9 do meths.buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide = true}) + meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) end screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| @@ -880,7 +880,58 @@ describe('extmark decorations', function() | ]]} - command('set number') + command('set showbreak=++') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}{4:789}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababa^b | + | + ]]} + + feed('2gkvg0') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}^a{18:babab}ababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('o') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}abababababababababababababababababababa{4:0123456}| + {1:++}{18:ababa}^bababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('gk') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}aba^b{18:ababababababababababababababababababababab}| + {1:++}{18:a}{4:89}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('o') + screen:expect{grid=[[ + ababababababababababababababababababababab{4:01234567}| + {1:++}{4:89}aba{18:bababababababababababababababababababababab}| + {1:++}^a{4:89}babababababababababababababababababababababab| + {1:++}abababababababababababababababababababababababab| + {1:++}ababab | + {24:-- VISUAL --} | + ]]} + + feed('$') + command('set number showbreak=') screen:expect{grid=[[ {2: 1 }ababababababababababababababababababababab{4:0123}| {2: }{4:456789}abababababababababababababababababababa{4:0}| -- cgit From 71530cc972576e6656431b6d000aec9b69a0997e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Sep 2023 20:29:18 +0800 Subject: feat(folds): support virtual text format for 'foldtext' (#25209) Co-authored-by: Lewis Russell --- test/functional/ui/fold_spec.lua | 121 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index f00fba331e..46de6b114e 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -40,12 +40,16 @@ describe("folded lines", function() [8] = {foreground = Screen.colors.Brown }, [9] = {bold = true, foreground = Screen.colors.Brown}, [10] = {background = Screen.colors.LightGrey, underline = true}, - [11] = {bold=true}, + [11] = {bold = true}, [12] = {foreground = Screen.colors.Red}, [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, [14] = {background = Screen.colors.Red}, [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red}, [16] = {background = Screen.colors.LightGrey}, + [17] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red}, + [18] = {background = Screen.colors.LightGrey, bold = true, foreground = Screen.colors.Blue}, + [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.DarkBlue}, + [20] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue}, }) end) @@ -2816,6 +2820,121 @@ describe("folded lines", function() ]]) end end) + + it('support foldtext with virtual text format', function() + screen:try_resize(30, 7) + insert(content1) + command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") + meths.set_option_value('cursorline', true, {}) + meths.set_option_value('foldcolumn', '4', {}) + meths.set_option_value('foldtext', + '[[v:folddashes], ["\t", "Search"], [getline(v:foldstart), "NonText"]]', {}) + + command('3,4fold') + command('5,6fold') + command('2,6fold') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:+ }{13:^-}{17: }{18:valid English}{13:·····}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]} + else + screen:expect([[ + {7: }This is a | + {7:+ }{13:^-}{17: }{18:valid English}{13:·····}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end + eq('-\tvalid English', funcs.foldtextresult(2)) + + feed('zo') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:- }valid English | + {7:│+ }{5:--}{19: }{18:sentence composed }| + {7:│+ }{13:^--}{17: }{18:in his cave.}{13:······}| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]} + else + screen:expect([[ + {7: }This is a | + {7:- }valid English | + {7:│+ }{5:--}{19: }{18:sentence composed }| + {7:│+ }{13:^--}{17: }{18:in his cave.}{13:······}| + {1:~ }| + {1:~ }| + | + ]]) + end + eq('--\tsentence composed by', funcs.foldtextresult(3)) + eq('--\tin his cave.', funcs.foldtextresult(5)) + + command('hi! Visual guibg=Red') + feed('V2k') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:- }^v{14:alid English} | + {7:│+ }{15:--}{19: }{20:sentence composed }| + {7:│+ }{15:--}{19: }{20:in his cave.}{15:······}| + {1:~ }| + {1:~ }| + ## grid 3 + {11:-- VISUAL LINE --} | + ]]} + else + screen:expect([[ + {7: }This is a | + {7:- }^v{14:alid English} | + {7:│+ }{15:--}{19: }{20:sentence composed }| + {7:│+ }{15:--}{19: }{20:in his cave.}{15:······}| + {1:~ }| + {1:~ }| + {11:-- VISUAL LINE --} | + ]]) + end + end) end describe("with ext_multigrid", function() -- cgit From f54677132b9052640ec0ecb79001a69a6d032565 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 17 Sep 2023 21:31:51 +0800 Subject: test(ui/fold_spec): click on multibyte "foldclosed" (#25216) --- test/functional/ui/fold_spec.lua | 51 +++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 46de6b114e..a371b45e2b 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -423,6 +423,45 @@ describe("folded lines", function() :set norightleft | ]]) end + + -- Add a winbar to avoid double-clicks + command('setlocal winbar=!!!!!!') + if multigrid then + meths.input_mouse('left', 'press', '', 2, 1, 1) + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {11:!!!!!! }| + {7:▾▾}^aa | + {7:││}bb | + {7:││}cc | + {7:││}dd | + {7:││}ee | + {7:│ }ff | + ## grid 3 + :set norightleft | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 1, 1) + screen:expect([[ + {11:!!!!!! }| + {7:▾▾}^aa | + {7:││}bb | + {7:││}cc | + {7:││}dd | + {7:││}ee | + {7:│ }ff | + :set norightleft | + ]]) + end end) it("works with split", function() @@ -2834,7 +2873,7 @@ describe("folded lines", function() command('5,6fold') command('2,6fold') if multigrid then - screen:expect{grid=[[ + screen:expect([[ ## grid 1 [2:------------------------------]| [2:------------------------------]| @@ -2852,7 +2891,7 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]} + ]]) else screen:expect([[ {7: }This is a | @@ -2868,7 +2907,7 @@ describe("folded lines", function() feed('zo') if multigrid then - screen:expect{grid=[[ + screen:expect([[ ## grid 1 [2:------------------------------]| [2:------------------------------]| @@ -2886,7 +2925,7 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]]} + ]]) else screen:expect([[ {7: }This is a | @@ -2904,7 +2943,7 @@ describe("folded lines", function() command('hi! Visual guibg=Red') feed('V2k') if multigrid then - screen:expect{grid=[[ + screen:expect([[ ## grid 1 [2:------------------------------]| [2:------------------------------]| @@ -2922,7 +2961,7 @@ describe("folded lines", function() {1:~ }| ## grid 3 {11:-- VISUAL LINE --} | - ]]} + ]]) else screen:expect([[ {7: }This is a | -- cgit From 508dda0e6c327a1430fbb0d9a382fe6a848c933e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 18 Sep 2023 07:07:54 +0800 Subject: test(ui/fold_spec): more testing for clicking on 'foldcolumn' (#25225) --- test/functional/ui/fold_spec.lua | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index a371b45e2b..c8ca5be282 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -424,8 +424,82 @@ describe("folded lines", function() ]]) end + if multigrid then + meths.input_mouse('left', 'press', '', 2, 0, 0) + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {7:▸ }{5:^+-- 6 lines: aa···························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :set norightleft | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 0, 0) + screen:expect([[ + {7:▸ }{5:^+-- 6 lines: aa···························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :set norightleft | + ]]) + end + -- Add a winbar to avoid double-clicks command('setlocal winbar=!!!!!!') + if multigrid then + meths.input_mouse('left', 'press', '', 2, 1, 0) + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {11:!!!!!! }| + {7:▾▸}{5:^+--- 5 lines: aa··························}| + {7:│ }ff | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :set norightleft | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 1, 0) + screen:expect([[ + {11:!!!!!! }| + {7:▾▸}{5:^+--- 5 lines: aa··························}| + {7:│ }ff | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :set norightleft | + ]]) + end + if multigrid then meths.input_mouse('left', 'press', '', 2, 1, 1) screen:expect([[ -- cgit From fd08fd3de3020647c8ae73f1c7d2cf9a4926c828 Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 14 Sep 2023 13:30:51 +0800 Subject: fix(float): add fixd option --- test/functional/ui/float_spec.lua | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 4e2cee391a..4ede03f242 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -899,6 +899,89 @@ describe('float window', function() end end) + it('window position fixed', function() + local buf = meths.create_buf(false,false) + command("set nowrap") + local win = meths.open_win(buf, false, { + relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = true}) + local expected_pos = { + [4]={{id=1001}, 'NW', 1, 2, 30, true}, + } + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {1: }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }{1: }| + {0:~ }{2:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_set_config(win, { + relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = false}) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {1: }| + {2:~ }| + ]], float_pos=expected_pos} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }{1: }| + {0:~ }{2:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) + it('draws correctly with redrawdebug=compositor', function() -- NB: we do not test that it produces the "correct" debug info -- (as it is intermediate only, and is allowed to change by internal -- cgit From 8da986ea877b07a5eb117446f410f2a7fc8cd9cb Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 13 Sep 2023 13:39:18 +0200 Subject: refactor(grid): change schar_T representation to be more compact Previously, a screen cell would occupy 28+4=32 bytes per cell as we always made space for up to MAX_MCO+1 codepoints in a cell. As an example, even a pretty modest 50*80 screen would consume 50*80*2*32 = 256000, i e a quarter megabyte With the factor of two due to the TUI side buffer, and even more when using msg_grid and/or ext_multigrid. This instead stores a 4-byte union of either: - a valid UTF-8 sequence up to 4 bytes - an escape char which is invalid UTF-8 (0xFF) plus a 24-bit index to a glyph cache This avoids allocating space for huge composed glyphs _upfront_, while still keeping rendering such glyphs reasonably fast (1 hash table lookup + one plain index lookup). If the same large glyphs are using repeatedly on the screen, this is still a net reduction of memory/cache consumption. The only case which really gets worse is if you blast the screen full with crazy emojis and zalgo text and even this case only leads to 4 extra bytes per char. When only <= 4-byte glyphs are used, plus the 4-byte attribute code, i e 8 bytes in total there is a factor of four reduction of memory use. Memory which will be quite hot in cache as the screen buffer is scanned over in win_line() buffer text drawing A slight complication is that the representation depends on host byte order. I've tested this manually by compling and running this in qemu-s390x and it works fine. We might add a qemu based solution to CI at some point. --- test/functional/ui/multibyte_spec.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index 5cecd423d7..417c7b797c 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -160,6 +160,22 @@ describe("multibyte rendering", function() {1:~ }| | ]]} + + -- nvim will reset the zalgo text^W^W glyph cache if it gets too full. + -- this should be exceedingly rare, but fake it to make sure it works + meths._invalidate_glyph_cache() + screen:expect{grid=[[ + ^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ | + ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ | + U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ | + u̗̞̓̔̈̏ĺ̟̝́̎̚l̛̜̅̌̎̆a̒̑̆̔̇̃m̜̗̈̊̎̚ċ̘̋̇̂̚ơ̟̖̊́̕ ̖̟̍̉̏̚l̙̔̓̀̅̏ä̞̗̘̙̅ḃ̟̎̄̃̕o̞̎̓̓̓̚r̗̜̊̓̈̒ï̗̜̃̃̅s̀̒̌̂̎̂ ̖̗̗̋̎̐n̝̟̝̘̄̚i̜̒̀̒̐̕s̘̘̄̊̃̀ī̘̜̏̌̕ ̗̖̞̐̈̒ư̙̞̄́̌t̟̘̖̙̊̚ ̌̅̋̆̚̚ä̇̊̇̕̕l̝̞̘̋̔̅i̍̋́̆̑̈q̛̆̐̈̐̚ư̏̆̊́̚î̜̝̑́̊p̗̓̅̑̆̏ ̆́̓̔̋̋e̟̊̋̏̓̚x̗̍̑̊̎̈ ̟̞̆̄̂̍ë̄̎̄̃̅a̛̜̅́̃̈ ̔̋̀̎̐̀c̖̖̍̀̒̂ơ̛̙̖̄̒m̘̔̍̏̆̕ḿ̖̙̝̏̂ȍ̓̋̈̀̕d̆̂̊̅̓̚o̖̔̌̑̚̕ ̙̆́̔̊̒c̖̘̖̀̄̍o̓̄̑̐̓̒ñ̞̒̎̈̚s̞̜̘̈̄̄e̙̊̀̇̌̋q̐̒̓́̔̃ư̗̟̔̔̚å̖̙̞̄̏t̛̙̟̒̇̏.̙̗̓̃̓̎ | + D̜̖̆̏̌̌ư̑̃̌̍̕i̝̊̊̊̊̄s̛̙̒́̌̇ ̛̃̔̄̆̌ă̘̔̅̅̀ú̟̟̟̃̃t̟̂̄̈̈̃e̘̅̌̒̂̆ ̖̟̐̉̉̌î̟̟̙̜̇r̛̙̞̗̄̌ú̗̗̃̌̎r̛̙̘̉̊̕e̒̐̔̃̓̋ ̊̊̍̋̑̉d̛̝̙̉̀̓o̘̜̐̐̓̐l̞̋̌̆̍́o̊̊̐̃̃̚ṙ̛̖̘̃̕ ̞̊̀̍̒̕ȉ́̑̐̇̅ǹ̜̗̜̞̏ ̛̜̐̄̄̚r̜̖̈̇̅̋ĕ̗̉̃̔̚p̟̝̀̓̔̆r̜̈̆̇̃̃e̘̔̔̏̎̓h̗̒̉̑̆̚ė̛̘̘̈̐n̘̂̀̒̕̕d̗̅̂̋̅́ê̗̜̜̜̕r̟̋̄̐̅̂i̛̔̌̒̂̕t̛̗̓̎̀̎ ̙̗̀̉̂̚ȉ̟̗̐̓̚n̙̂̍̏̓̉ ̙̘̊̋̍̕v̜̖̀̎̆̐ő̜̆̉̃̎l̑̋̒̉̔̆ư̙̓̓́̚p̝̘̖̎̏̒t̛̘̝̞̂̓ȁ̘̆̔́̊t̖̝̉̒̐̎e̞̟̋̀̅̄ ̆̌̃̀̑̔v̝̘̝̍̀̇ȅ̝̊̄̓̕l̞̝̑̔̂̋ĭ̝̄̅̆̍t̝̜̉̂̈̇ | + ē̟̊̇̕̚s̖̘̘̒̄̑s̛̘̀̊̆̇e̛̝̘̒̏̚ ̉̅̑̂̐̎c̛̟̙̎̋̓i̜̇̒̏̆̆l̟̄́̆̊̌l̍̊̋̃̆̌ủ̗̙̒̔̚m̛̘̘̖̅̍ ̖̙̈̎̂̕d̞̟̏̋̈̔ơ̟̝̌̃̄l̗̙̝̂̉̒õ̒̃̄̄̚ŕ̗̏̏̊̍ê̞̝̞̋̈ ̜̔̒̎̃̚e̞̟̞̒̃̄ư̖̏̄̑̃ ̛̗̜̄̓̎f̛̖̞̅̓̃ü̞̏̆̋̕g̜̝̞̑̑̆i̛̘̐̐̅̚à̜̖̌̆̎t̙̙̎̉̂̍ ̋̔̈̎̎̉n̞̓́̔̊̕ư̘̅̋̔̚l̗̍̒̄̀̚l̞̗̘̙̓̍â̘̔̒̎̚ ̖̓̋̉̃̆p̛̛̘̋̌̀ä̙̔́̒̕r̟̟̖̋̐̋ì̗̙̎̓̓ȃ̔̋̑̚̕t̄́̎̓̂̋ư̏̈̂̑̃r̖̓̋̊̚̚.̒̆̑̆̊̎ ̘̜̍̐̂̚E̞̅̐̇́̂x̄́̈̌̉̕ć̘̃̉̃̕è̘̂̑̏̑p̝̘̑̂̌̆t̔̐̅̍̌̂ȇ̞̈̐̚̕ű̝̞̜́̚ŕ̗̝̉̆́ | + š̟́̔̏̀ȉ̝̟̝̏̅n̑̆̇̒̆̚t̝̒́̅̋̏ ̗̑̌̋̇̚ơ̙̗̟̆̅c̙̞̙̎̊̎c̘̟̍̔̊̊a̛̒̓̉́̐e̜̘̙̒̅̇ć̝̝̂̇̕ả̓̍̎̂̚t̗̗̗̟̒̃ ̘̒̓̐̇́c̟̞̉̐̓̄ȕ̙̗̅́̏p̛̍̋̈́̅i̖̓̒̍̈̄d̞̃̈̌̆̐a̛̗̝̎̋̉t̞̙̀̊̆̇a̛̙̒̆̉̚t̜̟̘̉̓̚ ̝̘̗̐̇̕n̛̘̑̏̂́ō̑̋̉̏́ň̞̊̆̄̃ ̙̙̙̜̄̏p̒̆̋̋̓̏r̖̖̅̉́̚ơ̜̆̑̈̚i̟̒̀̃̂̌d̛̏̃̍̋̚ë̖̞̙̗̓n̛̘̓̒̅̎t̟̗̙̊̆̚,̘̙̔̊̚̕ ̟̗̘̜̑̔s̜̝̍̀̓̌û̞̙̅̇́n̘̗̝̒̃̎t̗̅̀̅̊̈ ̗̖̅̅̀̄i̛̖̍̅̋̂n̙̝̓̓̎̚ ̞̋̅̋̃̚c̗̒̀̆̌̎ū̞̂̑̌̓ĺ̛̐̍̑́p̝̆̌̎̈̚a̖̙̒̅̈̌ ̝̝̜̂̈̀q̝̖̔̍̒̚ư̔̐̂̎̊ǐ̛̟̖̘̕ | + o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚ | + {1:~ }| + | + ]], reset=true} end) end) -- cgit From ab92575753874f9dee73e722b6fddd8dd49e2f13 Mon Sep 17 00:00:00 2001 From: glepnir Date: Thu, 14 Sep 2023 21:02:30 +0800 Subject: fix(highlight): winhl receive wrong argument --- test/functional/ui/highlight_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index c68f4cf34c..931e1f9985 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -8,6 +8,7 @@ local feed_command, eq = helpers.feed_command, helpers.eq local curbufmeths = helpers.curbufmeths local funcs = helpers.funcs local meths = helpers.meths +local exec_lua = helpers.exec_lua describe('colorscheme compatibility', function() before_each(function() @@ -2641,4 +2642,17 @@ describe('highlight namespaces', function() | ]]} end) + + it('winhl does not accept invalid value #24586', function() + local res = exec_lua([[ + local curwin = vim.api.nvim_get_current_win() + vim.api.nvim_command("set winhl=Normal:Visual") + local _, msg = pcall(vim.api.nvim_command,"set winhl='Normal:Wrong'") + return { msg, vim.wo[curwin].winhl } + ]]) + eq({ + "Vim(set):E5248: Invalid character in group name", + "Normal:Visual", + },res) + end) end) -- cgit From 437ed3cee2d29a24d555a873d024cd851b953153 Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 11 Sep 2023 19:46:15 +0800 Subject: fix(float): trigger winnew event when float window create --- test/functional/ui/float_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index e37b3ccb5f..556859478e 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -103,6 +103,29 @@ describe('float window', function() assert_alive() end) + it('open with WinNew autocmd', function() + local res = exec_lua([[ + local triggerd = false + local buf = vim.api.nvim_create_buf(true, true) + vim.api.nvim_create_autocmd('WinNew', { + callback = function(opt) + if opt.buf == buf then + triggerd = true + end + end + }) + local opts = { + relative = "win", + row = 0, col = 0, + width = 1, height = 1, + noautocmd = false, + } + vim.api.nvim_open_win(buf, true, opts) + return triggerd + ]]) + eq(true, res) + end) + it('opened with correct height', function() local height = exec_lua([[ vim.go.winheight = 20 -- cgit From c5abf487f19e45fe96a001b28b9e7981f43eed7d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Sep 2023 18:45:11 +0800 Subject: fix(float): make "fixed" work with relative=win (#25243) --- test/functional/ui/float_spec.lua | 98 ++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 58 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index fcda0dad74..e1d5f6b965 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -940,85 +940,67 @@ describe('float window', function() end) it('window position fixed', function() + command('rightbelow 20vsplit') local buf = meths.create_buf(false,false) - command("set nowrap") local win = meths.open_win(buf, false, { - relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = true}) - local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 30, true}, - } + relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]| + {5:[No Name] }{4:[No Name] }| [3:----------------------------------------]| ## grid 2 - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| ## grid 3 | ## grid 4 - {1: }| - {2:~ }| - ]], float_pos=expected_pos} + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 5 + {1: }| + {2:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 4, 2, 10, true, 50}; + }} else screen:expect([[ - ^ | - {0:~ }| - {0:~ }{1: }| - {0:~ }{2:~ }| - {0:~ }| - {0:~ }| + {5:│}^ | + {0:~ }{5:│}{0:~ }| + {0:~ }{5:│}{0:~ }{1: }| + {0:~ }{5:│}{0:~ }{2:~ }| + {0:~ }{5:│}{0:~ }| + {5:[No Name] }{4:[No Name] }| | - ]]) + ]]) end - meths.win_set_config(win, { - relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = false}) + meths.win_set_config(win, {fixed=false}) if multigrid then - screen:expect{grid=[[ - ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [3:----------------------------------------]| - ## grid 2 - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - ## grid 3 - | - ## grid 4 - {1: }| - {2:~ }| - ]], float_pos=expected_pos} + screen:expect_unchanged() else screen:expect([[ - ^ | - {0:~ }| - {0:~ }{1: }| - {0:~ }{2:~ }| - {0:~ }| - {0:~ }| + {5:│}^ | + {0:~ }{5:│}{0:~ }| + {0:~ }{5:│}{0:~ }{1: }| + {0:~ }{5:│}{0:~ }{2:~ }| + {0:~ }{5:│}{0:~ }| + {5:[No Name] }{4:[No Name] }| | - ]]) + ]]) end end) -- cgit From 818d7f6daf306c6ad7bed0d2ee5c8b9c89f625f4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Sep 2023 21:48:12 +0800 Subject: fix(extmarks): fix win_col virt_text drawn on wrong screen line (#25264) --- test/functional/ui/decorations_spec.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index daa4b4bdb3..f2abd02d21 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1237,6 +1237,25 @@ describe('extmark decorations', function() | ]]} + meths.buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} }) + screen:expect{grid=[[ + for _,item in ipairs(items) do | + local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| + if | + hl_id_cell ~= nil then {4:Much} {4:MUCH}| + --^ -- -- -- -- -- -- --{4:Error}- -- hl_i{4:ERROR}| + l_id_cell {1:EOL} | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + {1:-} cell.text = text {1:-}| + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + end | + | + ]]} + feed '.' screen:expect{grid=[[ for _,item in ipairs(items) do | @@ -1244,7 +1263,7 @@ describe('extmark decorations', function() if | hl_id_cell ~= nil then {4:Much} {4:MUCH}| --^ -- -- -- -- -- -- -- -- -- -- -- hl_id | - = hl_id_cell {4:Error} {4:ERROR}| + = hl_id_cell {1:EOL} {4:Error} {4:ERROR}| end | for _ = 1, (count or 1) do | local cell = line[colpos] | @@ -1264,7 +1283,7 @@ describe('extmark decorations', function() {2: 3 } if | {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| - {2: }_id = hl_id_cell {4:Error} {4:ERROR}| + {2: }_id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}| {2: 6 } end | {2: 7 } for _ = 1, (count or 1) do | {2: 8 } local cell = line[colpos] | @@ -1283,7 +1302,7 @@ describe('extmark decorations', function() {2: 3 } if | {2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}| {2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl| - _id = hl_id_cell {4:Error} {4:ERROR}| + _id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}| {2: 6 } end | {2: 7 } for _ = 1, (count or 1) do | {2: 8 } local cell = line[colpos] | -- cgit From 23c21e763074d401e8b36a91e6568bebc1655ce9 Mon Sep 17 00:00:00 2001 From: Ibby <33922797+SleepySwords@users.noreply.github.com> Date: Thu, 21 Sep 2023 00:39:54 +1000 Subject: fix(extmarks): account for rightleft when drawing virt text (#25262) Co-authored-by: zeertzjq --- test/functional/ui/decorations_spec.lua | 105 ++++++++++++++++++++++++++++++-- test/functional/ui/fold_spec.lua | 33 ++++++++++ 2 files changed, 134 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f2abd02d21..d6a6243be2 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1910,6 +1910,84 @@ describe('extmark decorations', function() | ]]} end) + + it('virtual text works with rightleft', function() + screen:try_resize(50, 3) + insert('abcdefghijklmn') + feed('0') + command('set rightleft') + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}}) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 }) + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + screen:expect{grid=[[ + {28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}b^a| + {1: ~}| + | + ]]} + + insert(('#'):rep(32)) + feed('0') + screen:expect{grid=[[ + {28:ngila_tdeyalrevo}ba#####{28:loc_niw}###################^#| + {1: ~}| + | + ]]} + + insert(('#'):rep(16)) + feed('0') + screen:expect{grid=[[ + {28:ngila_thgir}############{28:loc_niw}###################^#| + {28:LOE} nml{28:deyalrevo}| + | + ]]} + + insert('###') + feed('0') + screen:expect{grid=[[ + #################################################^#| + {28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}ba#| + | + ]]} + + command('set number') + screen:expect{grid=[[ + #############################################^#{2: 1 }| + {28:ngila_thgir} {28:loc_niw} nml{28:deyalrevo}ba#####{2: }| + | + ]]} + + command('set cpoptions+=n') + screen:expect{grid=[[ + #############################################^#{2: 1 }| + {28:ngila_thgir} {28:loc_niw} nml{28:deyalrevo}ba#####| + | + ]]} + end) + + it('works with double width char and rightleft', function() + screen:try_resize(50, 3) + insert('abcdefghij口klmnop') + feed('0') + command('set rightleft') + screen:expect{grid=[[ + ponmlk口jihgfedcb^a| + {1: ~}| + | + ]]} + meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + screen:expect{grid=[[ + ponmlk {28:deyalrevo}b^a| + {1: ~}| + | + ]]} + meths.buf_set_extmark(0, ns, 0, 15, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + screen:expect{grid=[[ + po{28:古}lk {28:deyalrevo}b^a| + {1: ~}| + | + ]]} + end) end) describe('decorations: inline virtual text', function() @@ -4245,6 +4323,7 @@ if (h->n_buckets < new_n_buckets) { // expand end) it('does not show twice if end_row or end_col is specified #18622', function() + screen:try_resize(50, 8) insert([[ aaa bbb @@ -4260,10 +4339,28 @@ if (h->n_buckets < new_n_buckets) { // expand dd^d | {1:VIRT LINE 2} | {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + | + ]]} + end) + + it('works with rightleft', function() + screen:try_resize(50, 8) + insert([[ + aaa + bbb + ccc + ddd]]) + command('set number rightleft') + meths.buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true}) + meths.buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + screen:expect{grid=[[ + aaa{9: 1 }| + {1:1 ENIL TRIV}| + bbb{9: 2 }| + ccc{9: 3 }| + ^ddd{9: 4 }| + {1:2 ENIL TRIV}{9: }| + {1: ~}| | ]]} end) diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index c8ca5be282..5e907f82ba 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -3047,6 +3047,39 @@ describe("folded lines", function() {11:-- VISUAL LINE --} | ]]) end + + meths.set_option_value('rightleft', true, {}) + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + a si sihT{7: }| + {14:hsilgnE dila}^v{7: -}| + {20: desopmoc ecnetnes}{19: }{15:--}{7: +│}| + {15:······}{20:.evac sih ni}{19: }{15:--}{7: +│}| + {1: ~}| + {1: ~}| + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + a si sihT{7: }| + {14:hsilgnE dila}^v{7: -}| + {20: desopmoc ecnetnes}{19: }{15:--}{7: +│}| + {15:······}{20:.evac sih ni}{19: }{15:--}{7: +│}| + {1: ~}| + {1: ~}| + {11:-- VISUAL LINE --} | + ]]) + end end) end -- cgit From 380b634ac951acfd24cffc5091bbcfbb39cd8ca3 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 20 Sep 2023 21:51:57 +0200 Subject: fix(test): fix "indeterminism" warnings in UI tests --- test/functional/ui/cmdline_spec.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 4b92ab730d..6baad28dad 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1275,6 +1275,7 @@ describe('cmdheight=0', function() it('with multigrid', function() clear{args={'--cmd', 'set cmdheight=0'}} screen:attach{ext_multigrid=true} + meths.buf_set_lines(0, 0, -1, true, {'p'}) screen:expect{grid=[[ ## grid 1 [2:-------------------------]| @@ -1283,7 +1284,7 @@ describe('cmdheight=0', function() [2:-------------------------]| [2:-------------------------]| ## grid 2 - ^ | + ^p | {1:~ }| {1:~ }| {1:~ }| @@ -1302,7 +1303,7 @@ describe('cmdheight=0', function() [2:-------------------------]| [3:-------------------------]| ## grid 2 - | + {6:p} | {1:~ }| {1:~ }| {1:~ }| @@ -1427,7 +1428,21 @@ describe('cmdheight=0', function() | ]]) command('set cmdheight=0') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] }| + ]]} command('resize -1') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + | + ]]} command('resize +1') screen:expect([[ ^ | -- cgit From dc6c11394b73803028d04498c80a538fe6aa4310 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Sep 2023 07:03:26 +0800 Subject: fix(statuscolumn): update number hl for each screen line (#25277) --- test/functional/ui/statuscolumn_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 742976cbe2..a7830abe8f 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -475,7 +475,7 @@ describe('statuscolumn', function() aaaaaaaaa | {1:virtual-2 15}virt_line1 | {1:virtual-2 15}virt_line2 | - {1:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {5:aaaaaaaaa }| {1:virtual-1 16}END | {0:~ }| -- cgit From adb73772d9197a7fa6e9ee7a2e8874118e60844d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Sep 2023 08:00:03 +0800 Subject: vim-patch:9.0.1919: Wrong curswant when clicking on empty line or with vsplits Problem: Wrong curswant when clicking on empty line or with vsplits. Solution: Don't check for ScreenCols[] before the start of the window and handle empty line properly. closes: vim/vim#13132 https://github.com/vim/vim/commit/03cd697d635f1b0e7ffe21cf8244a8fb755f2ddb --- test/functional/ui/float_spec.lua | 4 ++-- test/functional/ui/mouse_spec.lua | 4 ++-- test/functional/ui/multigrid_spec.lua | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index f75fb52108..e077e21216 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -6287,7 +6287,7 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 1, 0, 0) + meths.input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| @@ -6366,7 +6366,7 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 1, 0, 0) + meths.input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 [2:----------------------------------------]| diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index a8d01cfbf1..fd24174f74 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1676,7 +1676,7 @@ describe('ui/mouse/input', function() end) - it('getmousepos works correctly', function() + it('getmousepos() works correctly', function() local winwidth = meths.get_option_value('winwidth', {}) -- Set winwidth=1 so that window sizes don't change. meths.set_option_value('winwidth', 1, {}) @@ -1771,7 +1771,7 @@ describe('ui/mouse/input', function() -- Test that mouse position values are properly set for ordinary windows. -- Set the float to be unfocusable instead of closing, to additionally test - -- that getmousepos does not consider unfocusable floats. (see discussion + -- that getmousepos() does not consider unfocusable floats. (see discussion -- in PR #14937 for details). opts.focusable = false meths.win_set_config(float, opts) diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 1778c8218b..6f4082beda 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -2307,6 +2307,7 @@ describe('ext_multigrid', function() {1:~ }| ]]} + -- XXX: mouse_check_grid() doesn't work properly when clicking on grid 1 meths.input_mouse('left', 'press', '', 1, 6, 20) -- TODO(bfredl): "batching" input_mouse is formally not supported yet. -- Normally it should work fine in async context when nvim is not blocked, -- cgit From acc32f20bedd611a582aedf08d64ad66d2a19d3b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Sep 2023 09:55:47 +0800 Subject: test(ui/float_spec): click in bordered float sets correct curswant --- test/functional/ui/float_spec.lua | 69 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index e077e21216..8c9b30d510 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8764,6 +8764,75 @@ describe('float window', function() end end) + it('left click sets correct curswant in float window with border', function() + local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf, 0, -1, true, {'', '', ''}) + meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:┌────────────────────┐}| + {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ {5:┌────────────────────┐} | + {0:~ }{5:│}{1: }{5:│}{0: }| + {0:~ }{5:│}{1: }{5:│}{0: }| + {0:~ }{5:│}{1: }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + | + ]]} + end + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 3, 1) + else + meths.input_mouse('left', 'press', '', 0, 3, 6) + end + eq({0, 3, 1, 0, 1}, funcs.getcurpos()) + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 3, 2) + else + meths.input_mouse('left', 'press', '', 0, 3, 7) + end + eq({0, 3, 1, 0, 2}, funcs.getcurpos()) + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 3, 10) + else + meths.input_mouse('left', 'press', '', 0, 3, 15) + end + eq({0, 3, 1, 0, 10}, funcs.getcurpos()) + end) + it("'winblend' option", function() screen:try_resize(50,9) screen:set_default_attr_ids({ -- cgit From e25cf47ad3e10e0e1ae2b2376d898382af5b1e26 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Sep 2023 10:20:30 +0800 Subject: fix(mouse): click on empty line with 'foldcolumn' --- test/functional/ui/float_spec.lua | 111 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 8c9b30d510..4fea513249 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -8831,6 +8831,117 @@ describe('float window', function() meths.input_mouse('left', 'press', '', 0, 3, 15) end eq({0, 3, 1, 0, 10}, funcs.getcurpos()) + + command('setlocal foldcolumn=1') + feed('zfkgg') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:┌────────────────────┐}| + {5:│}{19: }{1:^ }{5:│}| + {5:│}{19:+}{28:+-- 2 lines: ·····}{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 4, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + {5:┌────────────────────┐} | + {0:~ }{5:│}{19: }{1:^ }{5:│}{0: }| + {0:~ }{5:│}{19:+}{28:+-- 2 lines: ·····}{5:│}{0: }| + {0:~ }{5:│}{2:~ }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + | + ]]} + end + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 1) + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:┌────────────────────┐}| + {5:│}{19: }{1:^ }{5:│}| + {5:│}{19:-}{1: }{5:│}| + {5:│}{19:│}{1: }{5:│}| + {5:└────────────────────┘}| + ]], float_pos={ + [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + }} + else + meths.input_mouse('left', 'press', '', 0, 2, 6) + screen:expect{grid=[[ + {5:┌────────────────────┐} | + {0:~ }{5:│}{19: }{1:^ }{5:│}{0: }| + {0:~ }{5:│}{19:-}{1: }{5:│}{0: }| + {0:~ }{5:│}{19:│}{1: }{5:│}{0: }| + {0:~ }{5:└────────────────────┘}{0: }| + {0:~ }| + | + ]]} + end + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 2) + else + meths.input_mouse('left', 'press', '', 0, 2, 7) + end + eq({0, 2, 1, 0, 1}, funcs.getcurpos()) + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 3) + else + meths.input_mouse('left', 'press', '', 0, 2, 8) + end + eq({0, 2, 1, 0, 2}, funcs.getcurpos()) + + if multigrid then + meths.input_mouse('left', 'press', '', 4, 2, 11) + else + meths.input_mouse('left', 'press', '', 0, 2, 16) + end + eq({0, 2, 1, 0, 10}, funcs.getcurpos()) end) it("'winblend' option", function() -- cgit From 34a786bc49598eeafef3fffcb0836d4557e51638 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 22 Sep 2023 14:21:58 +0800 Subject: fix(extmarks): inline virt_text support multiple hl groups (#25303) --- test/functional/ui/decorations_spec.lua | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index d6a6243be2..c4fd6379f3 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1464,6 +1464,8 @@ describe('extmark decorations', function() end) it('can have virtual text which combines foreground and background groups', function() + screen:try_resize(20, 3) + screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; [2] = {background = tonumber('0x123456'), foreground = tonumber('0xbbbbbb')}; @@ -1481,30 +1483,21 @@ describe('extmark decorations', function() hi VeryBold gui=bold ]] - meths.buf_set_extmark(0, ns, 0, 0, { virt_text={ + insert('##') + local vt = { {'a', {'BgOne', 'FgEin'}}; {'b', {'BgOne', 'FgZwei'}}; {'c', {'BgTwo', 'FgEin'}}; {'d', {'BgTwo', 'FgZwei'}}; {'X', {'BgTwo', 'FgZwei', 'VeryBold'}}; - }}) - + } + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) screen:expect{grid=[[ - ^ {2:a}{3:b}{4:c}{5:d}{6:X} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | + {2:a}{3:b}{4:c}{5:d}{6:X}#^# {2:a}{3:b}{4:c}{5:d}{6:X} {2:a}{3:b}{4:c}{5:d}{6:X}| + {1:~ }| + | ]]} end) -- cgit From 64e8a3c4d19eab40888fbac36b96e97bd9d68c42 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 22 Sep 2023 15:36:24 +0800 Subject: fix(ui): handle virtual text with multiple hl in more cases (#25304) --- test/functional/ui/float_spec.lua | 17 +++++++++------ test/functional/ui/fold_spec.lua | 45 ++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 26 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 4fea513249..93ca1aef3f 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -821,7 +821,7 @@ describe('float window', function() [4] = {bold = true, reverse = true}, [5] = {reverse = true}, [6] = {background = Screen.colors.LightMagenta, bold = true, reverse = true}, - [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [7] = {foreground = Screen.colors.White, background = Screen.colors.Red}, [8] = {bold = true, foreground = Screen.colors.SeaGreen4}, [9] = {background = Screen.colors.LightGrey, underline = true}, [10] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, @@ -2512,7 +2512,12 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right",footer= { {"🦄"},{"BB"}},footer_pos="right"}) + command('hi B0 guibg=Red guifg=Black') + command('hi B1 guifg=White') + meths.win_set_config(win, { + title = {{"🦄"}, {"BB", {"B0", "B1"}}}, title_pos = "right", + footer= {{"🦄"}, {"BB", {"B0", "B1"}}}, footer_pos = "right", + }) if multigrid then screen:expect{grid=[[ ## grid 1 @@ -2533,10 +2538,10 @@ describe('float window', function() ## grid 3 | ## grid 4 - {5:╔═════}🦄BB{5:╗}| + {5:╔═════}🦄{7:BB}{5:╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| - {5:╚═════}🦄BB{5:╝}| + {5:╚═════}🦄{7:BB}{5:╝}| ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 2, 5, true } }, win_viewport={ @@ -2547,10 +2552,10 @@ describe('float window', function() screen:expect{grid=[[ ^ | {0:~ }| - {0:~ }{5:╔═════}🦄BB{5:╗}{0: }| + {0:~ }{5:╔═════}🦄{7:BB}{5:╗}{0: }| {0:~ }{5:║}{1: halloj! }{5:║}{0: }| {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| - {0:~ }{5:╚═════}🦄BB{5:╝}{0: }| + {0:~ }{5:╚═════}🦄{7:BB}{5:╝}{0: }| | ]]} end diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 5e907f82ba..f42682ba69 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -33,7 +33,7 @@ describe("folded lines", function() [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {reverse = true}, [3] = {bold = true, reverse = true}, - [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [4] = {foreground = Screen.colors.White, background = Screen.colors.Red}, [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, [6] = {background = Screen.colors.Yellow}, [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, @@ -2938,10 +2938,15 @@ describe("folded lines", function() screen:try_resize(30, 7) insert(content1) command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") + command('hi F0 guibg=Red guifg=Black') + command('hi F1 guifg=White') meths.set_option_value('cursorline', true, {}) meths.set_option_value('foldcolumn', '4', {}) - meths.set_option_value('foldtext', - '[[v:folddashes], ["\t", "Search"], [getline(v:foldstart), "NonText"]]', {}) + meths.set_option_value('foldtext', '[' + .. '["▶", ["F0", "F1"]], ' + .. '[v:folddashes], ' + .. '["\t", "Search"], ' + .. '[getline(v:foldstart), "NonText"]]', {}) command('3,4fold') command('5,6fold') @@ -2958,7 +2963,7 @@ describe("folded lines", function() [3:------------------------------]| ## grid 2 {7: }This is a | - {7:+ }{13:^-}{17: }{18:valid English}{13:·····}| + {7:+ }{4:^▶}{13:-}{17: }{18:valid English}{13:·····}| {1:~ }| {1:~ }| {1:~ }| @@ -2969,7 +2974,7 @@ describe("folded lines", function() else screen:expect([[ {7: }This is a | - {7:+ }{13:^-}{17: }{18:valid English}{13:·····}| + {7:+ }{4:^▶}{13:-}{17: }{18:valid English}{13:·····}| {1:~ }| {1:~ }| {1:~ }| @@ -2977,7 +2982,7 @@ describe("folded lines", function() | ]]) end - eq('-\tvalid English', funcs.foldtextresult(2)) + eq('▶-\tvalid English', funcs.foldtextresult(2)) feed('zo') if multigrid then @@ -2993,8 +2998,8 @@ describe("folded lines", function() ## grid 2 {7: }This is a | {7:- }valid English | - {7:│+ }{5:--}{19: }{18:sentence composed }| - {7:│+ }{13:^--}{17: }{18:in his cave.}{13:······}| + {7:│+ }{4:▶}{5:--}{19: }{18:sentence composed }| + {7:│+ }{4:^▶}{13:--}{17: }{18:in his cave.}{13:······}| {1:~ }| {1:~ }| ## grid 3 @@ -3004,15 +3009,15 @@ describe("folded lines", function() screen:expect([[ {7: }This is a | {7:- }valid English | - {7:│+ }{5:--}{19: }{18:sentence composed }| - {7:│+ }{13:^--}{17: }{18:in his cave.}{13:······}| + {7:│+ }{4:▶}{5:--}{19: }{18:sentence composed }| + {7:│+ }{4:^▶}{13:--}{17: }{18:in his cave.}{13:······}| {1:~ }| {1:~ }| | ]]) end - eq('--\tsentence composed by', funcs.foldtextresult(3)) - eq('--\tin his cave.', funcs.foldtextresult(5)) + eq('▶--\tsentence composed by', funcs.foldtextresult(3)) + eq('▶--\tin his cave.', funcs.foldtextresult(5)) command('hi! Visual guibg=Red') feed('V2k') @@ -3029,8 +3034,8 @@ describe("folded lines", function() ## grid 2 {7: }This is a | {7:- }^v{14:alid English} | - {7:│+ }{15:--}{19: }{20:sentence composed }| - {7:│+ }{15:--}{19: }{20:in his cave.}{15:······}| + {7:│+ }{4:▶}{15:--}{19: }{20:sentence composed }| + {7:│+ }{4:▶}{15:--}{19: }{20:in his cave.}{15:······}| {1:~ }| {1:~ }| ## grid 3 @@ -3040,8 +3045,8 @@ describe("folded lines", function() screen:expect([[ {7: }This is a | {7:- }^v{14:alid English} | - {7:│+ }{15:--}{19: }{20:sentence composed }| - {7:│+ }{15:--}{19: }{20:in his cave.}{15:······}| + {7:│+ }{4:▶}{15:--}{19: }{20:sentence composed }| + {7:│+ }{4:▶}{15:--}{19: }{20:in his cave.}{15:······}| {1:~ }| {1:~ }| {11:-- VISUAL LINE --} | @@ -3062,8 +3067,8 @@ describe("folded lines", function() ## grid 2 a si sihT{7: }| {14:hsilgnE dila}^v{7: -}| - {20: desopmoc ecnetnes}{19: }{15:--}{7: +│}| - {15:······}{20:.evac sih ni}{19: }{15:--}{7: +│}| + {20: desopmoc ecnetnes}{19: }{15:--}{4:▶}{7: +│}| + {15:······}{20:.evac sih ni}{19: }{15:--}{4:▶}{7: +│}| {1: ~}| {1: ~}| ## grid 3 @@ -3073,8 +3078,8 @@ describe("folded lines", function() screen:expect([[ a si sihT{7: }| {14:hsilgnE dila}^v{7: -}| - {20: desopmoc ecnetnes}{19: }{15:--}{7: +│}| - {15:······}{20:.evac sih ni}{19: }{15:--}{7: +│}| + {20: desopmoc ecnetnes}{19: }{15:--}{4:▶}{7: +│}| + {15:······}{20:.evac sih ni}{19: }{15:--}{4:▶}{7: +│}| {1: ~}| {1: ~}| {11:-- VISUAL LINE --} | -- cgit From b7763d7f6b7fdcabe06658c664457df8bc147563 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 22 Sep 2023 17:56:05 +0800 Subject: fix(api): get virtual text with multiple hl properly (#25307) --- test/functional/ui/decorations_spec.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index c4fd6379f3..f378c50792 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1464,7 +1464,7 @@ describe('extmark decorations', function() end) it('can have virtual text which combines foreground and background groups', function() - screen:try_resize(20, 3) + screen:try_resize(20, 5) screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; @@ -1494,8 +1494,11 @@ describe('extmark decorations', function() meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) + meths.buf_set_extmark(0, ns, 0, 0, { virt_lines = { vt, vt } }) screen:expect{grid=[[ {2:a}{3:b}{4:c}{5:d}{6:X}#^# {2:a}{3:b}{4:c}{5:d}{6:X} {2:a}{3:b}{4:c}{5:d}{6:X}| + {2:a}{3:b}{4:c}{5:d}{6:X} | + {2:a}{3:b}{4:c}{5:d}{6:X} | {1:~ }| | ]]} -- cgit From c0a29931e29bbb40650df01918826cdb64e8fc32 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 23 Sep 2023 14:42:59 +0800 Subject: fix(unhide): close floating windows first (#25318) --- test/functional/ui/float_spec.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 93ca1aef3f..e21e4e4aad 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -522,6 +522,16 @@ describe('float window', function() eq(5, meths.get_option_value('scroll', {win=float_win.id})) end) + it(':unhide works when there are floating windows #17797', function() + local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} + local w0 = curwin() + meths.open_win(0, false, float_opts) + meths.open_win(0, false, float_opts) + eq(3, #meths.list_wins()) + command('unhide') + eq({ w0 }, meths.list_wins()) + end) + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_buf, old_win -- cgit From fcdfbb430377a82921cf1a72df97bce7952733e8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 23 Sep 2023 22:33:44 +0800 Subject: fix(float): fix some other crashes with :unhide or :all (#25328) --- test/functional/ui/float_spec.lua | 163 +++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index e21e4e4aad..6db9e7af3e 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -522,8 +522,8 @@ describe('float window', function() eq(5, meths.get_option_value('scroll', {win=float_win.id})) end) - it(':unhide works when there are floating windows #17797', function() - local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} + it(':unhide works when there are floating windows', function() + local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} local w0 = curwin() meths.open_win(0, false, float_opts) meths.open_win(0, false, float_opts) @@ -532,6 +532,17 @@ describe('float window', function() eq({ w0 }, meths.list_wins()) end) + it(':all works when there are floating windows', function() + command('args Xa.txt') + local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} + local w0 = curwin() + meths.open_win(0, false, float_opts) + meths.open_win(0, false, float_opts) + eq(3, #meths.list_wins()) + command('all') + eq({ w0 }, meths.list_wins()) + end) + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_buf, old_win @@ -3222,6 +3233,154 @@ describe('float window', function() end end) + describe('no crash when rearranging windows', function() + local function test_rearrange_windows(cmd) + command('set laststatus=2') + screen:try_resize(40, 13) + + command('args X1 X2 X3 X4 X5 X6') + command('sargument 2') + command('sargument 3') + local w3 = curwin() + command('sargument 4') + local w4 = curwin() + command('sargument 5') + command('sargument 6') + + local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 } + meths.win_set_config(w3, float_opts) + meths.win_set_config(w4, float_opts) + command('wincmd =') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [8:----------------------------------------]| + [8:----------------------------------------]| + {4:X6 }| + [7:----------------------------------------]| + [7:----------------------------------------]| + {5:X5 }| + [4:----------------------------------------]| + [4:----------------------------------------]| + {5:X2 }| + [2:----------------------------------------]| + [2:----------------------------------------]| + {5:X1 }| + [3:----------------------------------------]| + ## grid 2 + | + {0:~ }| + ## grid 3 + | + ## grid 4 + | + {0:~ }| + ## grid 5 + {1: }| + ## grid 6 + {1: }| + ## grid 7 + | + {0:~ }| + ## grid 8 + ^ | + {0:~ }| + ]], float_pos={ + [5] = {{id = 1002}, "NW", 1, 6, 0, true, 50}; + [6] = {{id = 1003}, "NW", 1, 6, 0, true, 50}; + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = {id = 1002}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = {id = 1003}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [7] = {win = {id = 1004}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [8] = {win = {id = 1005}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {4:X6 }| + | + {0:~ }| + {5:X5 }| + {1: }| + {0:~ }| + {5:X2 }| + | + {0:~ }| + {5:X1 }| + | + ]]} + end + + command(cmd) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + {4:X1 }| + [4:----------------------------------------]| + {5:X2 }| + [9:----------------------------------------]| + {5:X3 }| + [10:----------------------------------------]| + {5:X4 }| + [7:----------------------------------------]| + {5:X5 }| + [8:----------------------------------------]| + {5:X6 }| + [3:----------------------------------------]| + ## grid 2 + ^ | + ## grid 3 + | + ## grid 4 + | + ## grid 7 + | + ## grid 8 + | + ## grid 9 + | + ## grid 10 + | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [7] = {win = {id = 1004}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [8] = {win = {id = 1005}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [9] = {win = {id = 1006}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [10] = {win = {id = 1007}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {4:X1 }| + | + {5:X2 }| + | + {5:X3 }| + | + {5:X4 }| + | + {5:X5 }| + | + {5:X6 }| + | + ]]} + end + end + + it('using :unhide', function() + test_rearrange_windows('unhide') + end) + + it('using :all', function() + test_rearrange_windows('all') + end) + end) + it('API has proper error messages', function() local buf = meths.create_buf(false,false) eq("Invalid key: 'bork'", -- cgit From 046c9a83f7ed2694c19d915a63ef0dfed9d29dc5 Mon Sep 17 00:00:00 2001 From: tj-moody <92702993+tj-moody@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:49:47 -0400 Subject: fix(ui): always use stl/stlnc fillchars when drawing statusline (#25267) --- test/functional/ui/statusline_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 7967fb6865..182e0cdadf 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -799,3 +799,21 @@ it("shows correct ruler in cmdline with no statusline", function() 3longlonglong | ]] end) + +it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function() + clear() + local screen = Screen.new(53, 4) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + command('hi clear StatusLine') + command('hi clear StatusLineNC') + command('vsplit') + screen:expect{grid=[[ + ^ │ | + {1:~ }│{1:~ }| + [No Name] [No Name] | + | + ]]} +end) -- cgit From 0592fd5e17dc3609c148e0ccc25a4f035d5f7153 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Sun, 24 Sep 2023 23:15:33 +0500 Subject: fix(ui): "resize -1" with cmdheight=0 #24758 Problem: Crash from: set cmdheight=0 redrawdebug=invalid resize -1 Solution: Do not invalidate first `p_ch` `msg_grid` rows in `update_screen` when scrolling the screen down after displaying a message, because they may be used later for drawing cmdline. Fixes #22154 --- test/functional/ui/cmdline_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 6baad28dad..497b2e7f4c 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1021,6 +1021,26 @@ describe('cmdheight=0', function() screen:attach() end) + it("with redrawdebug=invalid resize -1", function() + command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + feed(":resize -1") + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) + it("with cmdheight=1 noruler laststatus=2", function() command("set cmdheight=1 noruler laststatus=2") screen:expect{grid=[[ -- cgit From dfa8b582a64aa22d3c57261bfcdc970b26cb58f3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 27 Sep 2023 10:48:14 +0800 Subject: fix(extmarks): draw TAB in virt_text properly with 'rl' (#25381) --- test/functional/ui/decorations_spec.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f378c50792..f535bdd1a6 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1963,23 +1963,20 @@ describe('extmark decorations', function() it('works with double width char and rightleft', function() screen:try_resize(50, 3) - insert('abcdefghij口klmnop') + insert('abcdefghij口klmnopqrstu口vwx口yz') feed('0') command('set rightleft') screen:expect{grid=[[ - ponmlk口jihgfedcb^a| + zy口xwv口utsrqponmlk口jihgfedcb^a| {1: ~}| | ]]} meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' }) + meths.buf_set_extmark(0, ns, 0, 29, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) screen:expect{grid=[[ - ponmlk {28:deyalrevo}b^a| - {1: ~}| - | - ]]} - meths.buf_set_extmark(0, ns, 0, 15, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) - screen:expect{grid=[[ - po{28:古}lk {28:deyalrevo}b^a| + zy {28:古}wv {28: }qpon{28:古}k {28:deyalrevo}b^a| {1: ~}| | ]]} -- cgit From 10cabf787724871173a294f2fc1a5dbc62f2ee91 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 26 Sep 2023 14:28:58 +0200 Subject: refactor(grid): use batched updates for statusline and ruler --- test/functional/ui/multigrid_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 6f4082beda..5b982df2b5 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -2887,7 +2887,7 @@ describe('ext_multigrid', function() ## grid 3 | ## grid 4 - ^Lorem i| + Lorem i| psum do| lor sit| amet, | @@ -2896,7 +2896,7 @@ describe('ext_multigrid', function() ipiscin| g elit,| sed do| - eiusmo| + ^eiusmo| {1:~ }| ## grid 5 some text | -- cgit From 28ffd96c9b3912b65bbe0ad0fe8fb123407a6d1e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 28 Sep 2023 20:20:25 +0800 Subject: test: decoration provider with wrapped lines (#25404) --- test/functional/ui/decorations_spec.lua | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index f535bdd1a6..2c4bcadc4b 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -521,6 +521,72 @@ describe('decorations providers', function() ]]} end) + it('virtual text works with wrapped lines', function() + insert(mulholland) + feed('ggJj3JjJ') + setup_provider [[ + local hl = api.nvim_get_hl_id_by_name "ErrorMsg" + local test_ns = api.nvim_create_namespace "mulholland" + function on_do(event, ...) + if event == "line" then + local win, buf, line = ... + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + virt_text = {{string.rep('/', line+1), 'ErrorMsg'}}; + virt_text_pos='eol'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 6, { + virt_text = {{string.rep('*', line+1), 'ErrorMsg'}}; + virt_text_pos='overlay'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 39, { + virt_text = {{string.rep('!', line+1), 'ErrorMsg'}}; + virt_text_win_col=20; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{string.rep('?', line+1), 'ErrorMsg'}}; + virt_text_win_col=10; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{string.rep(';', line+1), 'ErrorMsg'}}; + virt_text_pos='overlay'; + ephemeral = true; + }) + api.nvim_buf_set_extmark(buf, test_ns, line, 40, { + virt_text = {{'+'}, {string.rep(' ', line+1), 'ErrorMsg'}}; + virt_text_pos='right_align'; + ephemeral = true; + }) + end + end + ]] + + screen:expect{grid=[[ + // jus{2:*} to see if th{2:!}re was an accident | + {2:;}n Mulholl{2:?}nd Drive {2:/} +{2: }| + try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| + {2:;;}fer(&sav{2:??}buf, buf); {2://} +{2: }| + posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| + {2:;;;}(&save_{2:???}); {2:///} +{2: }| + {1:~ }| + | + ]]} + command('setlocal breakindent breakindentopt=shift:2') + screen:expect{grid=[[ + // jus{2:*} to see if th{2:!}re was an accident | + {2:;}n Mulho{2:?}land Drive {2:/} +{2: }| + try_st{2:**}t(); bufref_{2:!!}save_buf; switch_b| + {2:;;}fer(&s{2:??}e_buf, buf); {2://} +{2: }| + posp ={2:***}tmark(mark,{2:!!!}lse);^ restore_buf| + {2:;;;}(&sav{2:???}uf); {2:///} +{2: }| + {1:~ }| + | + ]]} + end) + it('can highlight beyond EOL', function() insert(mulholland) setup_provider [[ -- cgit From 4200a0f1678c06c6da4e4cfb0184c29c1174ed21 Mon Sep 17 00:00:00 2001 From: glepnir Date: Wed, 27 Sep 2023 17:23:42 +0800 Subject: feat(float): support toggle show float window --- test/functional/ui/float_spec.lua | 126 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6db9e7af3e..18c8a7370f 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1172,14 +1172,14 @@ describe('float window', function() it('return their configuration', function() local buf = meths.create_buf(false, false) local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60}) - local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60} + local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false} eq(expected, meths.win_get_config(win)) - eq({relative='', external=false, focusable=true}, meths.win_get_config(0)) + eq({relative='', external=false, focusable=true, hide=false}, meths.win_get_config(0)) if multigrid then meths.win_set_config(win, {external=true, width=10, height=1}) - eq({external=true,focusable=true,width=10,height=1,relative=''}, meths.win_get_config(win)) + eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, meths.win_get_config(win)) end end) @@ -4281,7 +4281,7 @@ describe('float window', function() | ]]} end - eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', + eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', hide=false, external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.win_get_config(win)) feed('') @@ -10809,6 +10809,124 @@ describe('float window', function() ]]} end end) + + it('float window with hide option', function() + local buf = meths.create_buf(false,false) + local win = meths.open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true}) + local expected_pos = { + [4]={{id=1001}, 'NW', 1, 2, 5, true}, + } + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ## grid 4 (hidden) + {1: }| + {2:~ }| + ]], float_pos = {}} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_set_config(win, {hide = false}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ## grid 4 + {1: }| + {2:~ }| + ]], float_pos = expected_pos} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }{1: }{0: }| + {0:~ }{2:~ }{0: }| + {0:~ }| + {0:~ }| + | + ]]) + end + + meths.win_set_config(win, {hide=true}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ## grid 4 (hidden) + {1: }| + {2:~ }| + ]], float_pos = {}} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) end describe('with ext_multigrid', function() -- cgit From a9a48d6b5f00241e16e7131c997f0117bc5e9047 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 30 Sep 2023 10:31:55 +0200 Subject: refactor(message): simplify msg_puts_display and use batched grid updates msg_puts_display was more complex than necessary in nvim, as in nvim, it no longer talks directly with a terminal. In particular we don't need to scroll the grid before emiting the last char. The TUI already takes care of things like that, for terminals where it matters. --- test/functional/ui/cmdline_highlight_spec.lua | 2 +- test/functional/ui/popupmenu_spec.lua | 4 ++-- test/functional/ui/screen_basic_spec.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index 17e6855ee4..e4766103c2 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -577,10 +577,10 @@ describe('Command-line coloring', function() | {EOB:~ }| {EOB:~ }| + {EOB:~ }| {MSEP: }| :+ | {ERR:E5404: Chunk 1 end 3 not in range (1, 2]}| - | :++^ | ]]) end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index ea65cf35bd..38649a2be3 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -2439,14 +2439,14 @@ describe('builtin popupmenu', function() prefix | bef{n: word } | tex{n: }^ | - {2:-- INSERT -} | + {2:-- INSERT --}| ]]) -- can't draw the pum, but check we don't crash screen:try_resize(12,2) screen:expect([[ {1:<<<}t^ | - {2:-- INSERT -} | + {2:-- INSERT --}| ]]) -- but state is preserved, pum reappears diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index bc9517aa60..7cc1accd3f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -795,7 +795,7 @@ local function screen_tests(linegrid) screen:try_resize(1, 1) screen:expect([[ resize^ | - {2:-- INSERT -} | + {2:-- INSERT --}| ]]) feed(':ls') -- cgit From d4872377fef7eeb794ea06321f62281af0cde8e3 Mon Sep 17 00:00:00 2001 From: glepnir Date: Tue, 3 Oct 2023 19:26:11 +0800 Subject: fix(highlight): attr set all when normal attr changed --- test/functional/ui/highlight_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 931e1f9985..7776e024b0 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2523,6 +2523,8 @@ describe('highlight namespaces', function() [6] = {bold = true, reverse = true}; [7] = {reverse = true}; [8] = {foreground = Screen.colors.Gray20}; + [9] = {foreground = Screen.colors.Blue}; + [10] = {bold = true, foreground = Screen.colors.SeaGreen}; } ns1 = meths.create_namespace 'grungy' @@ -2655,4 +2657,21 @@ describe('highlight namespaces', function() "Normal:Visual", },res) end) + + it('Normal in set_hl #25474', function() + meths.set_hl(0, 'Normal', {bg='#333333'}) + command('highlight Ignore') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {6: }| + | + Ignore {8:xxx} {9:ctermf}| + {9:g=}15 {9:guifg=}| + bg | + {10:Press ENTER or type comma}| + {10:nd to continue}^ | + ]]} + end) end) -- cgit From a58bb215449cee65b965b9094e9e996ddfe78315 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 5 Oct 2023 14:44:13 +0200 Subject: refactor(grid): get rid of unbatched grid_puts and grid_putchar This finalizes the long running refactor from the old TUI-focused grid implementation where text-drawing cursor was not separated from the visible cursor. Still, the pattern of setting cursor position together with updating a line was convenient. Introduce grid_line_cursor_goto() to still allow this but now being explicit about it. Only having batched drawing functions makes code involving drawing a bit longer. But it is better to be explicit, and this highlights cases where multiple small redraws can be grouped together. This was the case for most of the changed places (messages, lastline, and :intro) --- test/functional/ui/messages_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 46a42e5beb..8a13796c04 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1366,7 +1366,7 @@ describe('ui/ext_messages', function() feed(":intro") screen:expect{grid=[[ - | + ^ | | | | -- cgit From ddef39299f357d3131644647379e88a69749bf40 Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 19 Sep 2023 14:30:02 +0200 Subject: refactor(grid): do arabic shaping in one place The 'arabicshape' feature of vim is a transformation of unicode text to make arabic and some related scripts look better at display time. In particular the content of a cell will be adjusted depending on the (original) content of the cells just before and after it. This is implemented by the arabic_shape() function in nvim. Before this commit, shaping was invoked in four different contexts: - when rendering buffer text in win_line() - in line_putchar() for rendering virtual text - as part of grid_line_puts, used by messages and statuslines and similar - as part of draw_cmdline() for drawing the cmdline This replaces all these with a post-processing step in grid_put_linebuf(), which has become the entry point for all text rendering after recent refactors. An aim of this is to make the handling of multibyte text yet simpler. One of the main reasons multibyte chars needs to be "parsed" into codepoint arrays of composing chars is so that these could be inspected for the purpose of shaping. This can likely be vastly simplified in many contexts where only the total length (in bytes) and width of composed char is needed. --- test/functional/ui/fold_spec.lua | 8 +++--- test/functional/ui/multibyte_spec.lua | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index f42682ba69..7894c8296b 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1156,7 +1156,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}| + {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1168,7 +1168,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}| + {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1337,7 +1337,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̎͂̀̂͛͛ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -1349,7 +1349,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̎͂̀̂͛͛ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index 417c7b797c..077dd1a779 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -177,6 +177,57 @@ describe("multibyte rendering", function() | ]], reset=true} end) + + it('works with arabic input and arabicshape', function() + command('set arabic') + + command('set noarabicshape') + feed('isghl!') + screen:expect{grid=[[ + ^!مالس| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + | + ]]} + + command('set arabicshape') + screen:expect{grid=[[ + ^!ﻡﻼﺳ| + {1: ~}| + {1: ~}| + {1: ~}| + {1: ~}| + | + ]]} + end) + + it('works with arabic input and arabicshape and norightleft', function() + command('set arabic norightleft') + + command('set noarabicshape') + feed('isghl!') + screen:expect{grid=[[ + سلام^! | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + command('set arabicshape') + screen:expect{grid=[[ + ﺱﻼﻣ^! | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + end) end) describe('multibyte rendering: statusline', function() -- cgit From f96f8566b5f7997266264ba94a22844d9bc22699 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 9 Oct 2023 16:14:37 +0800 Subject: test(ui/embed_spec): use notification instead of request (#25555) This avoid the hang mentioned in #24888, and also matches TUI better. --- test/functional/ui/embed_spec.lua | 1 + test/functional/ui/screen.lua | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index cd2b48213d..db01c55e23 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -98,6 +98,7 @@ describe('--embed UI', function() -- attach immediately after startup, for early UI local screen = Screen.new(40, 8) + screen.rpc_async = true -- Avoid hanging. #24888 screen:attach {stdin_fd=3} screen:set_default_attr_ids { [1] = {bold = true, foreground = Screen.colors.Blue1}; diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index be7c2f291c..d3ffb07749 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -150,6 +150,7 @@ function Screen.new(width, height) msg_grid = nil, msg_grid_pos = nil, _session = nil, + rpc_async = false, messages = {}, msg_history = {}, showmode = {}, @@ -173,9 +174,13 @@ function Screen.new(width, height) _busy = false, }, Screen) local function ui(method, ...) - local status, rv = self._session:request('nvim_ui_'..method, ...) - if not status then - error(rv[2]) + if self.rpc_async then + self._session:notify('nvim_ui_'..method, ...) + else + local status, rv = self._session:request('nvim_ui_'..method, ...) + if not status then + error(rv[2]) + end end end self.uimeths = create_callindex(ui) -- cgit From dacd34364ff3af98bc2d357c43e3ce06638e2ce9 Mon Sep 17 00:00:00 2001 From: Jaehoon Hwang Date: Mon, 9 Oct 2023 01:48:24 -0700 Subject: feat(ui-ext): make 'mousehide' into proper ui_option (#25532) --- test/functional/ui/options_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 9d20229ce1..58cd68d94a 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -19,6 +19,7 @@ describe('UI receives option updates', function() linespace=0, pumblend=0, mousefocus=false, + mousehide=true, mousemoveevent=false, showtabline=1, termguicolors=false, @@ -133,6 +134,12 @@ describe('UI receives option updates', function() eq(expected, screen.options) end) + command("set nomousehide") + expected.mousehide = false + screen:expect(function() + eq(expected, screen.options) + end) + command("set mousemoveevent") expected.mousemoveevent = true screen:expect(function() -- cgit From a2f17e97ec2d3767a978889320c1a9fb3d82d5b0 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Tue, 10 Oct 2023 12:33:30 +0300 Subject: fix(highlight): add `FloatFooter` to 'highlight_defs.h' (#25577) --- test/functional/ui/cursor_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 01475a189d..05057ca080 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -215,7 +215,7 @@ describe('ui/cursor', function() m.hl_id = 64 m.attr = {background = Screen.colors.DarkGray} end - if m.id_lm then m.id_lm = 66 end + if m.id_lm then m.id_lm = 67 end end -- Assert the new expectation. -- cgit From 372aa2eb3db375385cf19dc0a6571f790b858241 Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 9 Oct 2023 18:47:10 +0800 Subject: feat(float): add fclose command --- test/functional/ui/float_spec.lua | 180 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 18c8a7370f..ab02094beb 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -10927,6 +10927,186 @@ describe('float window', function() ]]) end end) + + it('fclose command #9663', function() + local bufA = meths.create_buf(false,false) + local bufB = meths.create_buf(false,false) + local bufC = meths.create_buf(false,false) + local bufD = meths.create_buf(false,false) + local config_A = {relative='editor', width=11, height=11, row=5, col=5, border ='single', zindex=50} + local config_B = {relative='editor', width=8, height=8, row=7, col=7, border ='single', zindex=70} + local config_C = {relative='editor', width=4, height=4, row=9, col=9, border ='single',zindex=90} + local config_D = {relative='editor', width=2, height=2, row=10, col=10, border ='single',zindex=100} + meths.open_win(bufA, false, config_A) + meths.open_win(bufB, false, config_B) + meths.open_win(bufC, false, config_C) + meths.open_win(bufD, false, config_D) + --close window which have higher zindex value + command('fclose') + local expected_pos = { + [4]={{id=1001}, 'NW', 1, 5, 5, true, 50}, + [5]={{id=1002}, 'NW', 1, 7, 7, true, 70}, + [6]={{id=1003}, 'NW', 1, 9, 9, true, 90}, + } + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ## grid 4 + {5:┌───────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└───────────┘}| + ## grid 5 + {5:┌────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────────┘}| + ## grid 6 + {5:┌────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────┘}| + ]],float_pos= expected_pos} + else + screen:expect([[ + ^ {5:┌─┌─┌────┐─┐┐} | + {0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:└────┘}{2: }{5:││}{0: }| + | + ]]) + end + -- with range + command('1fclose') + expected_pos[6]=nil + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ## grid 4 + {5:┌───────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└───────────┘}| + ## grid 5 + {5:┌────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────────┘}| + ]],float_pos= expected_pos} + else + screen:expect([[ + ^ {5:┌─┌────────┐┐} | + {0:~ }{5:│}{1: }{5:│}{1: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + | + ]]) + end + --with bang + command('fclose!') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + + ]],float_pos= {}} + else + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end + end) end describe('with ext_multigrid', function() -- cgit From f79052faef874b19ebbed007c30eb3f2c994a8b2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 11 Oct 2023 15:03:59 +0800 Subject: refactor(float): rename ex_floatclose to ex_fclose (#25596) --- test/functional/ui/float_spec.lua | 152 ++++++++++++++++++++++++++++---------- 1 file changed, 111 insertions(+), 41 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index ab02094beb..400b2bbae7 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -10928,26 +10928,96 @@ describe('float window', function() end end) - it('fclose command #9663', function() - local bufA = meths.create_buf(false,false) - local bufB = meths.create_buf(false,false) - local bufC = meths.create_buf(false,false) - local bufD = meths.create_buf(false,false) - local config_A = {relative='editor', width=11, height=11, row=5, col=5, border ='single', zindex=50} - local config_B = {relative='editor', width=8, height=8, row=7, col=7, border ='single', zindex=70} - local config_C = {relative='editor', width=4, height=4, row=9, col=9, border ='single',zindex=90} - local config_D = {relative='editor', width=2, height=2, row=10, col=10, border ='single',zindex=100} - meths.open_win(bufA, false, config_A) - meths.open_win(bufB, false, config_B) - meths.open_win(bufC, false, config_C) - meths.open_win(bufD, false, config_D) - --close window which have higher zindex value - command('fclose') + it(':fclose command #9663', function() + local buf_a = meths.create_buf(false,false) + local buf_b = meths.create_buf(false,false) + local buf_c = meths.create_buf(false,false) + local buf_d = meths.create_buf(false,false) + local config_a = {relative='editor', width=11, height=11, row=5, col=5, border ='single', zindex=50} + local config_b = {relative='editor', width=8, height=8, row=7, col=7, border ='single', zindex=70} + local config_c = {relative='editor', width=4, height=4, row=9, col=9, border ='single',zindex=90} + local config_d = {relative='editor', width=2, height=2, row=10, col=10, border ='single',zindex=100} + meths.open_win(buf_a, false, config_a) + meths.open_win(buf_b, false, config_b) + meths.open_win(buf_c, false, config_c) + meths.open_win(buf_d, false, config_d) local expected_pos = { [4]={{id=1001}, 'NW', 1, 5, 5, true, 50}, [5]={{id=1002}, 'NW', 1, 7, 7, true, 70}, [6]={{id=1003}, 'NW', 1, 9, 9, true, 90}, + [7]={{id=1004}, 'NW', 1, 10, 10, true, 100}, } + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:┌───────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└───────────┘}| + ## grid 5 + {5:┌────────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────────┘}| + ## grid 6 + {5:┌────┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└────┘}| + ## grid 7 + {5:┌──┐}| + {5:│}{1: }{5:│}| + {5:│}{2:~ }{5:│}| + {5:└──┘}| + ]], float_pos=expected_pos} + else + screen:expect([[ + ^ {5:┌─┌─┌────┐─┐┐} | + {0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│┌──┐│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:││}{1: }{5:││}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:││}{2:~ }{5:││}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:└└──┘┘}{2: }{5:││}{0: }| + | + ]]) + end + -- close the window with the highest zindex value + command('fclose') + expected_pos[7] = nil if multigrid then screen:expect{grid=[[ ## grid 1 @@ -11000,21 +11070,21 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:│}{2:~ }{5:│}| {5:└────┘}| - ]],float_pos= expected_pos} + ]], float_pos=expected_pos} else screen:expect([[ - ^ {5:┌─┌─┌────┐─┐┐} | - {0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:└────┘}{2: }{5:││}{0: }| - | + ^ {5:┌─┌─┌────┐─┐┐} | + {0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:└────┘}{2: }{5:││}{0: }| + | ]]) end -- with range command('1fclose') - expected_pos[6]=nil + expected_pos[6] = nil if multigrid then screen:expect{grid=[[ ## grid 1 @@ -11060,19 +11130,19 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:│}{2:~ }{5:│}| {5:└────────┘}| - ]],float_pos= expected_pos} + ]], float_pos=expected_pos} else screen:expect([[ - ^ {5:┌─┌────────┐┐} | - {0:~ }{5:│}{1: }{5:│}{1: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - | + ^ {5:┌─┌────────┐┐} | + {0:~ }{5:│}{1: }{5:│}{1: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + | ]]) end - --with bang + -- with bang command('fclose!') if multigrid then screen:expect{grid=[[ @@ -11094,16 +11164,16 @@ describe('float window', function() ## grid 3 | - ]],float_pos= {}} + ]], float_pos={}} else screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - | + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | ]]) end end) -- cgit From ebe489d8f0edbb3538a59733289d8969d1ffea22 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 12 Oct 2023 19:27:45 -0400 Subject: fix: allow multiline message for echoerr (#25380) PROBLEM: Currently `:echoerr` prints multi-line strings in a single line as `:echom` does (Note: `:echon` can print multi-line strings well). This makes stacktrace printed via echoerr difficult to read. Example code: try lua error("lua stacktrace") catch echoerr v:exception endtry Output: Error detected while processing a.vim[5]..a.vim: line 4: Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace^@stack traceback:^@^I[C]: in function 'error'^@^I[string ":lua"]:1: in main chunk SOLUTION: Allow echoerr to print multiline messages (e.g., lua exceptions), because this command is usually used to print stacktraces. Output after the fix: Error detected while processing a.vim[5]..a.vim: line 4: Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace stack traceback: [C]: in function 'error' [string ":lua"]:1: in main chunk --- test/functional/ui/messages_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 8a13796c04..ca2bf67220 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -333,6 +333,36 @@ describe('ui/ext_messages', function() ]]} end) + it(':echoerr multiline', function() + exec_lua([[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]]) + feed(':echoerr g:multi') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={{ + content = {{ "bork\nfail", 2 }}, + kind = "echoerr" + }}} + + feed(':messages') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={{ + content = {{ "Press ENTER or type command to continue", 4 }}, + kind = "return_prompt" + }}, msg_history={{ + content = {{ "bork\nfail", 2 }}, + kind = "echoerr" + }}} + end) + it('shortmess-=S', function() command('set shortmess-=S') feed('iline 1\nline 2') -- cgit From bf70a33f5e7de0218704126c149db24542e39766 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Oct 2023 09:58:30 +0800 Subject: vim-patch:8.1.0822: peeking and flushing output slows down execution (#25629) Problem: Peeking and flushing output slows down execution. Solution: Do not update the mode message when global_busy is set. Do not flush when only peeking for a character. (Ken Takata) https://github.com/vim/vim/commit/cb574f415486adff645ce384979bfecf27f5be8c --- test/functional/ui/decorations_spec.lua | 54 ++++++++++++++++++--------------- test/functional/ui/float_spec.lua | 8 +++-- test/functional/ui/fold_spec.lua | 4 +-- test/functional/ui/inccommand_spec.lua | 11 ++++++- test/functional/ui/options_spec.lua | 9 ++++-- test/functional/ui/searchhl_spec.lua | 2 +- 6 files changed, 54 insertions(+), 34 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 2c4bcadc4b..df7de77333 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1775,30 +1775,36 @@ describe('extmark decorations', function() ]]) -- When only one highlight group has an underline attribute, it should always take effect. - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) - screen:expect([[ - {1:aaa}{5:bbb}{1:aa^a} | - {0:~ }| - | - ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) - screen:expect_unchanged(true) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) - screen:expect([[ - {2:aaa}{6:bbb}{2:aa^a} | - {0:~ }| - | - ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) - screen:expect_unchanged(true) + for _, d in ipairs({-5, 5}) do + meths.buf_clear_namespace(0, ns, 0, -1) + screen:expect([[ + aaabbbaa^a | + {0:~ }| + | + ]]) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + screen:expect([[ + {1:aaa}{5:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + end + for _, d in ipairs({-5, 5}) do + meths.buf_clear_namespace(0, ns, 0, -1) + screen:expect([[ + aaabbbaa^a | + {0:~ }| + | + ]]) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + screen:expect([[ + {2:aaa}{6:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + end end) it('highlight is combined with syntax and sign linehl #20004', function() diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 400b2bbae7..9f6b3ca296 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -9284,9 +9284,11 @@ describe('float window', function() end -- Also test with global NormalNC highlight - meths.set_option_value('winhighlight', '', {win = win}) - command('hi link NormalNC Visual') - screen:expect_unchanged(true) + exec_lua([[ + vim.api.nvim_set_option_value('winhighlight', '', {win = ...}) + vim.api.nvim_set_hl(0, 'NormalNC', {link = 'Visual'}) + ]], win) + screen:expect_unchanged() command('hi clear NormalNC') command('hi SpecialRegion guifg=Red blend=0') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 7894c8296b..264c0355ae 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -169,10 +169,10 @@ describe("folded lines", function() end -- CursorLine is applied correctly with screenrow motions #22232 feed("jgk") - screen:expect_unchanged(true) + screen:expect_unchanged() -- CursorLine is applied correctly when closing a fold when cursor is not at fold start feed("zo4Gzc") - screen:expect_unchanged(true) + screen:expect_unchanged() command("set cursorlineopt=line") if multigrid then screen:expect([[ diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 00dfa3fd49..cb00c75e74 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2929,7 +2929,16 @@ it(':substitute with inccommand, allows :redraw before first separator is typed meths.open_win(float_buf, false, { relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false, }) - feed(':%s') + feed(':') + screen:expect([[ + foo bar baz | + bar baz fox | + bar foo baz | + {16: }{15: }| + {15:~ }| + :^ | + ]]) + feed('%s') screen:expect([[ foo bar baz | bar baz fox | diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 58cd68d94a..f3817856f7 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -69,15 +69,18 @@ describe('UI receives option updates', function() eq({'mouse_on'}, evs) end) command("set mouse=") + screen:expect(function() + eq({'mouse_on', 'mouse_off'}, evs) + end) command("set mouse&") screen:expect(function() - eq({'mouse_on','mouse_off', 'mouse_on'}, evs) + eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs) end) screen:detach() - eq({'mouse_on','mouse_off', 'mouse_on'}, evs) + eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs) screen:attach() screen:expect(function() - eq({'mouse_on','mouse_off','mouse_on', 'mouse_on'}, evs) + eq({'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on'}, evs) end) end) diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 7fd66d6f8a..eb7a2574f3 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -337,7 +337,7 @@ describe('search highlighting', function() ]]) feed('/foo') helpers.poke_eventloop() - screen:sleep(0) + screen:sleep(100) screen:expect_unchanged() end) -- cgit From ce0f80835a5f6febd64f4ce5cf245d476ebaecfd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 14 Oct 2023 13:53:52 +0800 Subject: test(ui/searchhl_spec): match more in :terminal test (#25631) --- test/functional/ui/searchhl_spec.lua | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index eb7a2574f3..dc7ef666bd 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -19,7 +19,8 @@ describe('search highlighting', function() [1] = {bold=true, foreground=Screen.colors.Blue}, [2] = {background = Screen.colors.Yellow}, -- Search [3] = {reverse = true}, - [4] = {foreground = Screen.colors.Red}, -- Message + [4] = {foreground = Screen.colors.Red}, -- WarningMsg + [5] = {bold = true, reverse = true}, -- StatusLine [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded }) end) @@ -326,19 +327,33 @@ describe('search highlighting', function() it('is preserved during :terminal activity', function() feed((':terminal "%s" REP 5000 foo'):format(testprg('shell-test'))) - feed(':file term') + screen:expect([[ + ^0: foo | + 1: foo | + 2: foo | + 3: foo | + 4: foo | + 5: foo | + :file term | + ]]) + feed('G') -- Follow :terminal output. feed(':vnew') insert([[ foo bar baz bar baz foo - bar foo baz - ]]) + bar foo baz]]) feed('/foo') - helpers.poke_eventloop() - screen:sleep(100) - screen:expect_unchanged() + screen:expect([[ + {3:foo} bar baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| + bar baz {2:foo} │{MATCH:%d+}: {2:foo}{MATCH:%s+}| + bar {2:foo} baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| + {1:~ }│{MATCH:.*}| + {1:~ }│{MATCH:.*}| + {5:[No Name] [+] }{3:term }| + /foo^ | + ]]) end) it('works with incsearch', function() -- cgit From 13f55750e9bea8ec8f50550546edc64a0f0964d8 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Fri, 13 Oct 2023 12:01:26 +0500 Subject: fix(ui): empty line before the next message after :silent command Problem: The next command after `silent !{cmd}` or `silent lua print('str')` prints an empty line before printing a message, because these commands set `msg_didout = true` despite not printing any messages. Solution: Set `msg_didout = true` only if `msg_silent == 0` --- test/functional/ui/messages_spec.lua | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index ca2bf67220..a5b2474bc5 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1061,6 +1061,53 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim -- luacheck: pop end) + it('no empty line after :silent #12099', function() + exec([[ + func T1() + silent !echo + echo "message T1" + endfunc + func T2() + silent lua print("lua message") + echo "message T2" + endfunc + func T3() + silent call nvim_out_write("api message\n") + echo "message T3" + endfunc + ]]) + feed(':call T1()') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T1 | + ]]} + feed(':call T2()') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T2 | + ]]} + feed(':call T3()') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T3 | + ]]} + end) + it('supports ruler with laststatus=0', function() command("set ruler laststatus=0") screen:expect{grid=[[ -- cgit From d974a3dcbb3757ebeb78fa64054c795ab7acdf1a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 15 Oct 2023 17:19:01 +0800 Subject: vim-patch:9.0.2032: cannot get mouse click pos for tab or virt text (#25653) Problem: Cannot accurately get mouse clicking position when clicking on a TAB or with virtual text. Solution: Add a "coladd" field to getmousepos() result. closes: vim/vim#13335 https://github.com/vim/vim/commit/f5a94d5165bb9e390797da50a1fa7a87df3fbee4 --- test/functional/ui/fold_spec.lua | 7 ++++--- test/functional/ui/mouse_spec.lua | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 264c0355ae..9a0182ea29 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -2155,13 +2155,14 @@ describe("folded lines", function() meths.input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) eq({ - column = 1, - line = 3, screencol = 1, screenrow = 5, - wincol = 1, winid = 1000, + wincol = 1, winrow = 5, + line = 3, + column = 1, + coladd = 0, }, funcs.getmousepos()) meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} }) diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index fd24174f74..1356ba3db8 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1717,6 +1717,7 @@ describe('ui/mouse/input', function() eq(0, mousepos.wincol) eq(0, mousepos.line) eq(0, mousepos.column) + eq(0, mousepos.coladd) end end end @@ -1736,15 +1737,18 @@ describe('ui/mouse/input', function() eq(win_col + 1, mousepos.wincol) local line = 0 local column = 0 + local coladd = 0 if win_row > 0 and win_row < opts.height + 1 and win_col > 0 and win_col < opts.width + 1 then -- Because of border, win_row and win_col don't need to be -- incremented by 1. line = math.min(win_row, funcs.line('$')) column = math.min(win_col, #funcs.getline(line) + 1) + coladd = win_col - column end eq(line, mousepos.line) eq(column, mousepos.column) + eq(coladd, mousepos.coladd) end end @@ -1764,8 +1768,10 @@ describe('ui/mouse/input', function() eq(win_col + 1, mousepos.wincol) local line = math.min(win_row + 1, funcs.line('$')) local column = math.min(win_col + 1, #funcs.getline(line) + 1) + local coladd = win_col + 1 - column eq(line, mousepos.line) eq(column, mousepos.column) + eq(coladd, mousepos.coladd) end end @@ -1788,8 +1794,10 @@ describe('ui/mouse/input', function() eq(win_col + 1, mousepos.wincol) local line = math.min(win_row + 1, funcs.line('$')) local column = math.min(win_col + 1, #funcs.getline(line) + 1) + local coladd = win_col + 1 - column eq(line, mousepos.line) eq(column, mousepos.column) + eq(coladd, mousepos.coladd) end end end -- cgit From 0818d655288ebd70de728b13fabcfd01a0e2e2ec Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 15 Oct 2023 19:36:19 +0800 Subject: fix(extmarks): skip virt_text if it is out of window (#25658) --- test/functional/ui/decorations_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index df7de77333..e56f82bd9f 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1456,6 +1456,24 @@ describe('extmark decorations', function() ]]} end) + it('virtual text win_col out of window does not break display #25645', function() + screen:try_resize(51, 6) + command('vnew') + meths.buf_set_lines(0, 0, -1, false, { string.rep('a', 50) }) + screen:expect{grid=[[ + ^aaaaaaaaaaaaaaaaaaaaaaaaa│ | + aaaaaaaaaaaaaaaaaaaaaaaaa│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {41:[No Name] [+] }{40:[No Name] }| + | + ]]} + local extmark_opts = { virt_text_win_col = 35, virt_text = { { ' ', 'Comment' } } } + meths.buf_set_extmark(0, ns, 0, 0, extmark_opts) + screen:expect_unchanged() + assert_alive() + end) + it('can have virtual text on folded line', function() insert([[ 11111 -- cgit From 356a6728ac077fa7ec4f6fbc51eda33e025d86e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 Oct 2023 21:42:34 +0800 Subject: vim-patch:9.0.2037: A few remaining cmdline completion issues with C-E/Y (#25686) Problem: A few remaining cmdline completion issues with C-E/Y Solution: Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end Fix cmdline completion fuzzy/Ctrl-E/Ctrl-Y/options when not used at the end A few places in the cmdline completion code only works properly when the user hits Tab (or 'wildchar') at the end of the cmdline, even though it's supposed to work even in the middle of the line. For fuzzy search, `:e ++ff`, and `:set hl=`, fix completion code to make sure to use `xp_pattern_len` instead of assuming the entire `xp_pattern` is the search pattern (since it contains texts after the cursor). Fix Ctrl-E / Ctrl-Y to not jump to the end when canceling/accepting a wildmenu completion. Also, make them work even when not using `set wildoptions+=pum` as there is no drawback to doing so. (Related issue where this was brought up: vim/vim#13331) closes: vim/vim#13362 https://github.com/vim/vim/commit/209ec90b9b9bd948d76511c9cd2b17f47a97afe6 Cherry-pick ex_getln.c changes from patch 9.0.2035. Co-authored-by: Yee Cheng Chin --- test/functional/ui/popupmenu_spec.lua | 67 ++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 38649a2be3..bfa4b7f14e 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3096,7 +3096,7 @@ describe('builtin popupmenu', function() :sign define culhl= culhl=^ | ]]) - feed('e Xdi') + feed('e Xnamedi') screen:expect([[ | {1:~ }| @@ -3105,9 +3105,9 @@ describe('builtin popupmenu', function() {1:~ }| {1:~ }| {1:~ }| - {1:~ }{s: XdirA/ }{1: }| - {1:~ }{n: XfileA }{1: }| - :e Xdir/XdirA/^ | + {1:~ }{s: XdirA/ }{1: }| + {1:~ }{n: XfileA }{1: }| + :e Xnamedir/XdirA/^ | ]]) -- Pressing on a directory name should go into that directory @@ -3120,9 +3120,9 @@ describe('builtin popupmenu', function() {1:~ }| {1:~ }| {1:~ }| - {1:~ }{s: XdirB/ }{1: }| - {1:~ }{n: XfileB }{1: }| - :e Xdir/XdirA/XdirB/^ | + {1:~ }{s: XdirB/ }{1: }| + {1:~ }{n: XfileB }{1: }| + :e Xnamedir/XdirA/XdirB/^ | ]]) -- Pressing on a directory name should go to the parent directory @@ -3135,9 +3135,9 @@ describe('builtin popupmenu', function() {1:~ }| {1:~ }| {1:~ }| - {1:~ }{s: XdirA/ }{1: }| - {1:~ }{n: XfileA }{1: }| - :e Xdir/XdirA/^ | + {1:~ }{s: XdirA/ }{1: }| + {1:~ }{n: XfileA }{1: }| + :e Xnamedir/XdirA/^ | ]]) -- Pressing when the popup menu is displayed should list all the @@ -3511,6 +3511,49 @@ describe('builtin popupmenu', function() :sign define^ | ]]) + -- pressing to end completion should work in middle of the line too + feed(':set wildchazz') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: wildchar }{1: }| + {1:~ }{n: wildcharm }{1: }| + :set wildchar^zz | + ]]) + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :set wildcha^zz | + ]]) + + -- pressing should select the current match and end completion + feed(':set wildchazz') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :set wildchar^zz | + ]]) + feed('') -- check positioning with multibyte char in pattern @@ -3726,13 +3769,13 @@ describe('builtin popupmenu', function() end) -- oldtest: Test_wildmenu_pum_clear_entries() - it('wildoptions=pum when using Ctrl-E as wildchar vim-patch:9.0.1030', function() + it('wildoptions=pum when using odd wildchar', function() screen:try_resize(30, 10) exec([[ set wildoptions=pum set wildchar= ]]) - feed(':sign ') + feed(':sign ') screen:expect([[ | {1:~ }| -- cgit From 272ef271153b0f66410b0e59ce31e05d211b44fd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 Oct 2023 22:43:42 +0800 Subject: vim-patch:9.0.2035: [security] use-after-free with wildmenu (#25687) Problem: [security] use-after-free with wildmenu Solution: properly clean up the wildmenu when exiting Fix wildchar/wildmenu/pum memory corruption with special wildchar's Currently, using `wildchar=` or `wildchar=` can lead to a memory corruption if using wildmenu+pum, or wrong states if only using wildmenu. This is due to the code only using one single place inside the cmdline process loop to perform wild menu clean up (by checking `end_wildmenu`) but there are other odd situations where the loop could have exited and we need a post-loop clean up just to be sure. If the clean up was not done you would have a stale popup menu referring to invalid memory, or if not using popup menu, incorrect status line (if `laststatus=0`). For example, if you hit `` two times when it's wildchar, there's a hard-coded behavior to exit command-line as a failsafe for user, and if you hit `` it will also exit command-line, but the clean up code would not have hit because of specialized `` handling. Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also used for 'wildchar'/'wildcharm'. Currently they don't behave properly, and also have potentially memory unsafe behavior as the logic is currently not accounting for this situation and try to do both. (Previous patch that addressed this: vim/vim#11677) Also, correctly document Escape key behavior (double-hit it to escape) in wildchar docs as it's previously undocumented. In addition, block known invalid chars to be set in `wildchar` option, such as Ctrl-C and ``. This is just to make it clear to the user they shouldn't be set, and is not required for this bug fix. closes: vim/vim#13361 https://github.com/vim/vim/commit/8f4fb007e4d472b09ff6bed9ffa485e0c3093699 Co-authored-by: Yee Cheng Chin --- test/functional/ui/popupmenu_spec.lua | 99 +++++++++++++++++++++++++++++++++-- test/functional/ui/wildmode_spec.lua | 79 ++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+), 3 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index bfa4b7f14e..6d5546e0aa 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -3768,13 +3768,16 @@ describe('builtin popupmenu', function() ]]) end) - -- oldtest: Test_wildmenu_pum_clear_entries() - it('wildoptions=pum when using odd wildchar', function() + -- oldtest: Test_wildmenu_pum_odd_wildchar() + it('wildoptions=pum with odd wildchar', function() screen:try_resize(30, 10) + -- Test odd wildchar interactions with pum. Make sure they behave properly + -- and don't lead to memory corruption due to improperly cleaned up memory. exec([[ set wildoptions=pum set wildchar= ]]) + feed(':sign ') screen:expect([[ | @@ -3788,7 +3791,97 @@ describe('builtin popupmenu', function() {1:~ }{n: unplace }{1: }| :sign define^ | ]]) - assert_alive() + + -- being a wildchar takes priority over its original functionality + feed('') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{s: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign jump^ | + ]]) + + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + + -- Escape key can be wildchar too. Double- is hard-coded to escape + -- command-line, and we need to make sure to clean up properly. + command('set wildchar=') + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + + -- can also be wildchar. however will still escape cmdline + -- and we again need to make sure we clean up properly. + command([[set wildchar=]]) + feed([[:sign ]]) + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) end) end diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 0355c57b5a..3201135b67 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -17,6 +17,85 @@ describe("'wildmenu'", function() screen:attach() end) + -- oldtest: Test_wildmenu_screendump() + it('works', function() + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText + [1] = {foreground = Screen.colors.Black, background = Screen.colors.Yellow}; -- WildMenu + [2] = {bold = true, reverse = true}; -- StatusLine + }) + -- Test simple wildmenu + feed(':sign ') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {1:define}{2: jump list > }| + :sign define^ | + ]]} + + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define }{1:jump}{2: list > }| + :sign jump^ | + ]]} + + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define jump }{1:list}{2: > }| + :sign list^ | + ]]} + + -- Looped back to the original value + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define jump list > }| + :sign ^ | + ]]} + + -- Test that the wild menu is cleared properly + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {0:~ }| + :sign ^ | + ]]} + + -- Test that a different wildchar still works + feed('') + command('set wildchar=') + feed(':sign ') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {1:define}{2: jump list > }| + :sign define^ | + ]]} + + -- Double- is a hard-coded method to escape while wildchar=. Make + -- sure clean up is properly done in edge case like this. + feed('') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end) + it('C-E to cancel wildmenu completion restore original input', function() feed(':sign ') screen:expect([[ -- cgit From 4db4168aafc8ac59f5cb4def5cd7eecfb3f2ada4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Oct 2023 06:40:08 +0800 Subject: vim-patch:8.2.4497: wrong color for half of wide character next to pum scrollbar (#25693) Problem: Wrong color for half of wide character next to pum scrollbar. Solution: Redraw the screen cell with the right color. (closes vim/vim#9874) https://github.com/vim/vim/commit/35d8c2010ea6ee5c9bcfa6a8285648172b92ed83 Co-authored-by: Bram Moolenaar --- test/functional/ui/popupmenu_spec.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 6d5546e0aa..a6cd216d84 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1788,6 +1788,30 @@ describe('builtin popupmenu', function() {2:-- }{5:match 1 of 3} | ]]) end) + + -- oldtest: Test_scrollbar_on_wide_char() + it('scrollbar overwrites half of double-width char below properly', function() + screen:try_resize(32, 10) + exec([[ + call setline(1, ['a', ' 啊啊啊', + \ ' 哦哦哦', + \ ' 呃呃呃']) + call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'})) + ]]) + feed('A') + screen:expect([[ + aa0bb^ | + {s:aa0bb }{c: }啊 | + {n:aa1bb }{c: } 哦 | + {n:aa2bb }{c: }呃呃 | + {n:aa3bb }{c: } | + {n:aa4bb }{c: } | + {n:aa5bb }{c: } | + {n:aa6bb }{s: } | + {n:aa7bb }{s: } | + {2:-- }{5:match 1 of 10} | + ]]) + end) end it('with vsplits', function() -- cgit From 366d0c7887f76f0adc40671292db46f115c9317e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Oct 2023 10:34:55 +0800 Subject: fix(move): check the correct buffer (#25698) --- test/functional/ui/inccommand_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index cb00c75e74..c9e004289d 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3095,6 +3095,36 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu baz]]) end) +it(':substitute with inccommand does not unexpectedly change viewport #25697', function() + clear() + local screen = Screen.new(45, 5) + common_setup(screen, 'nosplit', long_multiline_text) + command('vnew | tabnew | tabclose') + screen:expect([[ + ^ │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + | + ]]) + feed(':s/') + screen:expect([[ + │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + :s/^ | + ]]) + feed('') + screen:expect([[ + ^ │£ m n | + {15:~ }│t œ ¥ | + {15:~ }│ | + {11:[No Name] }{10:[No Name] [+] }| + | + ]]) +end) + it('long :%s/ with inccommand does not collapse cmdline', function() clear() local screen = Screen.new(10,5) -- cgit From 9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Thu, 26 Oct 2023 08:44:28 +0500 Subject: fix(float): win_get_bordertext_col returning negative column number (#25752) Problem: `win_get_bordertext_col` returns column < 1 for right or center aligned text, if its length is more than window width. Solution: Return max(resulting_column, 1) --- test/functional/ui/float_spec.lua | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 9f6b3ca296..f9849ea7fa 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -2034,6 +2034,61 @@ describe('float window', function() eq('center', footer_pos) end) + it('center aligned title longer than window width #25746', function() + local buf = meths.create_buf(false, false) + meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + ' BORDAA '}) + local win = meths.open_win(buf, false, { + relative='editor', width=9, height=2, row=2, col=5, border="double", + title = "abcdefghijklmnopqrstuvwxyz",title_pos = "center", + }) + + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 4 + {5:╔}{11:abcdefghi}{5:╗}| + {5:║}{1: halloj! }{5:║}| + {5:║}{1: BORDAA }{5:║}| + {5:╚═════════╝}| + ]], float_pos={ + [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + }, win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }{5:╔}{11:abcdefghi}{5:╗}{0: }| + {0:~ }{5:║}{1: halloj! }{5:║}{0: }| + {0:~ }{5:║}{1: BORDAA }{5:║}{0: }| + {0:~ }{5:╚═════════╝}{0: }| + | + ]]} + end + + meths.win_close(win, false) + assert_alive() + end) + it('border with title', function() local buf = meths.create_buf(false, false) meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', -- cgit From 4e6096a67fe9860994be38bcd155e7c47313205e Mon Sep 17 00:00:00 2001 From: George Harker Date: Tue, 31 Oct 2023 20:04:53 -0700 Subject: feat(server): allow embed with listen (#25709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit connection from any channel or stdio will unblock remote_ui_wait_for_attach. Wait on stdio only if only —embed specified, if both —embed and —listen then wait on any channel. --- test/functional/ui/embed_spec.lua | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index db01c55e23..e75de503ee 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -2,10 +2,13 @@ local uv = require'luv' local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local thelpers = require('test.functional.terminal.helpers') local feed = helpers.feed local eq = helpers.eq local clear = helpers.clear +local ok = helpers.ok + local function test_embed(ext_linegrid) local screen @@ -133,3 +136,60 @@ describe('--embed UI', function() ]]} end) end) + +describe('--embed --listen UI', function() + it('waits for connection on listening address', function() + helpers.skip(helpers.is_os('win')) + clear() + local child_server = assert(helpers.new_pipename()) + + local screen = thelpers.screen_setup(0, + string.format( + [=[["%s", "--embed", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s"]]=], + helpers.nvim_prog, child_server, helpers.nvim_set)) + screen:expect{grid=[[ + {1: } | + | + | + | + | + | + {3:-- TERMINAL --} | + ]]} + + local child_session = helpers.connect(child_server) + + local info_ok, apiinfo = child_session:request('nvim_get_api_info') + assert(info_ok) + assert(#apiinfo == 2) + + child_session:request('nvim_exec2', [[ + let g:vim_entered=0 + autocmd VimEnter * call execute("let g:vim_entered=1") + ]], {}) + + -- g:vim_entered shouldn't be set to 1 until after attach + local var_ok, var = child_session:request('nvim_get_var', 'vim_entered') + assert(var_ok) + ok(var == 0) + + local child_screen = Screen.new(40, 6) + child_screen:attach(nil, child_session) + child_screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], attr_ids={ + [1] = {foreground = Screen.colors.Blue, bold = true}; + }} + + -- g:vim_entered should now be set to 1 + var_ok, var = child_session:request('nvim_get_var', 'vim_entered') + assert(var_ok) + ok(var == 1) + + end) +end) -- cgit From d7359a87425dc38efda4f74bd580bae9946abe31 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Nov 2023 12:16:37 +0800 Subject: fix(startup): trigger UIEnter for the correct channel (#25860) --- test/functional/ui/embed_spec.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index e75de503ee..fb2cdb3c4a 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -159,19 +159,21 @@ describe('--embed --listen UI', function() local child_session = helpers.connect(child_server) - local info_ok, apiinfo = child_session:request('nvim_get_api_info') - assert(info_ok) - assert(#apiinfo == 2) + local info_ok, api_info = child_session:request('nvim_get_api_info') + ok(info_ok) + eq(2, #api_info) + ok(api_info[1] > 2, 'channel_id > 2', api_info[1]) child_session:request('nvim_exec2', [[ - let g:vim_entered=0 - autocmd VimEnter * call execute("let g:vim_entered=1") + let g:evs = [] + autocmd UIEnter * call add(g:evs, $"UIEnter:{v:event.chan}") + autocmd VimEnter * call add(g:evs, "VimEnter") ]], {}) - -- g:vim_entered shouldn't be set to 1 until after attach - local var_ok, var = child_session:request('nvim_get_var', 'vim_entered') - assert(var_ok) - ok(var == 0) + -- VimEnter and UIEnter shouldn't be triggered until after attach + local var_ok, var = child_session:request('nvim_get_var', 'evs') + ok(var_ok) + eq({}, var) local child_screen = Screen.new(40, 6) child_screen:attach(nil, child_session) @@ -186,10 +188,9 @@ describe('--embed --listen UI', function() [1] = {foreground = Screen.colors.Blue, bold = true}; }} - -- g:vim_entered should now be set to 1 - var_ok, var = child_session:request('nvim_get_var', 'vim_entered') - assert(var_ok) - ok(var == 1) - + -- VimEnter and UIEnter should now be triggered + var_ok, var = child_session:request('nvim_get_var', 'evs') + ok(var_ok) + eq({'VimEnter', ('UIEnter:%d'):format(api_info[1])}, var) end) end) -- cgit From 4c32927084dc491e47abffefdc7ac81eefc7b951 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 3 Nov 2023 08:19:04 +0800 Subject: test(ui/embed_spec): make sure server is started (#25880) --- test/functional/ui/embed_spec.lua | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index fb2cdb3c4a..e59a95c325 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -2,13 +2,15 @@ local uv = require'luv' local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local thelpers = require('test.functional.terminal.helpers') local feed = helpers.feed local eq = helpers.eq +local neq = helpers.neq local clear = helpers.clear local ok = helpers.ok - +local funcs = helpers.funcs +local nvim_prog = helpers.nvim_prog +local retry = helpers.retry local function test_embed(ext_linegrid) local screen @@ -142,20 +144,9 @@ describe('--embed --listen UI', function() helpers.skip(helpers.is_os('win')) clear() local child_server = assert(helpers.new_pipename()) - - local screen = thelpers.screen_setup(0, - string.format( - [=[["%s", "--embed", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s"]]=], - helpers.nvim_prog, child_server, helpers.nvim_set)) - screen:expect{grid=[[ - {1: } | - | - | - | - | - | - {3:-- TERMINAL --} | - ]]} + uv.fs_unlink(child_server) + funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean'}) + retry(nil, nil, function() neq(nil, uv.fs_stat(child_server)) end) local child_session = helpers.connect(child_server) @@ -182,10 +173,11 @@ describe('--embed --listen UI', function() {1:~ }| {1:~ }| {1:~ }| - {1:~ }| + {2:[No Name] 0,0-1 All}| | ]], attr_ids={ [1] = {foreground = Screen.colors.Blue, bold = true}; + [2] = {reverse = true, bold = true}; }} -- VimEnter and UIEnter should now be triggered -- cgit From 44f0480a22af8f87f8784dac430416cb9913adea Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 31 Oct 2023 21:33:00 +0100 Subject: refactor(grid): implement rightleftcmd as a post-processing step Previously, 'rightleftcmd' was implemented by having all code which would affect msg_col or output screen cells be conditional on `cmdmsg_rl`. This change removes all that and instead implements rightleft as a mirroring post-processing step. --- test/functional/ui/cmdline_spec.lua | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 497b2e7f4c..188b9ee87b 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -24,6 +24,7 @@ local function new_screen(opt) [7] = {bold = true, foreground = Screen.colors.Brown}, [8] = {background = Screen.colors.LightGrey}, [9] = {bold = true}, + [10] = {background = Screen.colors.Yellow1}; }) return screen end @@ -771,6 +772,84 @@ describe('cmdline redraw', function() :^abc | ]]) end) + + it('with rightleftcmd', function() + command('set rightleft rightleftcmd=search shortmess+=s') + meths.buf_set_lines(0, 0, -1, true, {"let's rock!"}) + screen:expect{grid=[[ + !kcor s'te^l| + {1: ~}| + {1: ~}| + {1: ~}| + | + ]]} + + feed '/' + screen:expect{grid=[[ + !kcor s'tel| + {1: ~}| + {1: ~}| + {1: ~}| + ^ /| + ]]} + + feed "let's" + -- note: cursor looks off but looks alright in real use + -- when rendered as a block so it touches the end of the text + screen:expect{grid=[[ + !kcor {2:s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ s'tel/| + ]]} + + -- cursor movement + feed "" + screen:expect{grid=[[ + !kcor{2: s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ s'tel/| + ]]} + + feed "rock" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{2:kcor s'tel}| + {1: ~}| + {1: ~}| + {1: ~}| + ^ kcor s'tel/| + ]]} + + feed "" + screen:expect{grid=[[ + !{10:kcor s'te^l}| + {1: ~}| + {1: ~}| + {1: ~}| + kcor s'tel/ | + ]]} + end) end) describe('statusline is redrawn on entering cmdline', function() -- cgit From 68cb4a7405ea9f8841d1f25ee8997c49e77fa679 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 3 Nov 2023 12:26:38 +0100 Subject: feat(extmarks): add "undo_restore" flag to opt out of undo-restoring It is a design goal of extmarks that they allow precise tracking of changes across undo/redo, including restore the exact positions after a do/undo or undo/redo cycle. However this behavior is not useful for all usecases. Many plugins won't keep marks around for long after text changes, but uses them more like a cache until some external source (like LSP semantic highlights) has fully updated to changed text and then will explicitly readjust/replace extmarks as needed. Add a "undo_restore" flag which is true by default (matches existing behavior) but can be set to false to opt-out of this behavior. Delete dead u_extmark_set() code. --- test/functional/ui/decorations_spec.lua | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e56f82bd9f..68c3e73e61 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -11,6 +11,7 @@ local meths = helpers.meths local funcs = helpers.funcs local curbufmeths = helpers.curbufmeths local command = helpers.command +local eq = helpers.eq local assert_alive = helpers.assert_alive describe('decorations providers', function() @@ -1997,6 +1998,60 @@ describe('extmark decorations', function() ]]} end) + local function with_undo_restore(val) + screen:try_resize(50, 5) + insert(example_text) + feed'gg' + meths.buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val}) + screen:expect{grid=[[ + ^for _,{1:item in} ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + | + ]]} + + meths.buf_set_text(0, 0, 4, 0, 8, {''}) + screen:expect{grid=[[ + ^for {1:em in} ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + | + ]]} + end + + it("highlights do reapply to restored text after delete", function() + with_undo_restore(true) -- also default behavior + + feed 'u' + screen:expect{grid=[[ + ^for _,{1:item in} ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + 1 change; before #2 0 seconds ago | + ]]} + end) + + it("highlights don't reapply to restored text after delete with no_undo_restore", function() + with_undo_restore(false) + + feed 'u' + screen:expect{grid=[[ + ^for _,it{1:em in} ipairs(items) do | + local text, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + 1 change; before #2 0 seconds ago | + ]]} + + eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0, + hl_eol = false, hl_group = "NonText", undo_restore = false, + ns_id = 1, priority = 4096, right_gravity = true } } }, + meths.buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) + end) + it('virtual text works with rightleft', function() screen:try_resize(50, 3) insert('abcdefghijklmn') -- cgit From a935c7531ad01e03cfdf8660b2067145f3c169fa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Nov 2023 11:09:50 +0800 Subject: test(ui/decorations_spec): avoid flakiness caused by undo msg (#25924) --- test/functional/ui/decorations_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 68c3e73e61..9c16f76359 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2024,26 +2024,26 @@ describe('extmark decorations', function() it("highlights do reapply to restored text after delete", function() with_undo_restore(true) -- also default behavior - feed 'u' + command('silent undo') screen:expect{grid=[[ ^for _,{1:item in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | if hl_id_cell ~= nil then | hl_id = hl_id_cell | - 1 change; before #2 0 seconds ago | + | ]]} end) - it("highlights don't reapply to restored text after delete with no_undo_restore", function() + it("highlights don't reapply to restored text after delete with undo_restore=false", function() with_undo_restore(false) - feed 'u' + command('silent undo') screen:expect{grid=[[ ^for _,it{1:em in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | if hl_id_cell ~= nil then | hl_id = hl_id_cell | - 1 change; before #2 0 seconds ago | + | ]]} eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0, -- cgit From 9af03bcd47127a416aa6a125590b75adb5f53c3c Mon Sep 17 00:00:00 2001 From: Omar El Halabi Date: Fri, 10 Nov 2023 05:20:26 +0100 Subject: fix(options): do not change inccommand during preview (#25462) --- test/functional/ui/inccommand_spec.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index c9e004289d..3ee67a710c 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -3167,3 +3167,31 @@ it("with 'inccommand' typing :filter doesn't segfault or leak memory #19057", fu feed('i') assert_alive() end) + +it("'inccommand' cannot be changed during preview #23136", function() + clear() + local screen = Screen.new(30, 6) + common_setup(screen, 'nosplit', 'foo\nbar\nbaz') + source([[ + function! IncCommandToggle() + let prev = &inccommand + + if &inccommand ==# 'split' + set inccommand=nosplit + elseif &inccommand ==# 'nosplit' + set inccommand=split + elseif &inccommand ==# '' + set inccommand=nosplit + else + throw 'unknown inccommand' + endif + + return " \" + endfun + + cnoremap IncCommandToggle() + ]]) + + feed(':%s/foo/bar') + assert_alive() +end) -- cgit From d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 10 Nov 2023 15:24:36 +0800 Subject: fix(f_wait): flush UI before blocking (#25962) --- test/functional/ui/messages_spec.lua | 59 +++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a5b2474bc5..215e763fd1 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1312,17 +1312,54 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]) end) - it('echo messages are shown correctly when getchar() immediately follows', function() - feed([[:echo 'foo' | echo 'bar' | call getchar()]]) - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {3: }| - foo | - bar^ | - ]]) + describe('echo messages are shown when immediately followed by', function() + --- @param to_block string command to cause a blocking wait + --- @param to_unblock number|string number: timeout for blocking screen + --- string: keys to stop the blocking wait + local function test_flush_before_block(to_block, to_unblock) + local timeout = type(to_unblock) == 'number' and to_unblock or nil + exec(([[ + func PrintAndWait() + echon "aaa\nbbb" + %s + echon "\nccc" + endfunc + ]]):format(to_block)) + feed(':call PrintAndWait()') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + aaa | + bbb^ | + ]], timeout=timeout} + if type(to_unblock) == 'string' then + feed(to_unblock) + end + screen:expect{grid=[[ + | + {1:~ }| + {3: }| + aaa | + bbb | + ccc | + {4:Press ENTER or type command to continue}^ | + ]]} + end + + it('getchar()', function() + test_flush_before_block([[call getchar()]], 'k') + end) + + it('wait()', function() + test_flush_before_block([[call wait(300, '0')]], 100) + end) + + it('lua vim.wait()', function() + test_flush_before_block([[lua vim.wait(300, function() end)]], 100) + end) end) it('consecutive calls to win_move_statusline() work after multiline message #21014',function() -- cgit From 6c3e170e5668e72b2b144a86b4e8278bc70daa48 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 11 Nov 2023 15:12:58 +0800 Subject: fix(highlight): apply 'winblend' to float border (#25981) --- test/functional/ui/float_spec.lua | 63 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index f9849ea7fa..c9f28f430a 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1017,7 +1017,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 4, 2, 10, true, 50}; + [5] = {{id = 1002}, "NW", 4, 2, 10, true}; }} else screen:expect([[ @@ -9191,6 +9191,13 @@ describe('float window', function() [13] = {background = Screen.colors.LightGray, blend = 30}, [14] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey88}, [15] = {foreground = tonumber('0x939393'), background = Screen.colors.Grey88}, + [16] = {background = Screen.colors.Grey90}; + [17] = {blend = 100}; + [18] = {background = Screen.colors.LightMagenta, blend = 100}; + [19] = {background = Screen.colors.LightMagenta, bold = true, blend = 100, foreground = Screen.colors.Blue1}; + [20] = {background = Screen.colors.White, foreground = Screen.colors.Gray0}; + [21] = {background = Screen.colors.White, bold = true, foreground = tonumber('0x00007f')}; + [22] = {background = Screen.colors.Gray90, foreground = Screen.colors.Gray0}; }) insert([[ Lorem ipsum dolor sit amet, consectetur @@ -9321,9 +9328,7 @@ describe('float window', function() {13:test }| {13: }| {13:popup text }| - ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; - }} + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9477,6 +9482,56 @@ describe('float window', function() | ]]) end + + -- Check that 'winblend' applies to border + meths.win_set_config(win, {border='single'}) + meths.set_option_value('winblend', 100, {win=win.id}) + meths.set_option_value("cursorline", true, {win=0}) + command('hi clear VertSplit') + feed('k0') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [2:--------------------------------------------------]| + [3:--------------------------------------------------]| + ## grid 2 + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea commodo consequat. Duis aute irure dolor in | + reprehenderit in voluptate velit esse cillum | + dolore eu fugiat nulla pariatur. Excepteur sint | + occaecat cupidatat non proident, sunt in culpa | + {16:^qui officia deserunt mollit anim id est }| + laborum. | + ## grid 3 + | + ## grid 4 + {17:┌───────────────┐}| + {17:│}{11:popup text}{18: }{17:│}| + {17:│}{19:~ }{17:│}| + {17:│}{19:~ }{17:│}| + {17:└───────────────┘}| + ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + else + screen:expect([[ + Ut enim ad minim veniam, quis nostrud | + exercitation ullamco laboris nisi ut aliquip ex | + ea co{20:┌───────────────┐}Duis aute irure dolor in | + repre{20:│}{5:popup}{6:it i}{5:text}{20:lu│}tate velit esse cillum | + dolor{20:│}{21:~}{20:eu fugiat null│} pariatur. Excepteur sint | + occae{20:│}{21:~}{20:t cupidatat no│} proident, sunt in culpa | + {16:^qui o}{22:└───────────────┘}{16:ollit anim id est }| + laborum. | + | + ]]) + end end) it('can overlap doublewidth chars', function() -- cgit From 9ecb43b6372feb49d6d497c41aa75d2cce1a1446 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Nov 2023 09:23:34 +0800 Subject: fix(float): apply 'winblend' to title/footer highlight (#25999) --- test/functional/ui/float_spec.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index c9f28f430a..2902b4a4a5 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -9198,6 +9198,9 @@ describe('float window', function() [20] = {background = Screen.colors.White, foreground = Screen.colors.Gray0}; [21] = {background = Screen.colors.White, bold = true, foreground = tonumber('0x00007f')}; [22] = {background = Screen.colors.Gray90, foreground = Screen.colors.Gray0}; + [23] = {blend = 100, bold = true, foreground = Screen.colors.Magenta}; + [24] = {foreground = tonumber('0x7f007f'), bold = true, background = Screen.colors.White}; + [25] = {foreground = tonumber('0x7f007f'), bold = true, background = Screen.colors.Grey90}; }) insert([[ Lorem ipsum dolor sit amet, consectetur @@ -9483,8 +9486,8 @@ describe('float window', function() ]]) end - -- Check that 'winblend' applies to border - meths.win_set_config(win, {border='single'}) + -- Check that 'winblend' applies to border/title/footer + meths.win_set_config(win, {border='single', title='Title', footer='Footer'}) meths.set_option_value('winblend', 100, {win=win.id}) meths.set_option_value("cursorline", true, {win=0}) command('hi clear VertSplit') @@ -9513,21 +9516,21 @@ describe('float window', function() ## grid 3 | ## grid 4 - {17:┌───────────────┐}| + {17:┌}{23:Title}{17:──────────┐}| {17:│}{11:popup text}{18: }{17:│}| {17:│}{19:~ }{17:│}| {17:│}{19:~ }{17:│}| - {17:└───────────────┘}| + {17:└}{23:Footer}{17:─────────┘}| ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | - ea co{20:┌───────────────┐}Duis aute irure dolor in | + ea co{20:┌}{24:Title}{20:──────────┐}Duis aute irure dolor in | repre{20:│}{5:popup}{6:it i}{5:text}{20:lu│}tate velit esse cillum | dolor{20:│}{21:~}{20:eu fugiat null│} pariatur. Excepteur sint | occae{20:│}{21:~}{20:t cupidatat no│} proident, sunt in culpa | - {16:^qui o}{22:└───────────────┘}{16:ollit anim id est }| + {16:^qui o}{22:└}{25:Footer}{22:─────────┘}{16:ollit anim id est }| laborum. | | ]]) -- cgit From 448907f65d6709fa234d8366053e33311a01bdb9 Mon Sep 17 00:00:00 2001 From: LW Date: Sun, 12 Nov 2023 04:54:27 -0800 Subject: feat(lsp)!: vim.lsp.inlay_hint.get(), enable(), is_enabled() #25512 refactor!: `vim.lsp.inlay_hint()` -> `vim.lsp.inlay_hint.enable()` Problem: The LSP specification allows inlay hints to include tooltips, clickable label parts, and code actions; but Neovim provides no API to query for these. Solution: Add minimal viable extension point from which plugins can query for inlay hints in a range, in order to build functionality on top of. Possible Next Steps --- - Add `virt_text_idx` field to `vim.fn.getmousepos()` return value, for usage in mappings of ``, ``, etc --- test/functional/ui/screen.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index d3ffb07749..810a68d387 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -88,6 +88,7 @@ local function isempty(v) return type(v) == 'table' and next(v) == nil end +--- @class test.functional.ui.screen local Screen = {} Screen.__index = Screen -- cgit From d3582e102b7bd53afb58efb37eca866ec528dfbe Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Mon, 13 Nov 2023 04:24:02 +0100 Subject: feat(statuscolumn): re-evaluate for every screen line (#25885) Problem: v:virtnum is less useful than it could be. Solution: Always re-evaluate 'statuscolumn', and update v:virtnum accordingly. --- test/functional/ui/statuscolumn_spec.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index a7830abe8f..9f00c7a5d6 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -429,7 +429,7 @@ describe('statuscolumn', function() {1:buffer 0 5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 5}aaaaaaaa | {1:virtual-2 5}virt_line | - {1:virtual-2 5}virt_line above | + {1:virtual-1 5}virt_line above | {1:buffer 0 6}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 6}aaaaaaaa | {1:buffer 0 7}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -443,18 +443,18 @@ describe('statuscolumn', function() exec_lua([[ vim.api.nvim_buf_set_extmark(0, ns, 15, 0, { virt_lines = {{{"END", ""}}} }) ]]) - feed('Gzz') + feed('GkJzz') screen:expect([[ + {1:buffer 0 12}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 12}aaaaaaaaa | {1:buffer 0 13}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 13}aaaaaaaaa | {1:buffer 0 14}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 14}aaaaaaaaa | - {1:buffer 0 15}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - {1:wrapped 1 15}aaaaaaaaa | - {4:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| - {4:wrapped 1 16}{5:aaaaaaaaa }| - {1:virtual-1 16}END | - {0:~ }| + {4:buffer 0 15}{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:wrapped 1 15}{5:aaaaaaaaa^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {4:wrapped 2 15}{5:aaaaaaaaaaaaaaaaaaa }| + {1:virtual-1 15}END | {0:~ }| {0:~ }| {0:~ }| @@ -467,18 +467,18 @@ describe('statuscolumn', function() vim.api.nvim_buf_set_extmark(0, ns, 14, 0, { virt_lines = {{{"virt_line2", ""}}} }) ]]) screen:expect([[ + {1:buffer 0 12}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaa | {1:buffer 0 13}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaa | {1:buffer 0 14}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| aaaaaaaaa | - {1:buffer 0 15}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaaaaaaa | - {1:virtual-2 15}virt_line1 | + {4:buffer 0 15}{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {5:aaaaaaaaa^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| + {5:aaaaaaa }| + {1:virtual-3 15}virt_line1 | {1:virtual-2 15}virt_line2 | - {4:buffer 0 16}{5:^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| - {5:aaaaaaaaa }| - {1:virtual-1 16}END | - {0:~ }| + {1:virtual-1 15}END | {0:~ }| | ]]) -- cgit From 8d9789a0f3b748b75ac4ae1b8e43d27af40d49fe Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 7 Nov 2023 11:31:21 -0600 Subject: docs: deprecate the "term_background" UI field --- test/functional/ui/options_spec.lua | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index f3817856f7..6af1820430 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -210,22 +210,6 @@ describe('UI can set terminal option', function() screen = Screen.new(20,5) end) - it('term_background', function() - eq('dark', eval '&background') - - screen:attach {term_background='light'} - eq('light', eval '&background') - end) - - it("term_background but not if 'background' already set by user", function() - eq('dark', eval '&background') - command 'set background=dark' - - screen:attach {term_background='light'} - - eq('dark', eval '&background') - end) - it('term_name', function() eq('nvim', eval '&term') -- cgit From ac8ed77afb359694a716501d9e87b0c9949b2445 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 14 Nov 2023 08:53:58 -0600 Subject: feat(tui): add 'termsync' option (#25871) The 'termsync' option enables a mode (provided the underlying terminal supports it) where all screen updates during a redraw cycle are buffered and drawn together when the redraw is complete. This eliminates tearing or flickering in cases where Nvim redraws slower than the terminal redraws the screen. --- test/functional/ui/options_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 6af1820430..2c649709c6 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -23,6 +23,7 @@ describe('UI receives option updates', function() mousemoveevent=false, showtabline=1, termguicolors=false, + termsync=true, ttimeout=true, ttimeoutlen=50, verbose=0, -- cgit From b522cb1ac3fbdf6e68eed5d0b6e1cbeaf3ac2254 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 6 Nov 2023 14:52:27 +0100 Subject: refactor(grid): make screen rendering more multibyte than ever before Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes. --- test/functional/ui/fold_spec.lua | 38 +++++++++++++++++------------------ test/functional/ui/multibyte_spec.lua | 30 +++++++++++++++++++++++++++ test/functional/ui/output_spec.lua | 4 ++-- 3 files changed, 50 insertions(+), 22 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 9a0182ea29..1addf7088e 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1102,8 +1102,6 @@ describe("folded lines", function() end) it("works with multibyte text", function() - -- Currently the only allowed value of 'maxcombine' - eq(6, meths.get_option_value('maxcombine', {})) eq(true, meths.get_option_value('arabicshape', {})) insert([[ å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة @@ -1120,7 +1118,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | + å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | möre tex^t | {1:~ }| {1:~ }| @@ -1132,7 +1130,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | + å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | möre tex^t | {1:~ }| {1:~ }| @@ -1156,7 +1154,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| + {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1168,7 +1166,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| + {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1192,7 +1190,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}| + {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1204,7 +1202,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة·················}| + {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| {1:~ }| {1:~ }| {1:~ }| @@ -1228,7 +1226,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}| + {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| {1:~ }| {1:~ }| {1:~ }| @@ -1240,7 +1238,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̎͂̀̂͛͛ العَرَبِيَّة···········}| + {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| {1:~ }| {1:~ }| {1:~ }| @@ -1265,7 +1263,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:···········ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}{8: 1 }{7: +}| + {5:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| {1: ~}| {1: ~}| {1: ~}| @@ -1277,7 +1275,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:···········ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}{8: 1 }{7: +}| + {5:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| {1: ~}| {1: ~}| {1: ~}| @@ -1301,7 +1299,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -1313,7 +1311,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:·················ةيَّبِرَعَلا x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -1337,7 +1335,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -1349,7 +1347,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̎͂̀̂͛͛ 语 å :senil 2 --^+}| + {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| {1: ~}| {1: ~}| {1: ~}| @@ -1373,7 +1371,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̎͂̀̂͛͛ 语 å| + ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| {1: ~}| {1: ~}| @@ -1385,7 +1383,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̎͂̀̂͛͛ 语 å| + ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| {1: ~}| {1: ~}| @@ -1409,7 +1407,7 @@ describe("folded lines", function() [2:---------------------------------------------]| [3:---------------------------------------------]| ## grid 2 - ةيَّبِرَعَ^لا x̎͂̀̂͛͛ 语 å| + ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| {1: ~}| {1: ~}| @@ -1421,7 +1419,7 @@ describe("folded lines", function() ]]) else screen:expect([[ - ةيَّبِرَعَ^لا x̎͂̀̂͛͛ 语 å| + ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| {1: ~}| {1: ~}| diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index 077dd1a779..d72bf27d6b 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -228,6 +228,36 @@ describe("multibyte rendering", function() ]]} end) + + it('works with arabicshape and multiple composing chars', function() + -- this tests an important edge case: arabicshape might increase the byte size of the base + -- character in a way so that the last composing char no longer fits. use "g8" on the text + -- to observe what is happening (the final E1 80 B7 gets deleted with 'arabicshape') + -- If we would increase the schar_t size, say from 32 to 64 bytes, we need to extend the + -- test text with even more zalgo energy to still touch this edge case. + + meths.buf_set_lines(0,0,-1,true, {"سلام့̀́̂̃̄̅̆̇̈̉̊̋̌"}) + command('set noarabicshape') + + screen:expect{grid=[[ + ^سلام့̀́̂̃̄̅̆̇̈̉̊̋̌ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + command('set arabicshape') + screen:expect{grid=[[ + ^ﺱﻼﻣ̀́̂̃̄̅̆̇̈̉̊̋̌ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('multibyte rendering: statusline', function() diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 0dd1f0325c..7b93b74eac 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -225,8 +225,8 @@ describe("shell command :!", function() å | ref: å̲ | 1: å̲ | - 2: å ̲ | - 3: å ̲ | + 2: å ̲ | + 3: å ̲ | | {3:Press ENTER or type command to continue}^ | ]]) -- cgit From c4afb9788c4f139eb2e3b7aa4d6a6a20b67ba156 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 11 Nov 2023 00:52:50 +0100 Subject: refactor(sign): move legacy signs to extmarks Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs. --- test/functional/ui/decorations_spec.lua | 28 ++++++++++++++-------------- test/functional/ui/sign_spec.lua | 6 +++--- test/functional/ui/statuscolumn_spec.lua | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9c16f76359..b3b3128fdd 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -4680,7 +4680,7 @@ l5 screen:expect{grid=[[ {1: }^l1 | - S2S1l2 | + S1S2l2 | {1: }l3 | {1: }l4 | {1: }l5 | @@ -4720,7 +4720,7 @@ l5 screen:expect{grid=[[ {1: }^l1 | S1{1: }l2 | - S2S1l3 | + S1S2l3 | S2{1: }l4 | {1: }l5 | {1: } | @@ -4765,7 +4765,7 @@ l5 meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ - S4S1^l1 | + S1S4^l1 | x S2l2 | S5{1: }l3 | {1: }l4 | @@ -4792,9 +4792,9 @@ l5 meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ - S3S4S1^l1 | + S1S3S4^l1 | x S2S3l2 | - S5S3{1: }l3 | + S3S5{1: }l3 | S3{1: }l4 | S3{1: }l5 | {1: } | @@ -4848,15 +4848,15 @@ l5 end screen:expect{grid=[[ - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - X Y Z W {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:^h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:^h} | | ]]} end) diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 7dcd4cff25..31b54ce0a2 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -274,9 +274,9 @@ describe('Signs', function() -- Line 3 checks that with a limit over the maximum number -- of signs, the ones with the highest Ids are being picked, -- and presented by their sorted Id order. - command('sign place 4 line=3 name=pietSearch buffer=1') - command('sign place 5 line=3 name=pietWarn buffer=1') - command('sign place 3 line=3 name=pietError buffer=1') + command('sign place 6 line=3 name=pietSearch buffer=1') + command('sign place 7 line=3 name=pietWarn buffer=1') + command('sign place 5 line=3 name=pietError buffer=1') screen:expect([[ {1:>>}{8:XX}{6: 1 }a | {8:XX}{1:>>}{6: 2 }b | diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 9f00c7a5d6..61f6419f8c 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -377,6 +377,7 @@ describe('statuscolumn', function() | ]]) command('set breakindent') + command('sign unplace 2') feed('J2gjg0') screen:expect([[ {2: }{4: 0│}{1:>>}{2: }{4: }{5:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| -- cgit From 91ef26dece6d34dbb6e1b5722ce2d3f6f7e3a6de Mon Sep 17 00:00:00 2001 From: "Bara C. Tudor" Date: Wed, 22 Nov 2023 03:50:28 +0200 Subject: fix(messages): :map output with ext_messages (#26126) --- test/functional/ui/messages_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 215e763fd1..a4f13aebc2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -834,6 +834,19 @@ stack traceback: end} end) + it('supports multiline messages for :map', function() + command('mapclear') + command('nmap Y y$') + command('nmap Q @@') + command('nnoremap j k') + feed(':map') + + screen:expect{messages={{ + content = {{ "\nn Q @@\nn Y y$\nn j " }, { "*", 5 }, { " k" }}, + kind = '' + }}} + end) + it('wildmode=list', function() screen:try_resize(25, 7) screen:set_option('ext_popupmenu', false) -- cgit From 0b38fe4dbb77c15ae6f5779174855acab25fc86c Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 8 Mar 2023 15:18:02 +0100 Subject: refactor(decorations): break up Decoration struct into smaller pieces Remove the monolithic Decoration struct. Before this change, each extmark could either represent just a hl_id + priority value as a inline decoration, or it would take a pointer to this monolitic 112 byte struct which has to be allocated. This change separates the decorations into two pieces: DecorSignHighlight for signs, highlights and simple set-flag decorations (like spell, ui-watched), and DecorVirtText for virtual text and lines. The main separation here is whether they are expected to allocate more memory. Currently this is not really true as sign text has to be an allocated string, but the plan is to get rid of this eventually (it can just be an array of two schar_T:s). Further refactors are expected to improve the representation of each decoration kind individually. The goal of this particular PR is to get things started by cutting the Gordian knot which was the monolithic struct Decoration. Now, each extmark can either contain chained indicies/pointers to these kinds of objects, or it can fit a subset of DecorSignHighlight inline. The point of this change is not only to make decorations smaller in memory. In fact, the main motivation is to later allow them to grow _larger_, but on a dynamic, on demand fashion. As a simple example, it would be possible to augment highlights to take a list of multiple `hl_group`:s, which then would trivially map to a chain of multiple DecorSignHighlight entries. One small feature improvement included with this refactor itself, is that the restriction that extmarks cannot be removed inside a decoration provider has been lifted. These are instead safely lifetime extended on a "to free" list until the current iteration of screen drawing is done. NB: flags is a mess. but DecorLevel is useless, this slightly less so --- test/functional/ui/bufhl_spec.lua | 3 --- test/functional/ui/decorations_spec.lua | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 5263fb4c24..81e514c9aa 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -762,8 +762,6 @@ describe('Buffer highlighting', function() local s1 = {{'Köttbullar', 'Comment'}, {'Kräuterbutter'}} local s2 = {{'こんにちは', 'Comment'}} - -- TODO: only a virtual text from the same ns currently overrides - -- an existing virtual text. We might add a prioritation system. set_virtual_text(id1, 0, s1, {}) eq({{1, 0, 0, { ns_id = 1, @@ -775,7 +773,6 @@ describe('Buffer highlighting', function() virt_text_hide = false, }}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true})) - -- TODO: is this really valid? shouldn't the max be line_count()-1? local lastline = line_count() set_virtual_text(id1, line_count(), s2, {}) eq({{3, lastline, 0, { diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index b3b3128fdd..59a41a6de6 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -663,7 +663,7 @@ describe('decorations providers', function() ]]) end) - it('does not allow removing extmarks during on_line callbacks', function() + it('does allow removing extmarks during on_line callbacks', function() exec_lua([[ eok = true ]]) @@ -676,7 +676,7 @@ describe('decorations providers', function() end ]]) exec_lua([[ - assert(eok == false) + assert(eok == true) ]]) end) -- cgit From fba17d5b882e2903ba7a40eabc6f557e3cf24658 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 22 Nov 2023 11:30:36 +0100 Subject: fix(decorations): fix imbalanced sign count --- test/functional/ui/decorations_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 59a41a6de6..9853f05cf2 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -4628,6 +4628,27 @@ l5 end) + it('can add a single sign and text highlight', function() + insert(example_test3) + feed 'gg' + + meths.buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1}) + screen:expect{grid=[[ + {1: }^l1 | + S {3:l}2 | + {1: }l3 | + {1: }l4 | + {1: }l5 | + {1: } | + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]} + + meths.buf_clear_namespace(0, ns, 0, -1) + end) + it('can add multiple signs (single extmark)', function() insert(example_test3) feed 'gg' -- cgit From c126a3756a09716ed64fd2acb9eee5d411c4aa7b Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 23 Nov 2023 12:58:17 +0100 Subject: fix(column): apply numhl signs when 'signcolumn' is "no" (#26167) --- test/functional/ui/sign_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 31b54ce0a2..adab184a4c 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -685,4 +685,21 @@ describe('Signs', function() | ]]) end) + + it('numhl highlight is applied when signcolumn=no', function() + screen:try_resize(screen._width, 4) + command([[ + set nu scl=no + call setline(1, ['line1', 'line2', 'line3']) + call nvim_buf_set_extmark(0, nvim_create_namespace('test'), 0, 0, {'number_hl_group':'Error'}) + call sign_define('foo', { 'text':'F', 'numhl':'Error' }) + call sign_place(0, '', 'foo', bufnr(''), { 'lnum':2 }) + ]]) + screen:expect([[ + {8: 1 }^line1 | + {8: 2 }line2 | + {6: 3 }line3 | + | + ]]) + end) end) -- cgit From b514edcdf4747b2ebf00a97f89f310d6d4f090f5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 23 Nov 2023 23:05:52 +0800 Subject: test: remove the pipe created by new_pipename() (#26173) --- test/functional/ui/embed_spec.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index e59a95c325..9729f65355 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -144,7 +144,6 @@ describe('--embed --listen UI', function() helpers.skip(helpers.is_os('win')) clear() local child_server = assert(helpers.new_pipename()) - uv.fs_unlink(child_server) funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean'}) retry(nil, nil, function() neq(nil, uv.fs_stat(child_server)) end) -- cgit From df399ea0d20e86027d0b59ca4bbd445c1d035a67 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 23 Nov 2023 16:23:26 +0100 Subject: fix(column): reset decor state before starting from top --- test/functional/ui/statuscolumn_spec.lua | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 61f6419f8c..dd11fa7c15 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -46,22 +46,17 @@ describe('statuscolumn', function() end) it("widens with irregular 'statuscolumn' width", function() - command([[set stc=%{v:relnum?v:relnum:(v:lnum==5?'bbbbb':v:lnum)}]]) - command('norm 5G | redraw!') - screen:expect([[ - 1 aaaaa | + screen:try_resize(screen._width, 4) + command([=[ + set stc=%{v:relnum?v:relnum:(v:lnum==5?'bbbbb':v:lnum)} + let ns = nvim_create_namespace('') + call nvim_buf_set_extmark(0, ns, 3, 0, {'virt_text':[['virt_text']]}) + norm 5G | redraw! + ]=]) + screen:expect([[ + 1 aaaaa virt_text | bbbbba^eaaa | 1 aaaaa | - 2 aaaaa | - 3 aaaaa | - 4 aaaaa | - 5 aaaaa | - 6 aaaaa | - 7 aaaaa | - 8 aaaaa | - 9 aaaaa | - 10 aaaaa | - 11 aaaaa | | ]]) end) -- cgit From a8a93e517f9eb988ee86170d9a77382637dd24a3 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 24 Nov 2023 02:15:50 +0100 Subject: fix(mouse): avoid dragging after click label popupmenu callback (#26187) --- test/functional/ui/statuscolumn_spec.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index dd11fa7c15..73039701cd 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -589,6 +589,33 @@ describe('statuscolumn', function() meths.input_mouse('left', 'press', '', 0, 7, 7) eq('0 1 l 11', eval("g:testvar")) end) + + it('selecting popupmenu does not drag mouse', function() + screen:try_resize(screen._width, 2) + screen:set_default_attr_ids({ + [0] = {foreground = Screen.colors.Brown}, + [1] = {background = Screen.colors.Plum1}, + }) + meths.set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {}) + exec([[ + function! MyClickFunc(minwid, clicks, button, mods) + let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) + menu PopupStc.Echo echo g:testvar + popup PopupStc + endfunction + ]]) + meths.input_mouse('left', 'press', '', 0, 0, 0) + screen:expect([[ + {0:8 }^aaaaa | + {1: Echo } | + ]]) + meths.input_mouse('left', 'press', '', 0, 1, 5) + meths.input_mouse('left', 'release', '', 0, 1, 5) + screen:expect([[ + {0:8 }^aaaaa | + 0 1 l 8 | + ]]) + end) end) end -- cgit From 55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Nov 2023 10:44:19 +0800 Subject: fix(messages): validate msg_grid before using msg_grid_pos (#26189) --- test/functional/ui/messages_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a4f13aebc2..1d11a12af4 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1402,6 +1402,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]) eq(1, meths.get_option_value('cmdheight', {})) end) + + it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() + command([[au VimResized * lua vim.api.nvim_echo({ { '123456' } }, true, {})]]) + screen:try_resize(60, 5) + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + eq({ mode = 'n', blocking = false }, meths.get_mode()) + end) end) it('calling screenstring() after redrawing between messages without UI #20999', function() -- cgit From 6a2a37b1e102394d99b4891dc9807868f0fa3c97 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Sat, 25 Nov 2023 00:10:19 +0100 Subject: fix(mouse): avoid dragging when clicking next to popupmenu (#26201) --- test/functional/ui/statuscolumn_spec.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 73039701cd..6eaf15cfad 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -590,7 +590,7 @@ describe('statuscolumn', function() eq('0 1 l 11', eval("g:testvar")) end) - it('selecting popupmenu does not drag mouse', function() + it('popupmenu callback does not drag mouse on close', function() screen:try_resize(screen._width, 2) screen:set_default_attr_ids({ [0] = {foreground = Screen.colors.Brown}, @@ -604,6 +604,7 @@ describe('statuscolumn', function() popup PopupStc endfunction ]]) + -- clicking an item does not drag mouse meths.input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {0:8 }^aaaaa | @@ -615,6 +616,19 @@ describe('statuscolumn', function() {0:8 }^aaaaa | 0 1 l 8 | ]]) + command('echo') + -- clicking outside to close the menu does not drag mouse + meths.input_mouse('left', 'press', '', 0, 0, 0) + screen:expect([[ + {0:8 }^aaaaa | + {1: Echo } | + ]]) + meths.input_mouse('left', 'press', '', 0, 0, 10) + meths.input_mouse('left', 'release', '', 0, 0, 10) + screen:expect([[ + {0:8 }^aaaaa | + | + ]]) end) end) end -- cgit From ae3685798deaf51f14422c568998998c03f91f2c Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 26 Nov 2023 21:07:29 +0100 Subject: feat(decoration): allow conceal_char to be a composing char decor->text.str pointer must go. This removes it for conceal char, in preparation for a larger PR which will also handle the sign case. By actually allowing composing chars for a conceal chars, this becomes a feature and not just a refactor, as a bonus. --- test/functional/ui/decorations_spec.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 9853f05cf2..ef02f73960 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -13,6 +13,7 @@ local curbufmeths = helpers.curbufmeths local command = helpers.command local eq = helpers.eq local assert_alive = helpers.assert_alive +local pcall_err = helpers.pcall_err describe('decorations providers', function() local screen @@ -1650,6 +1651,34 @@ describe('extmark decorations', function() ]]) command('set conceallevel=1') screen:expect_unchanged() + + eq("conceal char has to be printable", pcall_err(meths.buf_set_extmark, 0, ns, 0, 0, {end_col=0, end_row=2, conceal='\255'})) + end) + + it('conceal with composed conceal char', function() + screen:try_resize(50, 5) + insert('foo\n') + meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'}) + command('set conceallevel=2') + screen:expect([[ + {26:ẍ̲} | + ^ | + {1:~ }| + {1:~ }| + | + ]]) + command('set conceallevel=1') + screen:expect_unchanged() + + -- this is rare, but could happen. Save at least the first codepoint + meths._invalidate_glyph_cache() + screen:expect{grid=[[ + {26:x} | + ^ | + {1:~ }| + {1:~ }| + | + ]]} end) it('conceal without conceal char #24782', function() -- cgit From 35cec0de4acd351119230330f54b0a45f9823695 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Mon, 27 Nov 2023 16:22:19 +0100 Subject: fix(column): redraw and update signcols for paired extmark Problem: Signcolumn width does not increase when ranged sign does not start at sentinel line. Solution: Handle paired range of added sign when checking signcols. --- test/functional/ui/decorations_spec.lua | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index ef02f73960..6d4937b0c0 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -4718,21 +4718,19 @@ l5 {2:~ }| | ]]} - end) it('can add multiple signs (multiple extmarks) 2', function() insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) - + meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S1'}) + meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3}) screen:expect{grid=[[ {1: }^l1 | - S1S2l2 | - {1: }l3 | - {1: }l4 | + S2{1: }l2 | + S2{1: }l3 | + S1S2l4 | {1: }l5 | {1: } | {2:~ }| @@ -4740,23 +4738,6 @@ l5 {2:~ }| | ]]} - - -- TODO(lewis6991): Support ranged signs - -- meths.buf_set_extmark(1, ns, 1, -1, {sign_text='S3', end_row = 2}) - - -- screen:expect{grid=[[ - -- {1: }^l1 | - -- S3S2S1l2 | - -- S3{1: }l3 | - -- {1: }l4 | - -- {1: }l5 | - -- {1: } | - -- {2:~ }| - -- {2:~ }| - -- {2:~ }| - -- | - -- ]]} - end) it('can add multiple signs (multiple extmarks) 3', function() -- cgit From a0e9ef09d7af8274c754ca6c368ef4a6f7411510 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 29 Nov 2023 02:17:16 +0100 Subject: fix(decorations): do not apply sign highlight id as range attr id --- test/functional/ui/decorations_spec.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test/functional/ui') diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6d4937b0c0..e8fcfc46fc 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2155,6 +2155,17 @@ describe('extmark decorations', function() | ]]} end) + + it('works with both hl_group and sign_hl_group', function() + screen:try_resize(screen._width, 3) + insert('abcdefghijklmn') + meths.buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14}) + screen:expect{grid=[[ + {1:S }{4:abcdefghijklm^n} | + {1:~ }| + | + ]]} + end) end) describe('decorations: inline virtual text', function() @@ -4966,7 +4977,6 @@ l5 | ]]} end) - end) describe('decorations: virt_text', function() -- cgit From f4001d27efae44c6c07678ad2c72eed5f1a25ea8 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Tue, 28 Nov 2023 05:40:18 +0100 Subject: perf(column): only invalidate lines affected by added sign --- test/functional/ui/sign_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/functional/ui') diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index adab184a4c..b12e79bd42 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -467,6 +467,27 @@ describe('Signs', function() {0:~ }| | ]]) + -- should not increase size because sign with existing id is moved + command('sign place 4 line=1 name=pietSearch buffer=1') + screen:expect_unchanged() + command('sign unplace 4') + screen:expect([[ + {1:>>>>>>}{6: 1 }a | + {2: }{6: 2 }b | + {2: }{6: 3 }c | + {2: }{6: 4 }^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + command('sign place 4 line=1 name=pietSearch buffer=1') -- should keep the column at maximum size when signs are -- exceeding the maximum command('sign place 5 line=1 name=pietSearch buffer=1') -- cgit