mirror of
https://github.com/NotAShelf/specs.nvim.git
synced 2024-12-27 21:22:24 +00:00
Circumvent nvim segmentation fault by avoiding operations on highlights in unfocused windows.
This commit is contained in:
parent
eee5efbafc
commit
7229d48b51
1 changed files with 18 additions and 3 deletions
|
@ -16,6 +16,7 @@ end
|
|||
|
||||
function M.show_specs()
|
||||
local buftype = vim.api.nvim_buf_get_option(0, 'buftype')
|
||||
local start_win_id = vim.api.nvim_get_current_win()
|
||||
if buftype == 'nofile' then return end
|
||||
|
||||
local cursor_col = vim.fn.wincol()-1
|
||||
|
@ -35,8 +36,22 @@ function M.show_specs()
|
|||
local cnt = 0
|
||||
local config = vim.api.nvim_win_get_config(win_id)
|
||||
local timer = vim.loop.new_timer()
|
||||
local closed = false
|
||||
|
||||
vim.loop.timer_start(timer, opts.popup.delay_ms, opts.popup.inc_ms, vim.schedule_wrap(function()
|
||||
if closed or vim.api.nvim_get_current_win() ~= start_win_id then
|
||||
if not closed then
|
||||
pcall(vim.loop.close, timer)
|
||||
pcall(vim.api.nvim_win_close, win_id, true)
|
||||
|
||||
-- Callbacks might stack up before the timer actually gets closed, track that state
|
||||
-- internally here instead
|
||||
closed = true
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if vim.api.nvim_win_is_valid(win_id) then
|
||||
local bl = opts.popup.fader(opts.popup.blend, cnt)
|
||||
local dm = opts.popup.resizer(opts.popup.width, cursor_col, cnt)
|
||||
|
|
Loading…
Reference in a new issue