diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
tree | cd08258054db80bb9a11b1061bb091c70b76926a /test/functional/plugin/man_spec.lua | |
parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.gz rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.bz2 rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/plugin/man_spec.lua')
-rw-r--r-- | test/functional/plugin/man_spec.lua | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 58da059be6..815ddbc523 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -8,9 +8,30 @@ local nvim_prog = helpers.nvim_prog local matches = helpers.matches local write_file = helpers.write_file local tmpname = helpers.tmpname +local eq = helpers.eq +local pesc = helpers.pesc local skip = helpers.skip local is_ci = helpers.is_ci +-- Collects all names passed to find_path() after attempting ":Man foo". +local function get_search_history(name) + local args = vim.split(name, ' ') + local code = [[ + local args = ... + local man = require('runtime.lua.man') + local res = {} + man.find_path = function(sect, name) + table.insert(res, {sect, name}) + return nil + end + local ok, rv = pcall(man.open_page, -1, {tab = 0}, args) + assert(not ok) + assert(rv and rv:match('no manual entry')) + return res + ]] + return exec_lua(code, args) +end + clear() if funcs.executable('man') == 0 then pending('missing "man" command', function() end) @@ -169,8 +190,39 @@ describe(':Man', function() write_file(actual_file, '') local args = {nvim_prog, '--headless', '+:Man ' .. actual_file, '+q'} matches(('Error detected while processing command line:\r\n' .. - 'man.lua: "no manual entry for %s"'):format(actual_file), + 'man.lua: "no manual entry for %s"'):format(pesc(actual_file)), funcs.system(args, {''})) os.remove(actual_file) end) + + it('tries variants with spaces, underscores #22503', function() + eq({ + {'', 'NAME WITH SPACES'}, + {'', 'NAME_WITH_SPACES'}, + }, get_search_history('NAME WITH SPACES')) + eq({ + {'3', 'some other man'}, + {'3', 'some_other_man'}, + }, get_search_history('3 some other man')) + eq({ + {'3x', 'some other man'}, + {'3x', 'some_other_man'}, + }, get_search_history('3X some other man')) + eq({ + {'3tcl', 'some other man'}, + {'3tcl', 'some_other_man'}, + }, get_search_history('3tcl some other man')) + eq({ + {'n', 'some other man'}, + {'n', 'some_other_man'}, + }, get_search_history('n some other man')) + eq({ + {'', '123some other man'}, + {'', '123some_other_man'}, + }, get_search_history('123some other man')) + eq({ + {'1', 'other_man'}, + {'1', 'other_man'}, + }, get_search_history('other_man(1)')) + end) end) |