Skip to content

Commit

Permalink
fix(border): add whitespace to align border
Browse files Browse the repository at this point in the history
  • Loading branch information
siduck committed Dec 14, 2024
1 parent 91b7b60 commit 0cdfa1d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lua/volt/ui/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,22 @@ M.border = function(lines, hl)
hl = hl or "linenr"

local maxw = 0
local line_widths = {}

for i, line in ipairs(lines) do
maxw = math.max(maxw, M.line_w(line))
for _, line in ipairs(lines) do
local linew = M.line_w(line)

if maxw < linew then
maxw = linew
end

table.insert(line_widths, linew)
end

for i, _ in ipairs(lines) do
table.insert(lines[i], 1, { "", hl })
table.insert(lines[i], { "", hl })
local rpad = string.rep(" ", maxw - line_widths[i])
table.insert(lines[i], { rpad .. "", hl })
end

maxw = maxw + 2
Expand Down

0 comments on commit 0cdfa1d

Please sign in to comment.