mirror of
https://github.com/neovim/neovim.git
synced 2026-03-29 03:42:11 +00:00
refactor(progress): simplify progress-status format #38491
Problem:
Currently we are using
if 1 item then
{title}: {percent}%
else
Progress: {AVG}%({N})
dropping {title} and Progress text saves up space in statusline plus makes the format consistent, less jumping around.
Solution:
Use `{AVG}%({N})` for all cases.
This commit is contained in:
@@ -359,19 +359,13 @@ do
|
||||
local count = #running
|
||||
if count == 0 then
|
||||
return '' -- nothing to show
|
||||
elseif count == 1 then
|
||||
local progress_item = running[1]
|
||||
if progress_item.title == nil then
|
||||
return string.format('%d%%%% ', progress_item.percent or 0)
|
||||
end
|
||||
return string.format('%s: %d%%%% ', progress_item.title, progress_item.percent or 0)
|
||||
else
|
||||
local sum = 0 ---@type integer
|
||||
for _, progress_item in ipairs(running) do
|
||||
sum = sum + (progress_item.percent or 0)
|
||||
end
|
||||
local avg = math.floor(sum / count)
|
||||
return string.format('Progress: %d%%%%(%d) ', avg, count)
|
||||
return string.format('%d%%%%(%d) ', avg, count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user