Skip to content

Commit

Permalink
Fix visual selection w/ ib object
Browse files Browse the repository at this point in the history
Closes vim#6616
  • Loading branch information
LemonBoy committed May 23, 2022
1 parent e8c4a64 commit e846fef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/testdir/test_textobjects.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ func Test_inner_block_with_cpo_M_right_backslash()
call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green'])
endfunc

func Test_inner_block_single_char()
new
call setline(1, "(a)")

set selection=inclusive
let @"=''
call assert_nobeep('norm! 0faviby')
call assert_equal('a', @")

set selection=exclusive
let @"=''
call assert_nobeep('norm! 0faviby')
call assert_equal('a', @")

set selection&
bwipe!
endfunc

func Test_quote_selection_selection_exclusive()
new
call setline(1, "a 'bcde' f")
Expand Down
2 changes: 2 additions & 0 deletions src/textobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,10 @@ current_block(
/*
* In Visual mode, when the resulting area is not bigger than what we
* started with, extend it to the next block, and then exclude again.
* Don't try to expand the area if the area is empty.
*/
if (!LT_POS(start_pos, old_start) && !LT_POS(old_end, curwin->w_cursor)
&& !EQUAL_POS(start_pos, curwin->w_cursor)
&& VIsual_active)
{
curwin->w_cursor = old_start;
Expand Down

0 comments on commit e846fef

Please sign in to comment.