From 763c720d512516c4af25a510a88b2d073e3c41a9 Mon Sep 17 00:00:00 2001 From: Sam <130783534+Sam-programs@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:03:11 +0300 Subject: [PATCH] fix(ghost_text): make sure to the delete the mark for the same buffer (#1826) --- lua/cmp/view/ghost_text_view.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/cmp/view/ghost_text_view.lua b/lua/cmp/view/ghost_text_view.lua index 2f61c48..759567e 100644 --- a/lua/cmp/view/ghost_text_view.lua +++ b/lua/cmp/view/ghost_text_view.lua @@ -28,7 +28,8 @@ ghost_text_view.new = function() vim.api.nvim_set_decoration_provider(ghost_text_view.ns, { on_win = function(_, win) if self.extmark_id then - vim.api.nvim_buf_del_extmark(0, ghost_text_view.ns, self.extmark_id) + vim.api.nvim_buf_del_extmark(self.extmark_buf, ghost_text_view.ns, self.extmark_id) + self.extmark_id = nil end if win ~= self.win then @@ -55,7 +56,8 @@ ghost_text_view.new = function() local text = self.text_gen(self, line, col) if #text > 0 then - self.extmark_id = vim.api.nvim_buf_set_extmark(0, ghost_text_view.ns, row - 1, col, { + self.extmark_buf = vim.api.nvim_get_current_buf() + self.extmark_id = vim.api.nvim_buf_set_extmark(self.extmark_buf, ghost_text_view.ns, row - 1, col, { right_gravity = true, virt_text = { { text, type(c) == 'table' and c.hl_group or 'Comment' } }, virt_text_pos = has_inline and 'inline' or 'overlay',