diff --git a/autoload/startuptime.vim b/autoload/startuptime.vim index 8e199ff..a37eeb9 100644 --- a/autoload/startuptime.vim +++ b/autoload/startuptime.vim @@ -294,18 +294,6 @@ function! s:Profile(onfinish, onprogress, options, tries, file, items) abort call delete(a:file) endif if a:tries ==# 0 || a:options.input_file !=# v:null - if has('nvim-0.9') - if a:options.input_file !=# v:null || a:options.tries * 2 ==# len(a:items) - " Add a workaround for Neovim #23036. When the number of results is double - " what's expected, use every other result. - let l:items = [] - for l:idx in range(0, len(a:items) - 1, 2) - call add(l:items, a:items[l:idx]) - endfor - call remove(a:items, 0, -1) - call extend(a:items, l:items) - endif - endif if len(a:items) ==# 0 throw 'vim-startuptime: unable to obtain startup times' endif diff --git a/lua/startuptime.lua b/lua/startuptime.lua index be817f5..e57ceb3 100644 --- a/lua/startuptime.lua +++ b/lua/startuptime.lua @@ -13,12 +13,12 @@ end local extract = function(file, options, event_types) local other_event_type = event_types['other'] local sourcing_event_type = event_types['sourcing'] - local result = {} + local groups = {} local occurrences for line in io.lines(file) do if #line ~= 0 and line:find('^%d') ~= nil then if line:find(': --- N?VIM STARTING ---$') ~= nil then - table.insert(result, {}) + table.insert(groups, {}) occurrences = {} end local idx = line:find(':') @@ -60,9 +60,25 @@ local extract = function(file, options, event_types) table.insert(types, other_event_type) end if vim.tbl_contains(types, item.type) then - table.insert(result[#result], item) + table.insert(groups[#groups], item) + end + end + end + -- Exclude entries from the TUI process. Neovim #23036, #26790 + local result = {} + for _, group in ipairs(groups) do + local tui = true + for _, item in ipairs(group) do + -- Check for an event that would occur for the main process but not the + -- TUI. + if item.event == 'opening buffers' then + tui = false + break end end + if not tui then + table.insert(result, group) + end end return result end