diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /test/functional/editor/macro_spec.lua | |
parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/editor/macro_spec.lua')
-rw-r--r-- | test/functional/editor/macro_spec.lua | 159 |
1 files changed, 111 insertions, 48 deletions
diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua index c97befdf07..27c5eddac8 100644 --- a/test/functional/editor/macro_spec.lua +++ b/test/functional/editor/macro_spec.lua @@ -1,19 +1,21 @@ -local helpers = require('test.functional.helpers')(after_each) - -local eq = helpers.eq -local eval = helpers.eval -local feed = helpers.feed -local clear = helpers.clear -local expect = helpers.expect -local command = helpers.command -local fn = helpers.fn -local api = helpers.api -local insert = helpers.insert - -describe('macros', function() +local t = require('test.testutil') +local n = require('test.functional.testnvim')() + +local eq = t.eq +local eval = n.eval +local feed = n.feed +local clear = n.clear +local expect = n.expect +local command = n.command +local fn = n.fn +local api = n.api +local insert = n.insert + +describe('macros with default mappings', function() before_each(function() clear({ args_rm = { '--cmd' } }) end) + it('can be recorded and replayed', function() feed('qiahello<esc>q') expect('hello') @@ -22,6 +24,7 @@ describe('macros', function() expect('hellohello') eq('ahello', eval('@i')) end) + it('applies maps', function() command('imap x l') command('nmap l a') @@ -34,87 +37,147 @@ describe('macros', function() end) it('can be replayed with Q', function() - insert [[hello + insert [[ +hello hello hello]] feed [[gg]] feed [[qqAFOO<esc>q]] - eq({ 'helloFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOO +hello +hello]] feed [[Q]] - eq({ 'helloFOOFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOOFOO +hello +hello]] feed [[G3Q]] - eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOOFOO +hello +helloFOOFOOFOO]] feed [[ggV3jQ]] - eq( - { 'helloFOOFOOFOO', 'helloFOO', 'helloFOOFOOFOOFOO' }, - api.nvim_buf_get_lines(0, 0, -1, false) - ) + expect [[ +helloFOOFOOFOO +helloFOO +helloFOOFOOFOOFOO]] end) - it('can be replayed with @', function() - insert [[hello + it('can be replayed with Q and @@', function() + insert [[ +hello hello hello]] feed [[gg]] feed [[qqAFOO<esc>q]] - eq({ 'helloFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOO +hello +hello]] feed [[Q]] - eq({ 'helloFOOFOO', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOOFOO +hello +hello]] feed [[G3@@]] - eq({ 'helloFOOFOO', 'hello', 'helloFOOFOOFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOOFOO +hello +helloFOOFOOFOO]] feed [[ggV2j@@]] - eq( - { 'helloFOOFOOFOO', 'helloFOO', 'helloFOOFOOFOOFOO' }, - api.nvim_buf_get_lines(0, 0, -1, false) - ) + expect [[ +helloFOOFOOFOO +helloFOO +helloFOOFOOFOOFOO]] end) - it('can be replayed with @q and @w', function() - insert [[hello + it('can be replayed with @ in linewise Visual mode', function() + insert [[ +hello hello hello]] feed [[gg]] feed [[qqAFOO<esc>qu]] - eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +hello +hello +hello]] feed [[qwA123<esc>qu]] - eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +hello +hello +hello]] feed [[V3j@q]] - eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +helloFOO +helloFOO +helloFOO]] + + feed [[ggVj@w]] + expect [[ +helloFOO123 +helloFOO123 +helloFOO]] + end) - feed [[gg]] - feed [[Vj@w]] - eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + it('can be recorded and replayed in Visual mode', function() + insert('foo BAR BAR foo BAR foo BAR BAR BAR foo BAR BAR') + feed('0vqifofRq') + eq({ 0, 1, 7, 0 }, fn.getpos('.')) + eq({ 0, 1, 1, 0 }, fn.getpos('v')) + feed('Q') + eq({ 0, 1, 19, 0 }, fn.getpos('.')) + eq({ 0, 1, 1, 0 }, fn.getpos('v')) + feed('Q') + eq({ 0, 1, 27, 0 }, fn.getpos('.')) + eq({ 0, 1, 1, 0 }, fn.getpos('v')) + feed('@i') + eq({ 0, 1, 43, 0 }, fn.getpos('.')) + eq({ 0, 1, 1, 0 }, fn.getpos('v')) end) - it('can be replayed with @q and @w visual-block', function() - insert [[hello + it('can be replayed with @ in blockwise Visual mode', function() + insert [[ +hello hello hello]] feed [[gg]] feed [[qqAFOO<esc>qu]] - eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +hello +hello +hello]] feed [[qwA123<esc>qu]] - eq({ 'hello', 'hello', 'hello' }, api.nvim_buf_get_lines(0, 0, -1, false)) - - feed [[<C-v>3j@q]] - eq({ 'helloFOO', 'helloFOO', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + expect [[ +hello +hello +hello]] - feed [[gg]] - feed [[<C-v>j@w]] - eq({ 'helloFOO123', 'helloFOO123', 'helloFOO' }, api.nvim_buf_get_lines(0, 0, -1, false)) + feed [[0<C-v>3jl@q]] + expect [[ +heFOOllo +heFOOllo +heFOOllo]] + + feed [[gg0<C-v>j@w]] + expect [[ +h123eFOOllo +h123eFOOllo +heFOOllo]] end) end) |