Skip to content

Commit 4801b87

Browse files
committed
fix: paragraph width calculation
fixes #20
1 parent 0af84e5 commit 4801b87

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lua/nui-components/component/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ function Component:initial_value()
395395
end
396396

397397
function Component:modify_buffer_content(modify_fn)
398-
self:set_buffer_option("modifiable", true)
399398
vim.schedule(function()
399+
self:set_buffer_option("modifiable", true)
400400
modify_fn()
401401
vim.schedule(function()
402402
self:set_buffer_option("modifiable", false)

lua/nui-components/paragraph.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ function Paragraph:on_update()
145145
local lines = self:get_lines()
146146
local size = self:get_size()
147147
local props = self:get_props()
148+
local border_delta_size = self:get_border_delta_size()
148149

149150
if not self:is_hidden() then
150151
self._private.last_width = size.width
151152
end
152153

153-
local width = self._private.last_width or size.width
154+
local width = (self._private.last_width or size.width) - border_delta_size.width
154155

155156
fn.ieach(lines, function(line, index)
156157
local new_line = Line()

0 commit comments

Comments
 (0)