Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(buffers): compute width before creating sides #397

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lua/no-neck-pain/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ end
---@private
function ui.create_side_buffers()
local wins = {
left = { cmd = "topleft vnew", padding = 0 },
right = { cmd = "botright vnew", padding = 0 },
left = { cmd = "topleft vnew", padding = ui.get_side_width("left") },
right = { cmd = "botright vnew", padding = ui.get_side_width("right") },
}

for _, side in pairs(constants.SIDES) do
if _G.NoNeckPain.config.buffers[side].enabled then
wins[side].padding = ui.get_side_width(side)

if
wins[side].padding > _G.NoNeckPain.config.minSideBufferWidth
and not state.is_side_enabled_and_valid(state, side)
Expand Down Expand Up @@ -235,6 +233,7 @@ function ui.get_side_width(side)
occupied = occupied + _G.NoNeckPain.config.width
columns = columns - 1
end

-- then we don't have to create side buffers.
if occupied >= vim.o.columns then
log.debug(scope, "%d/%d - no space left to create side", occupied, vim.o.columns)
Expand Down