fix(edgy): improve edgy.lua bufferline offset logic

Use already defined Bufferline offsets or use Edgy offset if none are found.

Properly set offset separator position depending on offset location.
This commit is contained in:
Gobinda Goshwami 2024-06-24 14:39:22 +06:00 committed by GitHub
parent 2a7ba6d09c
commit 087dccf2f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,14 +152,17 @@ return {
local get = Offset.get local get = Offset.get
Offset.get = function() Offset.get = function()
if package.loaded.edgy then if package.loaded.edgy then
local old_offset = get()
local layout = require("edgy.config").layout local layout = require("edgy.config").layout
local ret = { left = "", left_size = 0, right = "", right_size = 0 } local ret = { left = "", left_size = 0, right = "", right_size = 0 }
for _, pos in ipairs({ "left", "right" }) do for _, pos in ipairs({ "left", "right" }) do
local sb = layout[pos] local sb = layout[pos]
local title = " Sidebar" .. string.rep(" ", sb.bounds.width - 8)
if sb and #sb.wins > 0 then if sb and #sb.wins > 0 then
local title = " Sidebar" .. string.rep(" ", sb.bounds.width - 8) ret[pos] = old_offset[pos .. "_size"] > 0 and old_offset[pos]
ret[pos] = "%#EdgyTitle#" .. title .. "%*" .. "%#WinSeparator#│%*" or pos == "left" and ("%#Bold#" .. title .. "%*" .. "%#BufferLineOffsetSeparator#│%*")
ret[pos .. "_size"] = sb.bounds.width or pos == "right" and ("%#BufferLineOffsetSeparator#│%*" .. "%#Bold#" .. title .. "%*")
ret[pos .. "_size"] = old_offset[pos .. "_size"] > 0 and old_offset[pos .. "_size"] or sb.bounds.width
end end
end end
ret.total_size = ret.left_size + ret.right_size ret.total_size = ret.left_size + ret.right_size