Skip to content

Commit

Permalink
Exclude entries from the TUI process.
Browse files Browse the repository at this point in the history
This way supports Neovim v0.10.
  • Loading branch information
dstein64 committed Feb 11, 2024
1 parent 1380a0e commit 314b38c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
12 changes: 0 additions & 12 deletions autoload/startuptime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 19 additions & 3 deletions lua/startuptime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(':')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 314b38c

Please sign in to comment.