neovim/test/functional/ui/wildmode_spec.lua
James McCoy de50c003d5 Use vim_strchr(s, c) when c may be NUL (#6656)
As part of the refactoring in #5119, some vim_strchr() were changed to
strchr().  However, vim_strchr() behaves differently than strchr() when
c is NUL, returning NULL instead of a pointer to the NUL.

Revert the strchr() calls where it isn't known whether c is NUL, since
this causes a semantic change the surrounding code doesn't expect.  In
the case of #6650, this led to a heap overrun.

Closes #6650
2017-05-03 10:12:38 +02:00

88 lines
2.3 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
local funcs = helpers.funcs
if helpers.pending_win32(pending) then return end
describe("'wildmode'", function()
local screen
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach()
end)
after_each(function()
screen:detach()
end)
describe("'wildmenu'", function()
it(':sign <tab> shows wildmenu completions', function()
command('set wildmode=full')
command('set wildmenu')
feed(':sign <tab>')
screen:expect([[
|
~ |
~ |
define jump list > |
:sign define^ |
]])
end)
it('does not crash after cycling back to original text', function()
command('set wildmode=full')
feed(':j<Tab><Tab><Tab>')
screen:expect([[
|
~ |
~ |
join jumps |
:j^ |
]])
-- This would cause nvim to crash before #6650
feed('<BS><Tab>')
screen:expect([[
|
~ |
~ |
! # & < = > @ > |
:!^ |
]])
end)
end)
end)
describe('command line completion', function()
local screen
before_each(function()
clear()
screen = Screen.new(40, 5)
screen:attach()
screen:set_default_attr_ids({[1]={bold=true, foreground=Screen.colors.Blue}})
end)
after_each(function()
os.remove('Xtest-functional-viml-compl-dir')
end)
it('lists directories with empty PATH', function()
local tmp = funcs.tempname()
command('e '.. tmp)
command('cd %:h')
command("call mkdir('Xtest-functional-viml-compl-dir')")
command('let $PATH=""')
feed(':!<tab><bs>')
screen:expect([[
|
{1:~ }|
{1:~ }|
{1:~ }|
:!Xtest-functional-viml-compl-dir^ |
]])
end)
end)