diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index 4b919b7eef..4d78f8481b 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -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 diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index 401334d00c..02cbdf84de 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -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 diff --git a/src/nvim/options.lua b/src/nvim/options.lua index bdc33dd5fc..f7ded5639b 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -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 ? '◐ ' : '' %}", diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 903765303b..7c3f203a81 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -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)