aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/buffer_updates_spec.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-03-03 09:45:06 +0100
committerGitHub <noreply@github.com>2021-03-03 09:45:06 +0100
commit6995fad260e3e7c49e4f9dc4b63de03989411c7b (patch)
tree442b00590615fa1475ba658939dcdbcf68a2c66b /test/functional/lua/buffer_updates_spec.lua
parentbda12927be84f0e0e05e885f9acb40a7ac2c5524 (diff)
parentf42e932df498f670c9b3d705cbf2f3b3f091c80c (diff)
downloadrneovim-6995fad260e3e7c49e4f9dc4b63de03989411c7b.tar.gz
rneovim-6995fad260e3e7c49e4f9dc4b63de03989411c7b.tar.bz2
rneovim-6995fad260e3e7c49e4f9dc4b63de03989411c7b.zip
Merge pull request #13973 from chentau/on_bytes_undofile
New versions of neovim will not read undofiles written by nvim before this merge (there will be an error message about incopmatible version). Nvim 0.4 (or an master up to bda12927be84f0e0e05e885f9acb40a7ac2c5524 ) can be used to recover older undofiles, so if you worried about unsaved changes lurking around in undofiles it would make sense to keep such version around somewhere to recover them. This is a necessary change to keep tree-sitter and plugins dependent on byte-level buffer change events fully working with undo states from a undofile. If there is a clear demand we might implement reading of the old format. Such recovered buffers will not be be fully functional with plugins relying on buffer updates or tree-sitter, however.
Diffstat (limited to 'test/functional/lua/buffer_updates_spec.lua')
-rw-r--r--test/functional/lua/buffer_updates_spec.lua54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 8c5e936906..7a6b5be8bc 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -666,8 +666,62 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("sends events when undoing with undofile", function()
+ write_file("Xtest-undofile", dedent([[
+ 12345
+ hello world
+ ]]))
+
+ command("e! Xtest-undofile")
+ command("set undodir=. | set undofile")
+
+ local ns = helpers.request('nvim_create_namespace', "ns1")
+ meths.buf_set_extmark(0, ns, 0, 0, {})
+
+ eq({"12345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- splice
+ feed("gg0d2l")
+
+ eq({"345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- move
+ command(".m+1")
+
+ eq({"hello world", "345"}, meths.buf_get_lines(0, 0, -1, true))
+
+ -- reload undofile and undo changes
+ command("w")
+ command("set noundofile")
+ command("bw!")
+ command("e! Xtest-undofile")
+
+ command("set undofile")
+
+ local check_events = setup_eventcheck(verify, nil)
+
+ feed("u")
+ eq({"345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ check_events {
+ { "test1", "bytes", 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 },
+ { "test1", "bytes", 2, 6, 0, 0, 0, 0, 0, 0, 1, 0, 4 }
+ }
+
+ feed("u")
+ eq({"12345", "hello world"}, meths.buf_get_lines(0, 0, -1, true))
+
+ check_events {
+ { "test1", "bytes", 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 }
+ }
+ command("bw!")
+ end)
+
+
teardown(function()
os.remove "Xtest-reload"
+ os.remove "Xtest-undofile"
+ os.remove ".Xtest-undofile.un~"
end)
end