Skip to content

Commit

Permalink
fix(view): wrong window position when statusline is not set (#363)
Browse files Browse the repository at this point in the history
* fix: wrong window position when statusline is not set

* fix: properly calculate non-floating windows

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
  • Loading branch information
WilliamHsieh and folke committed Mar 19, 2023
1 parent fb02773 commit e14f8dc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/which-key/view.lua
Expand Up @@ -31,6 +31,12 @@ function M.show()
if M.is_valid() then
return
end

-- non-floating windows
local wins = vim.tbl_filter(function(w)
return vim.api.nvim_win_is_valid(w) and vim.api.nvim_win_get_config(w).relative == ""
end, vim.api.nvim_list_wins())

local opts = {
relative = "editor",
width = vim.o.columns
Expand All @@ -44,6 +50,7 @@ function M.show()
row = vim.o.lines
- config.options.window.margin[3]
- (vim.fn.has("nvim-0.6") == 0 and config.options.window.border ~= "none" and 2 or 0)
+ ((vim.o.laststatus == 0 or vim.o.laststatus == 1 and #wins == 1) and 1 or 0)
- vim.o.cmdheight,
col = config.options.window.margin[2],
style = "minimal",
Expand Down

0 comments on commit e14f8dc

Please sign in to comment.