2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2022-04-20 06:54:31 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local command = n.command
|
|
|
|
local exec = n.exec
|
|
|
|
local feed = n.feed
|
2022-04-20 06:54:31 -07:00
|
|
|
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
describe("'cursorbind'", function()
|
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=<Esc>` or `wildchar=<C-\>` 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 `<Esc>` 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 `<C-\><C-\><C-N>` it will also exit command-line, but the clean
up code would not have hit because of specialized `<C-\>` 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 `<CR>`. 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 <ychin.git@gmail.com>
2023-10-17 07:43:42 -07:00
|
|
|
-- oldtest: Test_cursorline_cursorbind_horizontal_scroll()
|
2022-04-20 06:54:31 -07:00
|
|
|
it("behaves consistently whether 'cursorline' is set or not vim-patch:8.2.4795", function()
|
|
|
|
local screen = Screen.new(60, 8)
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
|
|
|
[2] = { bold = true, reverse = true }, -- StatusLine
|
|
|
|
[3] = { reverse = true }, -- StatusLineNC
|
|
|
|
[4] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn
|
|
|
|
})
|
|
|
|
exec([[
|
|
|
|
call setline(1, 'aa bb cc dd ee ff gg hh ii jj kk ll mm' ..
|
|
|
|
\ ' nn oo pp qq rr ss tt uu vv ww xx yy zz')
|
|
|
|
set nowrap
|
|
|
|
" The following makes the cursor apparent on the screen dump
|
|
|
|
set sidescroll=1 cursorcolumn
|
|
|
|
" add empty lines, required for cursorcolumn
|
|
|
|
call append(1, ['','','',''])
|
|
|
|
20vsp
|
|
|
|
windo :set cursorbind
|
|
|
|
]])
|
|
|
|
feed('20l')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
a bb cc dd ee ff gg │aa bb cc dd ee ff gg^ hh ii jj kk ll mm |
|
2023-12-09 05:42:00 -07:00
|
|
|
{4: }│ {4: } |*4
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:~ }│{1:~ }|
|
2022-04-20 06:54:31 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('10l')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
hh ii jj kk ll mm n│aa bb cc dd ee ff gg hh ii jj ^kk ll mm |
|
2023-12-09 05:42:00 -07:00
|
|
|
{4: } │ {4: } |*4
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:~ }│{1:~ }|
|
2022-04-20 06:54:31 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
command('windo :set cursorline')
|
|
|
|
feed('0')
|
|
|
|
feed('20l')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4:a bb cc dd ee ff gg }│{4:aa bb cc dd ee ff gg^ hh ii jj kk ll mm }|
|
2023-12-09 05:42:00 -07:00
|
|
|
{4: }│ {4: } |*4
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:~ }│{1:~ }|
|
2022-04-20 06:54:31 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
feed('10l')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
{4: hh ii jj kk ll mm n}│{4:aa bb cc dd ee ff gg hh ii jj ^kk ll mm }|
|
2023-12-09 05:42:00 -07:00
|
|
|
{4: } │ {4: } |*4
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:~ }│{1:~ }|
|
2022-04-20 06:54:31 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]])
|
2022-04-20 15:08:50 -07:00
|
|
|
command('windo :set nocursorline nocursorcolumn')
|
|
|
|
feed('0')
|
|
|
|
feed('40l')
|
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
kk ll mm nn oo pp qq│ bb cc dd ee ff gg hh ii jj kk ll mm n^n|
|
2023-12-09 05:42:00 -07:00
|
|
|
│ |*4
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:~ }│{1:~ }|
|
2022-04-20 15:08:50 -07:00
|
|
|
{3:[No Name] [+] }{2:[No Name] [+] }|
|
|
|
|
|
|
|
|
|
]])
|
2022-04-20 06:54:31 -07:00
|
|
|
end)
|
|
|
|
end)
|