aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/extmark.c9
-rw-r--r--test/functional/ui/decorations_spec.lua36
2 files changed, 33 insertions, 12 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index cad0f71941..b981ffdaf9 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -180,11 +180,14 @@ void extmark_del(buf_T *buf, MarkTreeIter *itr, MTKey key, bool restore)
}
if (mt_decor_any(key)) {
- // If key is an end mark it has been found first while iterating the marktree,
- // indicating the decor is already invalid.
- if (mt_invalid(key) || mt_end(key)) {
+ if (mt_invalid(key)) {
decor_free(mt_decor(key));
} else {
+ if (mt_end(key)) {
+ MTKey k = key;
+ key = key2;
+ key2 = k;
+ }
buf_decor_remove(buf, key.pos.row, key2.pos.row, key.pos.col, mt_decor(key), true);
}
}
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 240a5acc99..fe414783fd 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -6393,24 +6393,19 @@ l5
end)
describe('decorations: virt_text', function()
- local screen ---@type test.functional.ui.screen
+ local ns, screen ---@type integer, test.functional.ui.screen
before_each(function()
clear()
screen = Screen.new(50, 10)
+ ns = api.nvim_create_namespace('test')
end)
it('avoids regression in #17638', function()
- exec_lua[[
- vim.wo.number = true
- vim.wo.relativenumber = true
- ]]
-
+ command 'set number relativenumber'
command 'normal 4ohello'
command 'normal aVIRTUAL'
- local ns = api.nvim_create_namespace('test')
-
api.nvim_buf_set_extmark(0, ns, 2, 0, {
virt_text = {{"hello", "String"}},
virt_text_win_col = 20,
@@ -6451,7 +6446,6 @@ describe('decorations: virt_text', function()
|
]]}
- local ns = api.nvim_create_namespace('ns')
for row = 1, 5 do
api.nvim_buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} })
end
@@ -6464,6 +6458,30 @@ describe('decorations: virt_text', function()
|
]]}
end)
+
+ it('redraws correctly when removing mark whose end ends up in front of start', function()
+ command('normal 5ohello')
+ api.nvim_buf_set_extmark(0, ns, 2, 0, { end_col = 1, virt_text = {{'world', 'Normal'}} })
+ screen:expect([[
+ |
+ hello |
+ hello world |
+ hello |*2
+ hell^o |
+ {1:~ }|*3
+ |
+ ]])
+ feed('3Gdd')
+ api.nvim_buf_clear_namespace(0, ns, 0, -1)
+ screen:expect([[
+ |
+ hello |
+ ^hello |
+ hello |*2
+ {1:~ }|*4
+ |
+ ]])
+ end)
end)
describe('decorations: window scoped', function()