Skip to content

Commit

Permalink
chore: this doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jun 29, 2024
1 parent 12689e2 commit 452611d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
7 changes: 3 additions & 4 deletions lua/no-neck-pain/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ end
---@private
function State:computeSplits(focusedWin)
local side = self.getSideID(self, "left") or self.getSideID(self, "right")
local sWidth, sHeight = 0, 0
local sWidth, sHeight = vim.o.columns, vim.o.lines

-- when side buffer exists we rely on them, otherwise we fallback to the UI
if side ~= nil then
Expand All @@ -587,11 +587,10 @@ function State:computeSplits(focusedWin)

sWidth, sHeight = A.getWidthAndHeight(side)
sWidth = vim.o.columns - sWidth * nbSide
else
sWidth = vim.o.columns
sHeight = vim.o.lines
end

vim.print(sWidth, sHeight, vim.o.columns, vim.api.nvim_list_uis()[1].width, vim.o.lines, vim.api.nvim_list_uis()[1].height)

local fWidth, fHeight = A.getWidthAndHeight(focusedWin)
local isVSplit = true

Expand Down
14 changes: 7 additions & 7 deletions tests/test_autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ T["auto command"]["does not shift when opening/closing float window"] = function
right = 1002,
})

Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 75)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 75)

child.api.nvim_open_win(
0,
true,
{ width = 100, height = 100, relative = "cursor", row = 0, col = 0 }
{ width = 10, height = 10, relative = "cursor", row = 0, col = 0 }
)

Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1000, 1002, 1003 })
Expand All @@ -65,8 +65,8 @@ T["auto command"]["does not shift when opening/closing float window"] = function
right = 1002,
})

Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 75)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 75)

-- Close float window keeps the buffer here with the same width
child.fn.win_gotoid(1003)
Expand All @@ -79,8 +79,8 @@ T["auto command"]["does not shift when opening/closing float window"] = function
right = 1002,
})

Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 75)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 75)
end

T["skipEnteringNoNeckPainBuffer"] = MiniTest.new_set()
Expand Down
13 changes: 6 additions & 7 deletions tests/test_splits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ T["split"]["keeps side buffers"] = function()
child.cmd("q")

Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1000, 1002 })
Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 15)
Helpers.expect.buf_width(child, "tabs[1].wins.main.left", 75)
Helpers.expect.buf_width(child, "tabs[1].wins.main.right", 75)
end

T["split"]["keeps correct focus"] = function()
Expand Down Expand Up @@ -135,15 +135,14 @@ T["vsplit"]["corretly size splits when opening helper with side buffers open"] =
Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1003, 1000, 1002 })

Helpers.expect.buf_width(child, "tabs[1].wins.splits[1003].id", 50)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 67)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 47)

child.cmd("h")
child.loop.sleep(50)

Helpers.expect.equality(Helpers.winsInTab(child), { 1004, 1001, 1003, 1000, 1002 })

Helpers.expect.buf_width(child, "tabs[1].wins.splits[1004].id", 150)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 67)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 47)
end

T["vsplit"]["correctly position side buffers when there's enough space"] = function()
Expand All @@ -170,7 +169,7 @@ T["vsplit"]["preserve vsplit width when having side buffers"] = function()

Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1002, 1000 })

Helpers.expect.buf_width(child, "tabs[1].wins.splits[1002].id", 65)
Helpers.expect.buf_width(child, "tabs[1].wins.splits[1002].id", 150)
end

T["vsplit"]["closing `curr` makes `split` the new `curr`"] = function()
Expand Down Expand Up @@ -363,7 +362,7 @@ T["vsplit/split"]["splits and vsplits keeps a correct size"] = function()

Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1003, 1000, 1002 })
Helpers.expect.equality(Helpers.currentWin(child), 1003)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 468)
Helpers.expect.buf_width(child, "tabs[1].wins.main.curr", 48)

child.cmd("vsplit")
vim.loop.sleep(50)
Expand Down

0 comments on commit 452611d

Please sign in to comment.