Permalink
Browse files

patch 8.0.0622: selecting quoted text fails with 'selection' "exclusive"

Problem:    Using a text object to select quoted text fails when 'selection'
            is set to "exclusive". (Guraga)
Solution:   Swap cursor and visual start position. (Christian Brabandt,
            closes #1687)
  • Loading branch information...
brammool committed Jun 5, 2017
1 parent 8ad80de commit c5e2b040b490c2f4dd50c945840bc176bfcccb29
Showing with 33 additions and 10 deletions.
  1. +13 −2 src/search.c
  2. +18 −8 src/testdir/test_textobjects.vim
  3. +2 −0 src/version.c
View
@@ -4364,16 +4364,27 @@ current_quote(
int selected_quote = FALSE; /* Has quote inside selection */
int i;
/* Correct cursor when 'selection' is exclusive */
/* Correct cursor when 'selection' is "exclusive". */
if (VIsual_active)
{
/* this only works within one line */
if (VIsual.lnum != curwin->w_cursor.lnum)
return FALSE;
vis_bef_curs = LT_POS(VIsual, curwin->w_cursor);
if (*p_sel == 'e' && vis_bef_curs)
if (*p_sel == 'e')
{
if (!vis_bef_curs)
{
/* VIsual needs to be start of Visual selection. */
pos_T t = curwin->w_cursor;
curwin->w_cursor = VIsual;
VIsual = t;
vis_bef_curs = TRUE;
}
dec_cursor();
}
vis_empty = EQUAL_POS(VIsual, curwin->w_cursor);
}
@@ -5,7 +5,7 @@ if !has('textobjects')
endif
set belloff=all
function! CpoM(line, useM, expected)
func CpoM(line, useM, expected)
new
if a:useM
@@ -29,16 +29,26 @@ function! CpoM(line, useM, expected)
call assert_equal(getreg('"'), a:expected[2])
q!
endfunction
endfunc
function! Test_inner_block_without_cpo_M()
func Test_inner_block_without_cpo_M()
call CpoM('(red \(blue) green)', 0, ['red \(blue', 'red \(blue', ''])
endfunction
endfunc
function! Test_inner_block_with_cpo_M_left_backslash()
func Test_inner_block_with_cpo_M_left_backslash()
call CpoM('(red \(blue) green)', 1, ['red \(blue) green', 'blue', 'red \(blue) green'])
endfunction
endfunc
function! Test_inner_block_with_cpo_M_right_backslash()
func Test_inner_block_with_cpo_M_right_backslash()
call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green'])
endfunction
endfunc
func Test_quote_selection_selection_exclusive()
new
call setline(1, "a 'bcde' f")
set selection=exclusive
exe "norm! fdvhi'y"
call assert_equal('bcde', @")
set selection&vim
bw!
endfunc
View
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
622,
/**/
621,
/**/

0 comments on commit c5e2b04

Please sign in to comment.