aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-11-05 13:17:23 +0100
committerGitHub <noreply@github.com>2023-11-05 13:17:23 +0100
commit22fa66bb1d502e250d972b1814552412cc2e87fe (patch)
tree1b2db4ae7e5dacd3a51611301e180ccb046563e2 /test
parent4d757bbfbb6c0e5280563779c4b4ee1ce9142cf0 (diff)
parent68cb4a7405ea9f8841d1f25ee8997c49e77fa679 (diff)
downloadrneovim-22fa66bb1d502e250d972b1814552412cc2e87fe.tar.gz
rneovim-22fa66bb1d502e250d972b1814552412cc2e87fe.tar.bz2
rneovim-22fa66bb1d502e250d972b1814552412cc2e87fe.zip
Merge pull request #25882 from bfredl/noundo
feat(extmarks): add "no_undo_restore" flag to opt out of undo-restoring
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/decorations_spec.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index e56f82bd9f..68c3e73e61 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -11,6 +11,7 @@ local meths = helpers.meths
local funcs = helpers.funcs
local curbufmeths = helpers.curbufmeths
local command = helpers.command
+local eq = helpers.eq
local assert_alive = helpers.assert_alive
describe('decorations providers', function()
@@ -1997,6 +1998,60 @@ describe('extmark decorations', function()
]]}
end)
+ local function with_undo_restore(val)
+ screen:try_resize(50, 5)
+ insert(example_text)
+ feed'gg'
+ meths.buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val})
+ screen:expect{grid=[[
+ ^for _,{1:item in} ipairs(items) do |
+ local text, hl_id_cell, count = unpack(item) |
+ if hl_id_cell ~= nil then |
+ hl_id = hl_id_cell |
+ |
+ ]]}
+
+ meths.buf_set_text(0, 0, 4, 0, 8, {''})
+ screen:expect{grid=[[
+ ^for {1:em in} ipairs(items) do |
+ local text, hl_id_cell, count = unpack(item) |
+ if hl_id_cell ~= nil then |
+ hl_id = hl_id_cell |
+ |
+ ]]}
+ end
+
+ it("highlights do reapply to restored text after delete", function()
+ with_undo_restore(true) -- also default behavior
+
+ feed 'u'
+ screen:expect{grid=[[
+ ^for _,{1:item in} ipairs(items) do |
+ local text, hl_id_cell, count = unpack(item) |
+ if hl_id_cell ~= nil then |
+ hl_id = hl_id_cell |
+ 1 change; before #2 0 seconds ago |
+ ]]}
+ end)
+
+ it("highlights don't reapply to restored text after delete with no_undo_restore", function()
+ with_undo_restore(false)
+
+ feed 'u'
+ screen:expect{grid=[[
+ ^for _,it{1:em in} ipairs(items) do |
+ local text, hl_id_cell, count = unpack(item) |
+ if hl_id_cell ~= nil then |
+ hl_id = hl_id_cell |
+ 1 change; before #2 0 seconds ago |
+ ]]}
+
+ eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0,
+ hl_eol = false, hl_group = "NonText", undo_restore = false,
+ ns_id = 1, priority = 4096, right_gravity = true } } },
+ meths.buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true}))
+ end)
+
it('virtual text works with rightleft', function()
screen:try_resize(50, 3)
insert('abcdefghijklmn')