diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
commit | 21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch) | |
tree | 84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /test/functional/plugin/man_spec.lua | |
parent | d9c904f85a23a496df4eb6be42aa43f007b22d50 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-colorcolchar.tar.gz rneovim-colorcolchar.tar.bz2 rneovim-colorcolchar.zip |
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'test/functional/plugin/man_spec.lua')
-rw-r--r-- | test/functional/plugin/man_spec.lua | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index c6c7d2b03d..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) @@ -59,7 +80,7 @@ describe(':Man', function() screen:expect([[ ^this {b:is} {b:a} test | - with {u:overstruck} text | + with {i:overstruck} text | {eob:~ }| {eob:~ }| | @@ -98,7 +119,7 @@ describe(':Man', function() screen:expect([[ ^this {b:is} {b:あ} test | - with {u:överstrũck} te{i:xt¶} | + with {i:överstrũck} te{i:xt¶} | {eob:~ }| {eob:~ }| | @@ -115,7 +136,7 @@ describe(':Man', function() screen:expect([[ {b:^_begins} | {b:mid_dle} | - {u:mid_dle} | + {i:mid_dle} | {eob:~ }| | ]]) @@ -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) |