Delete previous marks before adding new ones

It was causing some issues when there were still extmarks left and we
generated annotation just after
This commit is contained in:
Daniel Mathiot
2021-08-27 21:46:19 +02:00
parent 1d97f1415e
commit 6c89fd0714
2 changed files with 5 additions and 5 deletions

View File

@@ -54,10 +54,11 @@ neogen.generate = function(opts)
if #content ~= 0 then
local jump_text = language.jump_text or neogen.configuration.jump_text
neogen.utilities.cursor.del_extmarks() -- Delete previous extmarks before setting any new ones
--- Removes jump_text marks and keep the second part of jump_text|other_text if there is one (which is other_text)
local delete_marks = function(v)
local pattern = jump_text.. "[|%w]+"
local pattern = jump_text .. "[|%w]+"
local matched = string.match(v, pattern)
if matched then
@@ -118,4 +119,3 @@ neogen.setup = function(opts)
end
return neogen

View File

@@ -38,8 +38,8 @@ neogen.utilities.cursor.jump = function()
end
neogen.utilities.cursor.del_extmarks = function()
local extmarks = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
for _,v in pairs(extmarks) do
local extmarks = vim.api.nvim_buf_get_extmarks(0, neogen_ns, 0, -1, {})
for _, v in pairs(extmarks) do
vim.api.nvim_buf_del_extmark(0, neogen_ns, v[1])
end
end