Skip to content

Commit

Permalink
fix(dirman): corrected win width and height calculation
Browse files Browse the repository at this point in the history
- Use `vim.fn.winheight` ,`vim.fn.winwidth` instead of `vim.opt_local.lines:get()`
  and `vim.opt_local.columns:get()` to calculate the correct window size.
- Note that `vim.opt_local.{cols,lines}` don't take account split panes and
  extra spaces such as `winbar`, `statusline` and `cmdheight`
  • Loading branch information
amuuname authored and vhyrro committed Feb 11, 2023
1 parent 6350254 commit 9766bef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lua/neorg/modules/core/ui/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ module.public = {
get_window_size = function(half)
return half
and {
math.floor(vim.opt_local.columns:get() / 2),
math.floor(vim.opt_local.lines:get() / 2),
math.floor(vim.fn.winwidth(0) / 2),
math.floor(vim.fn.winheight(0) / 2),
}
or { vim.opt_local.columns:get(), vim.opt_local.lines:get() }
or { vim.fn.winwidth(0), vim.fn.winheight(0) }
end,

--- Returns a modified version of floating window options.
Expand Down

0 comments on commit 9766bef

Please sign in to comment.