From f38f86b1ad8ad2ae3236f36e56fcdb416f679e65 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Jan 2024 06:19:19 +0800 Subject: vim-patch:9.1.0007: can select empty inner text blocks Problem: can select empty inner text blocks (laurentalacoque) Solution: make selecting empty inner text blocks an error textobjects: Make selecting inner empty blocks an error fixes: vim/vim#13514 closes: vim/vim#13523 https://github.com/vim/vim/commit/ad4d7f446dc6754bde212234d46f4849b520b6e0 Co-authored-by: Christian Brabandt --- test/old/testdir/test_textobjects.vim | 114 +++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) (limited to 'test/old/testdir/test_textobjects.vim') diff --git a/test/old/testdir/test_textobjects.vim b/test/old/testdir/test_textobjects.vim index f21d6fcb99..72c7338a96 100644 --- a/test/old/testdir/test_textobjects.vim +++ b/test/old/testdir/test_textobjects.vim @@ -402,7 +402,7 @@ func Test_paragraph() call assert_beeps("normal Vipip") exe "normal \" - close! + bw! endfunc " Tests for text object aw @@ -608,7 +608,7 @@ func Test_textobj_quote() normal $hhyi" call assert_equal('bar', @") - close! + bw! endfunc " Test for i(, i<, etc. when cursor is in front of a block @@ -640,7 +640,115 @@ func Test_textobj_find_paren_forward() normal 0di) call assert_equal('foo ()', getline(1)) - close! + bw! +endfunc + +func Test_inner_block_empty_paren() + new + call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f(viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('(', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f(viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('(', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f(viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('(', @") + bwipe! +endfunc + +func Test_inner_block_empty_bracket() + new + call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f[viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('[', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f[viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('[', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f[viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('[', @") + bwipe! +endfunc + +func Test_inner_block_empty_brace() + new + call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f{viby","xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('{', @") + + " Example 2 + call cursor(3, 1) + let @" = '' + call assert_beeps('call feedkeys("0f{viby", "xt")') + call assert_equal(7, getpos('.')[2]) + call assert_equal('{', @") + + " Example 3 + call cursor(6, 1) + let @" = '' + call assert_beeps('call feedkeys("0f{viby", "xt")') + call assert_equal(3, getpos('.')[2]) + call assert_equal('{', @") + bwipe! +endfunc + +func Test_inner_block_empty_lessthan() + new + call setline(1, ["<>", "", "<", ">", "", "<><>"]) + + " Example 1 + call cursor(1, 1) + let @" = '' + call assert_beeps(':call feedkeys("0f Date: Sat, 6 Jan 2024 06:24:15 +0800 Subject: vim-patch:9.1.0012: regression with empty inner blocks introduced Problem: regression with empty inner blocks introduced (after v9.1.0007) Solution: Set correct cursor position, Check for visual mode being active (Maxim Kim) relates: vim/vim#13514 closes: vim/vim#13819 https://github.com/vim/vim/commit/3779516988f14f2070d827514c79383334a0946b Co-authored-by: Maxim Kim --- test/old/testdir/test_textobjects.vim | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'test/old/testdir/test_textobjects.vim') diff --git a/test/old/testdir/test_textobjects.vim b/test/old/testdir/test_textobjects.vim index 72c7338a96..3b86ae97da 100644 --- a/test/old/testdir/test_textobjects.vim +++ b/test/old/testdir/test_textobjects.vim @@ -645,7 +645,7 @@ endfunc func Test_inner_block_empty_paren() new - call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"]) + call setline(1, ["(text)()", "", "(text)(", ")", "", "()()", "", "text()"]) " Example 1 call cursor(1, 1) @@ -667,12 +667,18 @@ func Test_inner_block_empty_paren() call assert_beeps('call feedkeys("0f(viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('(', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0cibtext", "xt") + call assert_equal("text(text)", getline('.')) + bwipe! endfunc func Test_inner_block_empty_bracket() new - call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"]) + call setline(1, ["[text][]", "", "[text][", "]", "", "[][]", "", "text[]"]) " Example 1 call cursor(1, 1) @@ -694,12 +700,18 @@ func Test_inner_block_empty_bracket() call assert_beeps('call feedkeys("0f[viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('[', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0ci[text", "xt") + call assert_equal("text[text]", getline('.')) + bwipe! endfunc func Test_inner_block_empty_brace() new - call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"]) + call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}", "", "text{}"]) " Example 1 call cursor(1, 1) @@ -721,6 +733,12 @@ func Test_inner_block_empty_brace() call assert_beeps('call feedkeys("0f{viby", "xt")') call assert_equal(3, getpos('.')[2]) call assert_equal('{', @") + + " Change empty inner block + call cursor(8, 1) + call feedkeys("0ciBtext", "xt") + call assert_equal("text{text}", getline('.')) + bwipe! endfunc -- cgit