aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/man_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/plugin/man_spec.lua')
-rw-r--r--test/functional/plugin/man_spec.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index 58da059be6..9730bf4bf6 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -8,9 +8,29 @@ 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 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, name)
+ return nil
+ end
+ local ok, rv = pcall(man.open_page, 0, {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)
@@ -173,4 +193,19 @@ describe(':Man', function()
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({
+ 'some other man',
+ 'some_other_man',
+ }, get_search_history('3 some other man'))
+ eq({
+ 'other_man',
+ 'other_man',
+ }, get_search_history('other_man(1)'))
+ end)
end)