Skip to content

Commit 6975a1c

Browse files
committed
fix: fix toggle logic
1 parent 8305950 commit 6975a1c

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

lua/float-preview.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function FloatPreview:attach(bufnr)
328328
for _, key in ipairs(self.cfg.mapping.preview) do
329329
vim.keymap.set("n", key, function()
330330
local _, node = pcall(get_node)
331-
if self.path ~= nil and self.path == node.path then
331+
if self.path ~= nil and self.path == node.absolute_path then
332332
self.close_preview(self)
333333
return
334334
end
@@ -347,9 +347,11 @@ function FloatPreview:attach(bufnr)
347347
if self.cfg.auto_preview then
348348
if bufnr == vim.api.nvim_get_current_buf() then
349349
self:preview_under_cursor()
350-
else
351-
self:_close "changed buffer"
350+
return
352351
end
352+
353+
self:_close "changed buffer"
354+
return
353355
end
354356
end,
355357
})
@@ -360,12 +362,7 @@ function FloatPreview:attach(bufnr)
360362
vim.api.nvim_create_autocmd({ "CursorMoved" }, {
361363
group = preview_au,
362364
callback = function()
363-
local _, node = pcall(get_node)
364-
if self.path == node.path then
365-
self.close_preview(self)
366-
return
367-
end
368-
self.close_preview(self)
365+
self:close_preview()
369366
end,
370367
})
371368
)

0 commit comments

Comments
 (0)