Skip to content

Commit

Permalink
fix: check that window and buffer are valid & init namespace directly
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd committed Sep 20, 2023
1 parent 910da1f commit ef15a6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/image/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local state = {
backend = nil,
options = default_options,
images = {},
extmarks_namespace = nil,
extmarks_namespace = vim.api.nvim_create_namespace("image.nvim"),
remote_cache = {},
tmp_dir = vim.fn.tempname(),
}
Expand Down Expand Up @@ -68,14 +68,14 @@ api.setup = function(options)
-- create tmp dir
vim.fn.mkdir(state.tmp_dir, "p")

-- setup namespaces
state.extmarks_namespace = vim.api.nvim_create_namespace("image.nvim")

-- handle folds / scroll extra
---@type table<number, { topline: number, botline: number, bufnr: number, height: number; folded_lines: number }>
local window_history = {}
vim.api.nvim_set_decoration_provider(state.extmarks_namespace, {
on_win = vim.schedule_wrap(function(_, winid, bufnr, topline, botline)
if not vim.api.nvim_win_is_valid(winid) then return false end
if not vim.api.nvim_buf_is_valid(bufnr) then return false end

-- get current window
local window = nil
local windows = {}
Expand Down

0 comments on commit ef15a6d

Please sign in to comment.