From 452611de9c68725c59a90f9ba8a1fea5a1850e56 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Sat, 29 Jun 2024 23:05:08 +0200 Subject: [PATCH] chore: this doesn't work --- lua/no-neck-pain/state.lua | 7 +++---- tests/test_autocmds.lua | 14 +++++++------- tests/test_splits.lua | 13 ++++++------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lua/no-neck-pain/state.lua b/lua/no-neck-pain/state.lua index 3009910..ec0a264 100644 --- a/lua/no-neck-pain/state.lua +++ b/lua/no-neck-pain/state.lua @@ -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 @@ -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 diff --git a/tests/test_autocmds.lua b/tests/test_autocmds.lua index 3b3ad1f..6180990 100644 --- a/tests/test_autocmds.lua +++ b/tests/test_autocmds.lua @@ -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 }) @@ -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) @@ -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() diff --git a/tests/test_splits.lua b/tests/test_splits.lua index 1fa92b2..63bde64 100644 --- a/tests/test_splits.lua +++ b/tests/test_splits.lua @@ -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() @@ -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() @@ -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() @@ -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)