mirror of
https://github.com/gosticks/bookmarks.nvim.git
synced 2025-10-16 11:55:38 +00:00
fix: adding signs outside buffer len
If a mark was added and the file length was decreased afterwards adding signs would fail with an out of bounds error for marks in outside of the new bounds
This commit is contained in:
parent
db4899640d
commit
26d0eb7924
@ -28,20 +28,22 @@ end
|
||||
function M:add(bufnr, signs)
|
||||
local cfg = self.config
|
||||
local isExt = true
|
||||
local line_count = api.nvim_buf_line_count(bufnr)
|
||||
for _, s in ipairs(signs) do
|
||||
if not self:contains(bufnr, s.lnum) then
|
||||
isExt = false
|
||||
local cs = cfg[s.type]
|
||||
local text = s.text or cs.text
|
||||
|
||||
api.nvim_buf_set_extmark(bufnr, self.ns, s.lnum - 1, -1, {
|
||||
id = s.lnum,
|
||||
sign_text = text,
|
||||
priority = config.sign_priority,
|
||||
sign_hl_group = cs.hl,
|
||||
number_hl_group = config.numhl and cs.numhl or nil,
|
||||
line_hl_group = config.linehl and cs.linehl or nil,
|
||||
})
|
||||
if s.lnum >= 1 and s.lnum <= line_count then
|
||||
if not self:contains(bufnr, s.lnum) then
|
||||
isExt = false
|
||||
local cs = cfg[s.type]
|
||||
local text = s.text or cs.text
|
||||
api.nvim_buf_set_extmark(bufnr, self.ns, s.lnum - 1, -1, {
|
||||
id = s.lnum,
|
||||
sign_text = text,
|
||||
priority = config.sign_priority,
|
||||
sign_hl_group = cs.hl,
|
||||
number_hl_group = config.numhl and cs.numhl or nil,
|
||||
line_hl_group = config.linehl and cs.linehl or nil,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
return isExt
|
||||
|
||||
Loading…
Reference in New Issue
Block a user