aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/man_spec.lua
diff options
context:
space:
mode:
authorEriks Muhins <chad@eriksmuhins.com>2023-03-03 21:44:13 +0200
committerJustin M. Keyes <justinkz@gmail.com>2023-03-07 15:19:24 +0100
commit160a019ffa104eebd65f4037729954d98aca6ad0 (patch)
tree596ded4eb16629ce26eb33f930adb5a57d7fa31b /test/functional/plugin/man_spec.lua
parent7a462c10d522e1b650979e810ad3b137224bb2b0 (diff)
downloadrneovim-160a019ffa104eebd65f4037729954d98aca6ad0.tar.gz
rneovim-160a019ffa104eebd65f4037729954d98aca6ad0.tar.bz2
rneovim-160a019ffa104eebd65f4037729954d98aca6ad0.zip
feat(man.lua): support spaces in manpage names
Problem: :Man command errors if given more than two arguments. Thus, it is impossible to open man pages that contain spaces in their names. Solution: Adjust :Man so that it tries variants with spaces and underscores, and uses the first found.
Diffstat (limited to 'test/functional/plugin/man_spec.lua')
-rw-r--r--test/functional/plugin/man_spec.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index 58da059be6..a1a7274e5d 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -10,6 +10,26 @@ local write_file = helpers.write_file
local tmpname = helpers.tmpname
local skip = helpers.skip
local is_ci = helpers.is_ci
+local table_contains = vim.tbl_contains
+
+-- Returns a table composed of all man page name arguments
+-- that were passed to search_for_path after attempting to
+-- open 'name'.
+local function get_search_history(name)
+ local as_table = string.gsub(name, ' ', '\', \'')
+ as_table = '\'' .. as_table .. '\''
+ local code = ([[
+ local man = require('runtime.lua.man')
+ local res = {}
+ man.attempt_to_get_path = function(sect, name, silent)
+ table.insert(res, name)
+ return nil
+ end
+ pcall(man.open_page, 0, {tab = 0}, {%s})
+ return res
+ ]]):format(as_table)
+ return exec_lua(code)
+end
clear()
if funcs.executable('man') == 0 then
@@ -173,4 +193,10 @@ describe(':Man', function()
funcs.system(args, {''}))
os.remove(actual_file)
end)
+
+ it('searches for manpage name with variants with spaces, underscores', function()
+ local tried = get_search_history('NAME WITH SPACES')
+ table_contains(tried, 'NAME WITH SPACES')
+ table_contains(tried, 'NAME_WITH_SPACES')
+ end)
end)