Skip to content

Commit 2ca9857

Browse files
fix: 'Invalid window id ...' error when restoring a session saved with an invisible Scratch Window (#430) (#431)
## 📃 Summary Please see #430 closes #430 ## 📸 Preview none --------- Co-authored-by: shortcuts <vannicattec@gmail.com>
1 parent 6aaa6e3 commit 2ca9857

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lua/no-neck-pain/ui.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ function ui.create_side_buffers()
158158
else
159159
ui.init_side_options(side, state.get_side_id(state, side))
160160
end
161-
end
162161

163-
colors.init(state.get_side_id(state, side), side)
162+
colors.init(state.get_side_id(state, side), side)
163+
end
164164
end
165165
end
166166

scripts/init_auto_open.lua

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ vim.cmd("set rtp+=deps/mini.nvim")
55
-- Auto open enabled for the test
66
require("no-neck-pain").setup({
77
width = 50,
8+
minSideBufferWidth = 5,
89
autocmds = { enableOnVimEnter = true, enableOnTabEnter = true },
10+
buffers = { colors = { background = "tokyonight-moon" } },
911
})
1012
require("mini.test").setup()

tests/test_colors.lua

+27
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,33 @@ T["setup"]["`left` or `right` buffer options overrides `common` ones"] = functio
109109
})
110110
end
111111

112+
T["setup"]["does not throw on invalid windows"] = function()
113+
child.restart({ "-u", "scripts/init_auto_open.lua" })
114+
child.set_size(80, 80)
115+
child.wait()
116+
117+
Helpers.expect.equality(child.get_wins_in_tab(), { 1001, 1000, 1002 })
118+
Helpers.expect.state(child, "tabs[1].wins.main", { curr = 1000, left = 1001, right = 1002 })
119+
120+
child.cmd("e aaa.txt")
121+
child.cmd("vnew aaa.txt")
122+
child.cmd("mksession! deps/mk.vim")
123+
124+
Helpers.expect.equality(child.get_wins_in_tab(), { 1001, 1003, 1000, 1002 })
125+
Helpers.expect.state(child, "tabs[1].wins.main", { curr = 1000, left = 1001, right = 1002 })
126+
127+
child.restart({ "-u", "scripts/init_auto_open.lua" })
128+
child.wait()
129+
130+
Helpers.expect.equality(child.get_wins_in_tab(), { 1001, 1000, 1002 })
131+
132+
child.cmd("source deps/mk.vim")
133+
child.wait()
134+
135+
Helpers.expect.equality(child.get_wins_in_tab(), { 1000, 1003, 1004, 1005 })
136+
Helpers.expect.state(child, "tabs[1].wins.main", { curr = 1000, left = 1001, right = 1002 })
137+
end
138+
112139
T["setup"]["`common` options spreads it to `left` and `right` buffers"] = function()
113140
child.cmd([[colorscheme peachpuff]])
114141
child.lua([[

0 commit comments

Comments
 (0)