Skip to content

Commit

Permalink
fix: paragraph width calculation
Browse files Browse the repository at this point in the history
fixes #20
  • Loading branch information
b0o committed Apr 13, 2024
1 parent 0af84e5 commit 4801b87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/nui-components/component/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ function Component:initial_value()
end

function Component:modify_buffer_content(modify_fn)
self:set_buffer_option("modifiable", true)
vim.schedule(function()
self:set_buffer_option("modifiable", true)
modify_fn()
vim.schedule(function()
self:set_buffer_option("modifiable", false)
Expand Down
3 changes: 2 additions & 1 deletion lua/nui-components/paragraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ function Paragraph:on_update()
local lines = self:get_lines()
local size = self:get_size()
local props = self:get_props()
local border_delta_size = self:get_border_delta_size()

if not self:is_hidden() then
self._private.last_width = size.width
end

local width = self._private.last_width or size.width
local width = (self._private.last_width or size.width) - border_delta_size.width

fn.ieach(lines, function(line, index)
local new_line = Line()
Expand Down

0 comments on commit 4801b87

Please sign in to comment.