neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 209ed16f57a73518296c3dce0a1ef3975181318d
parent fa1baa9a47cdb3eed17d48b6011a164d4009d2ee
Author: Vadim A. Misbakh-Soloviov <msva@users.noreply.github.com>
Date:   Fri,  5 May 2023 11:15:39 +0700

fix(man.lua): return support of all sections

Current behaviour of `:Man` is to only work with "number" sections.
This is caused by wrong assumptions about man sections naming.

Also, there was similar assumption about length of section dirs
in `paths` variable.

fixes #23485

Signed-off-by: Vadim Misbakh-Soloviov <git@mva.name>

Diffstat:
Mruntime/lua/man.lua | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua @@ -583,7 +583,7 @@ local function get_paths(sect, name) local mandirs = table.concat(vim.split(mandirs_raw, '[:\n]', { trimempty = true }), ',') ---@type string[] - local paths = fn.globpath(mandirs, 'man?/' .. name .. '*.' .. sect .. '*', false, true) + local paths = fn.globpath(mandirs, 'man[^\\/]*/' .. name .. '*.' .. sect .. '*', false, true) -- Prioritize the result from find_path as it obeys b:man_default_sects. local first = M.find_path(sect, name) @@ -739,7 +739,12 @@ function M.open_page(count, smods, args) else -- Combine the name and sect into a manpage reference so that all -- verification/extraction can be kept in a single function. - if tonumber(args[1]) then + if args[1]:match('^%d$') or args[1]:match('^%d%a') or args[1]:match('^%a$') then + -- NB: Valid sections are not only digits, but also: + -- - <digit><word> (see POSIX mans), + -- - and even <letter> and <word> (see, for example, by tcl/tk) + -- NB2: don't optimize to :match("^%d"), as it will match manpages like + -- 441toppm and others whose name starts with digit local sect = args[1] table.remove(args, 1) local name = table.concat(args, ' ')