aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/extmark_spec.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2026-04-18 12:53:00 +0200
committerGitHub <noreply@github.com>2026-04-18 06:53:00 -0400
commit68f7acaaae662b7511cc71a20901066174e03538 (patch)
tree846cb77f5462feb114b1602668adf3fe9fed3dd0 /test/functional/api/extmark_spec.lua
parent6b9b4a1377b330fca651287025c1bf5242ac9790 (diff)
downloadrneovim-68f7acaaae662b7511cc71a20901066174e03538.tar.gz
rneovim-68f7acaaae662b7511cc71a20901066174e03538.tar.bz2
rneovim-68f7acaaae662b7511cc71a20901066174e03538.zip
fix(marks): adjust marks when unloading "nofile" buffer #39118
Problem: Marks are not adjusted unloading a buffer that doesn't exist on disk. E.g. extmarks are still valid (and will be beyond the end of the buffer if the buffer is reloaded), even though the text is lost. Solution: Adjust marks for a cleared buffer when unloading a buffer that doesn't exist on disk.
Diffstat (limited to 'test/functional/api/extmark_spec.lua')
-rw-r--r--test/functional/api/extmark_spec.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index 3245eba80c..911d9fb0bf 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1959,6 +1959,16 @@ describe('API/extmarks', function()
},
}
end)
+
+ it('are invalidated when "nofile" buffer is unloaded', function()
+ local buf = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_name(buf, 'foo')
+ api.nvim_buf_set_lines(buf, 0, 0, false, { 'foo', 'bar' })
+ local id = api.nvim_buf_set_extmark(buf, ns, 1, 0, { invalidate = true })
+ api.nvim_buf_delete(buf, { unload = true })
+ local mark = { 0, 0, { invalid = true, invalidate = true, ns_id = 3, right_gravity = true } }
+ eq(mark, api.nvim_buf_get_extmark_by_id(buf, ns, id, { details = true }))
+ end)
end)
describe('Extmarks buffer api with many marks', function()