mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update 2025-04-16
Update 2025-04-07 Update 2025-04-12 Update 2025-04-16
This commit is contained in:
@@ -92,7 +92,7 @@ end)
|
||||
local render_numbers = ya.sync(function(_, mode)
|
||||
ya.render()
|
||||
|
||||
Entity.number = function(_, index, file, hovered)
|
||||
Entity.number = function(_, index, total, file, hovered)
|
||||
local idx
|
||||
if mode == SHOW_NUMBERS_RELATIVE then
|
||||
idx = math.abs(hovered - index)
|
||||
@@ -106,13 +106,13 @@ local render_numbers = ya.sync(function(_, mode)
|
||||
end
|
||||
end
|
||||
|
||||
local num_format = "%" .. #tostring(total) .. "d"
|
||||
|
||||
-- emulate vim's hovered offset
|
||||
if idx >= 100 then
|
||||
return ui.Span(string.format("%4d ", idx))
|
||||
elseif hovered == index then
|
||||
return ui.Span(string.format("%3d ", idx))
|
||||
if hovered == index then
|
||||
return ui.Span(string.format(num_format .. " ", idx))
|
||||
else
|
||||
return ui.Span(string.format(" %3d ", idx))
|
||||
return ui.Span(string.format(" " .. num_format, idx))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,7 +124,13 @@ local render_numbers = ya.sync(function(_, mode)
|
||||
|
||||
local hovered_index
|
||||
for i, f in ipairs(files) do
|
||||
if f:is_hovered() then
|
||||
-- TODO: Removed f:is_hovered() support in next Yazi release
|
||||
if type(f.is_hovered) == "boolean" then
|
||||
hovered = f.is_hovered
|
||||
else
|
||||
hovered = f:is_hovered()
|
||||
end
|
||||
if hovered then
|
||||
hovered_index = i
|
||||
break
|
||||
end
|
||||
@@ -135,7 +141,8 @@ local render_numbers = ya.sync(function(_, mode)
|
||||
linemodes[#linemodes + 1] = Linemode:new(f):redraw()
|
||||
|
||||
local entity = Entity:new(f)
|
||||
entities[#entities + 1] = ui.Line({ Entity:number(i, f, hovered_index), entity:redraw() }):style(entity:style())
|
||||
entities[#entities + 1] = ui.Line({ Entity:number(i, #self._folder.files, f, hovered_index), entity:redraw() })
|
||||
:style(entity:style())
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user