diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
tree | cd08258054db80bb9a11b1061bb091c70b76926a /test/functional/editor/mark_spec.lua | |
parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.gz rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.tar.bz2 rneovim-1b7b916b7631ddf73c38e3a0070d64e4636cb2f3.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/editor/mark_spec.lua')
-rw-r--r-- | test/functional/editor/mark_spec.lua | 87 |
1 files changed, 72 insertions, 15 deletions
diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua index b3b190ef79..e669d7f2bb 100644 --- a/test/functional/editor/mark_spec.lua +++ b/test/functional/editor/mark_spec.lua @@ -24,7 +24,6 @@ describe('named marks', function() os.remove(file2) end) - it("can be set", function() command("edit " .. file1) command("mark a") @@ -40,59 +39,59 @@ describe('named marks', function() it("errors when set out of range with :mark", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "1000mark x") - eq("nvim_exec(): Vim(mark):E16: Invalid range: 1000mark x", err) + eq("nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x", err) end) it("errors when set out of range with :k", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "1000kx") - eq("nvim_exec(): Vim(k):E16: Invalid range: 1000kx", err) + eq("nvim_exec2(): Vim(k):E16: Invalid range: 1000kx", err) end) it("errors on unknown mark name with :mark", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "mark #") - eq("nvim_exec(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err) + eq("nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote", err) end) it("errors on unknown mark name with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! '#") - eq("nvim_exec(): Vim(normal):E78: Unknown mark", err) + eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err) end) it("errors on unknown mark name with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `#") - eq("nvim_exec(): Vim(normal):E78: Unknown mark", err) + eq("nvim_exec2(): Vim(normal):E78: Unknown mark", err) end) it("errors when moving to a mark that is not set with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! 'z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) err = pcall_err(helpers.exec_capture, "normal! '.") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a mark that is not set with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) err = pcall_err(helpers.exec_capture, "normal! `>") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a global mark that is not set with '", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! 'Z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("errors when moving to a global mark that is not set with `", function() command("edit " .. file1) local err = pcall_err(helpers.exec_capture, "normal! `Z") - eq("nvim_exec(): Vim(normal):E20: Mark not set", err) + eq("nvim_exec2(): Vim(normal):E20: Mark not set", err) end) it("can move to them using '", function() @@ -147,13 +146,27 @@ describe('named marks', function() eq({2, 2}, cursor()) end) + it("can move to them using :'", function() + command("args " .. file1 .. " " .. file2) + feed("j") + feed("ma") + feed("G") + command("'a") + eq({2, 0}, cursor()) + feed("mA") + command("next") + command("'A") + eq(1, meths.get_current_buf().id) + eq({2, 0}, cursor()) + end) + it("errors when it can't find the buffer", function() command("args " .. file1 .. " " .. file2) feed("mA") command("next") command("bw! " .. file1 ) local err = pcall_err(helpers.exec_capture, "normal! 'A") - eq("nvim_exec(): Vim(normal):E92: Buffer 1 not found", err) + eq("nvim_exec2(): Vim(normal):E92: Buffer 1 not found", err) os.remove(file1) end) @@ -161,7 +174,7 @@ describe('named marks', function() feed('ifoo<Esc>mA') command('enew') feed('ibar<Esc>') - eq('Vim(print):E20: Mark not set', pcall_err(command, [['Aprint]])) + eq("Vim(print):E20: Mark not set: 'Aprint", pcall_err(command, [['Aprint]])) end) it("leave a context mark when moving with '", function() @@ -413,8 +426,52 @@ describe('named marks view', function() 6 line | ^7 line | 8 line | - {MATCH:.*} | + {MATCH:.*marks} | | ]]) end) + + it('fallback to standard behavior when mark is loaded from shada', function() + local screen = Screen.new(10, 6) + screen:attach() + command('edit ' .. file1) + feed('G') + feed('mA') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + command('set shadafile=Xtestfile-functional-editor-marks-shada') + finally(function() + command('set shadafile=NONE') + os.remove('Xtestfile-functional-editor-marks-shada') + end) + command('wshada!') + command('bwipe!') + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + command('rshada!') + command('edit ' .. file1) + feed('`"') + screen:expect([[ + 26 line | + 27 line | + 28 line | + 29 line | + ^30 line | + | + ]]) + feed('`A') + screen:expect_unchanged() + end) end) |