mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
fix(extui): reposition "more" window after entering cmdwin
Problem: Closing the "more" window for an entered cmdwin in ff95d7ff9
still requires special casing to properly handle "more" visibility.
Solution: Reposition the "more" window instead; anchoring it to the
cmdwin.
This commit is contained in:
@@ -433,13 +433,14 @@ function M.set_pos(type)
|
|||||||
local function win_set_pos(win)
|
local function win_set_pos(win)
|
||||||
local texth = type and api.nvim_win_text_height(win, {}) or 0
|
local texth = type and api.nvim_win_text_height(win, {}) or 0
|
||||||
local height = type and math.min(texth.all, math.ceil(o.lines * 0.5))
|
local height = type and math.min(texth.all, math.ceil(o.lines * 0.5))
|
||||||
api.nvim_win_set_config(win, {
|
local config = {
|
||||||
hide = false,
|
hide = false,
|
||||||
relative = 'laststatus',
|
relative = 'laststatus',
|
||||||
height = height,
|
height = height,
|
||||||
row = win == ext.wins[ext.tab].box and 0 or 1,
|
row = win == ext.wins[ext.tab].box and 0 or 1,
|
||||||
col = 10000,
|
col = 10000,
|
||||||
})
|
}
|
||||||
|
api.nvim_win_set_config(win, config)
|
||||||
if type == 'box' then
|
if type == 'box' then
|
||||||
-- Ensure last line is visible and first line is at top of window.
|
-- Ensure last line is visible and first line is at top of window.
|
||||||
local row = (texth.all > height and texth.end_row or 0) + 1
|
local row = (texth.all > height and texth.end_row or 0) + 1
|
||||||
@@ -454,12 +455,18 @@ function M.set_pos(type)
|
|||||||
-- It's actually closed one event iteration later so schedule in case it was open.
|
-- It's actually closed one event iteration later so schedule in case it was open.
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
api.nvim_set_current_win(win)
|
api.nvim_set_current_win(win)
|
||||||
api.nvim_create_autocmd('WinLeave', {
|
api.nvim_create_autocmd({ 'WinEnter', 'CmdwinEnter', 'CmdwinLeave' }, {
|
||||||
once = true,
|
callback = function(ev)
|
||||||
callback = function()
|
if ev.event == 'CmdwinEnter' then
|
||||||
|
api.nvim_win_set_config(win, { relative = 'win', win = 0, row = 0, col = 0 })
|
||||||
|
elseif ev.event == 'CmdwinLeave' then
|
||||||
|
api.nvim_win_set_config(win, config)
|
||||||
|
else
|
||||||
if api.nvim_win_is_valid(win) then
|
if api.nvim_win_is_valid(win) then
|
||||||
api.nvim_win_set_config(win, { hide = true })
|
api.nvim_win_set_config(win, { hide = true })
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
desc = 'Hide inactive "more" window.',
|
desc = 'Hide inactive "more" window.',
|
||||||
})
|
})
|
||||||
|
@@ -65,7 +65,7 @@ function M.tab_check_wins()
|
|||||||
anchor = type ~= 'cmd' and 'SE' or nil,
|
anchor = type ~= 'cmd' and 'SE' or nil,
|
||||||
hide = type ~= 'cmd' or M.cmdheight == 0 or nil,
|
hide = type ~= 'cmd' or M.cmdheight == 0 or nil,
|
||||||
title = type == 'more' and 'Messages' or nil,
|
title = type == 'more' and 'Messages' or nil,
|
||||||
border = type == 'box' and not o.termguicolors and 'single' or border or 'none',
|
border = type == 'box' and 'single' or border or 'none',
|
||||||
-- kZIndexMessages < zindex < kZIndexCmdlinePopupMenu (grid_defs.h), 'more' below others.
|
-- kZIndexMessages < zindex < kZIndexCmdlinePopupMenu (grid_defs.h), 'more' below others.
|
||||||
zindex = 200 - (type == 'more' and 1 or 0),
|
zindex = 200 - (type == 'more' and 1 or 0),
|
||||||
_cmdline_offset = type == 'cmd' and 0 or nil,
|
_cmdline_offset = type == 'cmd' and 0 or nil,
|
||||||
@@ -88,7 +88,7 @@ function M.tab_check_wins()
|
|||||||
api.nvim_set_option_value('smoothscroll', true, { scope = 'local' })
|
api.nvim_set_option_value('smoothscroll', true, { scope = 'local' })
|
||||||
local ft = type == 'cmd' and 'cmdline' or ('msg' .. type)
|
local ft = type == 'cmd' and 'cmdline' or ('msg' .. type)
|
||||||
api.nvim_set_option_value('filetype', ft, { scope = 'local' })
|
api.nvim_set_option_value('filetype', ft, { scope = 'local' })
|
||||||
local ignore = 'all' .. (type == 'more' and ',-WinLeave,-TextYankPost' or '')
|
local ignore = 'all' .. (type == 'more' and ',-TextYankPost' or '')
|
||||||
api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' })
|
api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' })
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user