mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 12:08:33 +00:00
fix(man.vim): q in "$MANPAGER mode" does not quit #18443
Problem: q in "$MANPAGER mode" does not quit Nvim. This is because ftplugin/man.vim creates its own mapping: nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c which overrides the one set by the autoload file when using :Man! ("$MANPAGER mode") Solution: Set b:pager during "$MANPAGER mode" so that ftplugin/man.vim can set the mapping correctly. Fixes #18281 Ref #17791 Helped-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
This commit is contained in:
@@ -125,9 +125,7 @@ endfunction
|
|||||||
function! s:set_options(pager) abort
|
function! s:set_options(pager) abort
|
||||||
setlocal noswapfile buftype=nofile bufhidden=hide
|
setlocal noswapfile buftype=nofile bufhidden=hide
|
||||||
setlocal nomodified readonly nomodifiable
|
setlocal nomodified readonly nomodifiable
|
||||||
if a:pager
|
let b:pager = a:pager
|
||||||
nnoremap <silent> <buffer> <nowait> q :lclose<CR>:q<CR>
|
|
||||||
endif
|
|
||||||
setlocal filetype=man
|
setlocal filetype=man
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@@ -24,7 +24,11 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
|
|||||||
nnoremap <silent> <buffer> k gk
|
nnoremap <silent> <buffer> k gk
|
||||||
nnoremap <silent> <buffer> gO :call man#show_toc()<CR>
|
nnoremap <silent> <buffer> gO :call man#show_toc()<CR>
|
||||||
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
|
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
|
||||||
|
if get(b:, 'pager')
|
||||||
|
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>q
|
||||||
|
else
|
||||||
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
|
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'ft_man_folding_enable', 0)
|
if get(g:, 'ft_man_folding_enable', 0)
|
||||||
|
@@ -2,13 +2,19 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local command, eval, rawfeed = helpers.command, helpers.eval, helpers.rawfeed
|
local command, eval, rawfeed = helpers.command, helpers.eval, helpers.rawfeed
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
|
local funcs = helpers.funcs
|
||||||
|
local nvim_prog = helpers.nvim_prog
|
||||||
|
local matches = helpers.matches
|
||||||
|
|
||||||
describe(':Man', function()
|
describe(':Man', function()
|
||||||
|
before_each(function()
|
||||||
|
clear()
|
||||||
|
end)
|
||||||
|
|
||||||
describe('man.lua: highlight_line()', function()
|
describe('man.lua: highlight_line()', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
|
||||||
command('syntax on')
|
command('syntax on')
|
||||||
command('set filetype=man')
|
command('set filetype=man')
|
||||||
command('syntax off') -- Ignore syntax groups
|
command('syntax off') -- Ignore syntax groups
|
||||||
@@ -137,4 +143,10 @@ describe(':Man', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('q quits in "$MANPAGER mode" (:Man!) #18281', function()
|
||||||
|
-- This will hang if #18281 regresses.
|
||||||
|
local args = {nvim_prog, '--headless', '+autocmd VimLeave * echo "quit works!!"', '+Man!', '+call nvim_input("q")'}
|
||||||
|
matches('quit works!!', funcs.system(args, {'manpage contents'}))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user