diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-03-27 09:06:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 01:06:46 +0000 |
commit | 750e1836afb49b860fa11b4336a7ae351720a553 (patch) | |
tree | d46b75c6d0bc947fcfc268e2e103e6fdf1a9547a /test | |
parent | 8f40ffdb92b6ca25529b470e4a4e2bb7ddbb000a (diff) | |
download | rneovim-750e1836afb49b860fa11b4336a7ae351720a553.tar.gz rneovim-750e1836afb49b860fa11b4336a7ae351720a553.tar.bz2 rneovim-750e1836afb49b860fa11b4336a7ae351720a553.zip |
vim-patch:9.1.1224: cannot :put while keeping indent (#33076)
Problem: cannot :put while keeping indent (Peter Aronoff)
Solution: add the :iput ex command (64-bitman)
fixes: vim/vim#16225
closes: vim/vim#16886
https://github.com/vim/vim/commit/e08f10a55c3f15b0b4af631908551d88ec4fe502
Cherry-pick test_put.vim changes from patch 8.2.1593.
N/A patches:
vim-patch:9.1.1213: cannot :put while keeping indent
vim-patch:9.1.1215: Patch 9.1.1213 has some issues
Co-authored-by: 64-bitman <60551350+64-bitman@users.noreply.github.com>
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_put.vim | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/test/old/testdir/test_put.vim b/test/old/testdir/test_put.vim index e0a78c7409..26eb7f0eb4 100644 --- a/test/old/testdir/test_put.vim +++ b/test/old/testdir/test_put.vim @@ -73,16 +73,18 @@ func Test_put_fails_when_nomodifiable() setlocal nomodifiable normal! yy - call assert_fails(':put', 'E21') - call assert_fails(':put!', 'E21') - call assert_fails(':normal! p', 'E21') - call assert_fails(':normal! gp', 'E21') - call assert_fails(':normal! P', 'E21') - call assert_fails(':normal! gP', 'E21') + call assert_fails(':put', 'E21:') + call assert_fails(':put!', 'E21:') + call assert_fails(':iput', 'E21:') + call assert_fails(':iput!', 'E21:') + call assert_fails(':normal! p', 'E21:') + call assert_fails(':normal! gp', 'E21:') + call assert_fails(':normal! P', 'E21:') + call assert_fails(':normal! gP', 'E21:') if has('mouse') set mouse=n - call assert_fails('execute "normal! \<MiddleMouse>"', 'E21') + call assert_fails('execute "normal! \<MiddleMouse>"', 'E21:') set mouse& endif @@ -132,7 +134,7 @@ func Test_put_visual_delete_all_lines() let @r = '' normal! VG"rgp call assert_equal(1, line('$')) - close! + bw! endfunc func Test_gp_with_count_leaves_cursor_at_end() @@ -328,6 +330,82 @@ func Test_put_list() bw! endfunc +func Test_iput_multiline() + new + setlocal noexpandtab + call setline(1, "\<Tab>foo") + call setreg('0', "bar\n\<Tab>bar2\nbar3", 'l') + iput + call assert_equal(["\<Tab>bar", "\<Tab>\<Tab>bar2", "\<Tab>bar3"], getline(2, 4)) + setlocal expandtab tabstop=8 shiftwidth=8 noshiftround + iput + call assert_equal([repeat(' ', 8) . "bar", + \ repeat(' ', 16) . "bar2", + \ repeat(' ', 8) . "bar3"], getline(5, 7)) + bw! +endfunc + +func Test_iput_beforeafter_tab() + new + setlocal noexpandtab + call setline(1, "\<Tab>foo") + call setreg('0', "bar", 'l') + iput + call assert_equal(["\<Tab>bar"], getline(2, '$')) + call feedkeys("k", 'x') + iput! + call assert_equal("\<Tab>bar", getline(1)) + call assert_equal("\<Tab>bar", getline(3)) + bw! +endfunc + +func Test_iput_beforeafter_expandtab() + new + setlocal expandtab tabstop=8 shiftwidth=8 noshiftround + call setline(1, "\<Tab>foo") + call setreg('0', "bar", 'l') + iput + call assert_equal([repeat(' ', 8) . "bar"], getline(2, '$')) + :1iput! + call assert_equal(repeat(' ', 8) . "bar", getline(1)) + bw! +endfunc + +func Test_iput_invalidrange() + new + call setreg('0', "bar", 'l') + call assert_fails(':10iput', 'E16:') + bw! +endfunc + +func Test_iput_zero_range() + new + let _var = [getreg('a'), getregtype('a')] + call setreg('a', 'foobar', 'l') + call setline(1, range(1, 2)) + call cursor(1, 1) + 0iput a + call assert_equal(['foobar', '1', '2'], getline(1, '$')) + %d + call setline(1, range(1, 2)) + call cursor(1, 1) + 0iput! a + call assert_equal(['foobar', '1', '2'], getline(1, '$')) + call setreg('a', _var[0], _var[1]) + bw! +endfunc + +func Test_iput_not_put() + new + call setline(1, "\<Tab>foo") + call setreg('0', "bar", 'l') + iput + call assert_equal("\<Tab>bar", getline(2)) + put + call assert_equal("bar", getline(3)) + bw! +endfunc + " Test pasting the '.' register func Test_put_inserted() new |