Skip to content

Commit f1a45ac

Browse files
authored
fix: ensure Border:change_title doesn't error (#256)
I believe this was a regression introduced in 8c6cc07, but currently when you call `Border:change_title` you'll see: ``` E5108: Error executing lua .../packer/start/plenary.nvim/lua/plenary/window/border.lua:57: attempt to in dex local 'thickness' (a nil value) ``` This is because after `Border:__align_calc_config` is called, the new `border_win_options` were never actually updated in the metatable. This ensure that after the table is merged that it's correctly updated so that when `Border:change_title` is called, it still has the correct reference to these.
1 parent 239c16d commit f1a45ac

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lua/plenary/window/border.lua

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local tbl = require "plenary.tbl"
21
local strings = require "plenary.strings"
32

43
local Border = {}
@@ -190,8 +189,11 @@ function Border:__align_calc_config(content_win_options, border_win_options)
190189
focusable = vim.F.if_nil(border_win_options.focusable, false),
191190
}
192191

193-
-- Update border characters
192+
-- Ensure the relevant contests and border win_options are set
193+
self._border_win_options = border_win_options
194+
self.content_win_options = content_win_options
194195
self.contents = Border._create_lines(content_win_options, border_win_options)
196+
195197
vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, false, self.contents)
196198

197199
return nvim_win_config
@@ -201,9 +203,6 @@ end
201203
-- Can be used to create a new window (with `create_window = true`)
202204
-- or change an existing one
203205
function Border:move(content_win_options, border_win_options)
204-
self.content_win_options = content_win_options
205-
self._border_win_options = border_win_options
206-
207206
-- Update lines in border buffer, and get config for border window
208207
local nvim_win_config = self:__align_calc_config(content_win_options, border_win_options)
209208

@@ -217,8 +216,6 @@ function Border:new(content_bufnr, content_win_id, content_win_options, border_w
217216
local obj = {}
218217

219218
obj.content_win_id = content_win_id
220-
obj.content_win_options = content_win_options
221-
obj._border_win_options = border_win_options
222219

223220
obj.bufnr = vim.api.nvim_create_buf(false, true)
224221
assert(obj.bufnr, "Failed to create border buffer")

0 commit comments

Comments
 (0)