Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove right padding from paragraph and descendants #11

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lua/nui-components/paragraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ function Paragraph:prop_types()
end

function Paragraph:_calculate_gap_width(max_width, text_width)
local align = self:get_props().align
local props = self:get_props()
local align, truncate = props.align, props.truncate

local gap_width = max_width - text_width
if align == "left" then
if align == "left" and not truncate then
return 0, gap_width
elseif align == "center" then
return math.floor(gap_width / 2), math.ceil(gap_width / 2)
return math.floor(gap_width / 2), truncate and 0 or math.ceil(gap_width / 2)
elseif align == "right" then
return gap_width, 0
end
Expand Down