mirror of
https://github.com/neovim/neovim.git
synced 2026-07-10 11:29:39 +00:00
fix(ui2): "msg_history_show" error while in cmdwin
Problem:
Executing :messages while in cmdwin fails:
Error in "msg_history_show" UI event handler (ns=nvim.ui2):
Lua: …/_core/ui2/messages.lua:699: Invalid 'height': expected positive Integer
stack traceback:
[C]: in function 'nvim_win_set_config'
…/_core/ui2/messages.lua:699: in function 'set_pos'
…/_core/ui2/messages.lua:329: in function 'set_target_pos'
…/_core/ui2/messages.lua:389: in function 'show_msg'
…/_core/ui2/messages.lua:553: in function 'handler'
…/_core/ui2.lua:161: in function 'ui_callback'
…/_core/ui2.lua:210: in function <…/_core/ui2.lua:202>
The bug: when `texth.all` is small (e.g. 0 from a hidden pager whose new
content isn't laid out yet), or when the available height after
subtracting the cmdwin is small, `math.min(min, …)` can yield 0, and
`nvim_win_set_config` rejects `height=0`.
Solution:
Floor at 1.
This commit is contained in:
@@ -624,13 +624,16 @@ local function win_row_height_border(tgt, min)
|
||||
local cfgmin = ui.cfg.msg[tgt].height --[[@as number]]
|
||||
min = math.min(min, cfgmin < 1 and math.ceil(o.lines * cfgmin) or cfgmin)
|
||||
if tgt ~= 'pager' then
|
||||
return (tgt == 'msg' and 0 or 1) - ui.cmd.wmnumode, min, min < o.lines - ui.cmdheight
|
||||
return (tgt == 'msg' and 0 or 1) - ui.cmd.wmnumode,
|
||||
math.max(1, min),
|
||||
min < o.lines - ui.cmdheight
|
||||
end
|
||||
local cmdwin = fn.getcmdwintype() ~= was_cmdwin and api.nvim_win_get_height(0) or 0
|
||||
local global_stl = (cmdwin > 0 or o.laststatus == 3) and 1 or 0
|
||||
local row = 1 - cmdwin - global_stl
|
||||
local top = min < o.lines - ui.cmdheight - global_stl - cmdwin
|
||||
return row, math.min(min, o.lines - (top and 1 or 0) - ui.cmdheight - global_stl - cmdwin), top
|
||||
local height = math.min(min, o.lines - (top and 1 or 0) - ui.cmdheight - global_stl - cmdwin)
|
||||
return row, math.max(1, height), top
|
||||
end
|
||||
|
||||
local function enter_pager()
|
||||
|
||||
Reference in New Issue
Block a user