Skip to content

Commit

Permalink
Check window width and height for focus_max_or_equal
Browse files Browse the repository at this point in the history
At present it only checks for window width, which works for vertical splits.
However, horizontal splits will not properly maximise since they will always
have the max width, so attempts to focus_max_or_equal will always lead to
focus_equalise.
  • Loading branch information
jerryjrchen committed Jul 16, 2024
1 parent 3841a38 commit 20bbb5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/focus/modules/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ end

M.focus_max_or_equal = function()
local winwidth = vim.fn.winwidth(vim.api.nvim_get_current_win())
if winwidth > vim.o.columns / 2 then
local winheight = vim.fn.winheight(vim.api.nvim_get_current_win())
local bigger_than_half = (winwidth > vim.o.columns / 2) and (winheight > vim.o.lines / 2)
if bigger_than_half then
M.focus_equalise()
else
M.focus_maximise()
Expand Down

0 comments on commit 20bbb5a

Please sign in to comment.