mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 04:42:03 +00:00
fix(progress): show progress-status only in curwin #38458
Problem:
Currently same progress stat get's displayed on statusline of all
windows. This is repeatitive and noisy.
Solultion:
Only display progress-status on the focused window
Problem:
Currently, when multiple progress are on going we show it as Progress:
{N} items {percent}% format. It can be simplified sinnce items doesn't
really add enough value for the valuable space it takes in statusline
Solution:
Change format to Progress: {percent}%({N})
This commit is contained in:
2
runtime/lua/vim/_meta/options.lua
generated
2
runtime/lua/vim/_meta/options.lua
generated
@@ -6990,7 +6990,7 @@ vim.wo.stc = vim.wo.statuscolumn
|
||||
---
|
||||
---
|
||||
--- @type string
|
||||
vim.o.statusline = "%<%f %h%w%m%r %{% v:lua.require('vim._core.util').term_exitcode() %}%=%{% luaeval('(package.loaded[''vim.ui''] and vim.ui.progress_status()) or '''' ')%}%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &busy > 0 ? '◐ ' : '' %}%{% luaeval('(package.loaded[''vim.diagnostic''] and next(vim.diagnostic.count()) and vim.diagnostic.status() .. '' '') or '''' ') %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}"
|
||||
vim.o.statusline = "%<%f %h%w%m%r %{% v:lua.require('vim._core.util').term_exitcode() %}%=%{% luaeval('(package.loaded[''vim.ui''] and vim.api.nvim_get_current_win() == tonumber(vim.g.actual_curwin or -1) and vim.ui.progress_status()) or '''' ')%}%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &busy > 0 ? '◐ ' : '' %}%{% luaeval('(package.loaded[''vim.diagnostic''] and next(vim.diagnostic.count()) and vim.diagnostic.status() .. '' '') or '''' ') %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}"
|
||||
vim.o.stl = vim.o.statusline
|
||||
vim.wo.statusline = vim.o.statusline
|
||||
vim.wo.stl = vim.wo.statusline
|
||||
|
||||
@@ -352,7 +352,7 @@ do
|
||||
--- Gets a status description summarizing currently running progress messages.
|
||||
--- - If none: returns empty string
|
||||
--- - If one running item: "title: 42%"
|
||||
--- - If multiple running items: "Progress: N items AVG%"
|
||||
--- - If multiple running items: "Progress: AVG%(N)"
|
||||
---@param running ProgressMessage[]
|
||||
---@return string
|
||||
local function progress_status_fmt(running)
|
||||
@@ -371,7 +371,7 @@ do
|
||||
sum = sum + (progress_item.percent or 0)
|
||||
end
|
||||
local avg = math.floor(sum / count)
|
||||
return string.format('Progress: %d items %d%%%% ', count, avg)
|
||||
return string.format('Progress: %d%%%%(%d) ', avg, count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8803,7 +8803,7 @@ local options = {
|
||||
'%f %h%w%m%r ',
|
||||
"%{% v:lua.require('vim._core.util').term_exitcode() %}",
|
||||
'%=',
|
||||
"%{% luaeval('(package.loaded[''vim.ui''] and vim.ui.progress_status()) or '''' ')%}",
|
||||
"%{% luaeval('(package.loaded[''vim.ui''] and vim.api.nvim_get_current_win() == tonumber(vim.g.actual_curwin or -1) and vim.ui.progress_status()) or '''' ')%}",
|
||||
"%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
|
||||
"%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
|
||||
"%{% &busy > 0 ? '◐ ' : '' %}",
|
||||
|
||||
@@ -965,7 +965,7 @@ describe('default statusline', function()
|
||||
'%f %h%w%m%r ',
|
||||
"%{% v:lua.require('vim._core.util').term_exitcode() %}",
|
||||
'%=',
|
||||
"%{% luaeval('(package.loaded[''vim.ui''] and vim.ui.progress_status()) or '''' ')%}",
|
||||
"%{% luaeval('(package.loaded[''vim.ui''] and vim.api.nvim_get_current_win() == tonumber(vim.g.actual_curwin or -1) and vim.ui.progress_status()) or '''' ')%}",
|
||||
"%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}",
|
||||
"%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}",
|
||||
"%{% &busy > 0 ? '◐ ' : '' %}",
|
||||
@@ -1073,7 +1073,7 @@ describe('default statusline', function()
|
||||
true,
|
||||
{ kind = 'progress', title = 'second-item', status = 'running', percent = 20 }
|
||||
)
|
||||
eq('Progress: 2 items 35% ', get_progress())
|
||||
eq('Progress: 35%(2) ', get_progress())
|
||||
|
||||
api.nvim_echo({ { 'searching' } }, true, {
|
||||
id = id1,
|
||||
@@ -1091,6 +1091,29 @@ describe('default statusline', function()
|
||||
{3:[No Name] second-item: 20% 0,0-1 All}|
|
||||
{131:terminal(ripgrep)}: {19:100% }searching |
|
||||
]])
|
||||
|
||||
-- Progress_status only shown on active window
|
||||
exec('split')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*6
|
||||
{3:[No Name] second-item: 20% 0,0-1 All}|
|
||||
|
|
||||
{1:~ }|*5
|
||||
{2:[No Name] 0,0-1 All}|
|
||||
{131:terminal(ripgrep)}: {19:100% }searching |
|
||||
]])
|
||||
|
||||
exec('wincmd w')
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }|*6
|
||||
{2:[No Name] 0,0-1 All}|
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
{3:[No Name] second-item: 20% 0,0-1 All}|
|
||||
{131:terminal(ripgrep)}: {19:100% }searching |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user