summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-05 16:37:07 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-05 16:37:07 +0200
commitc5e2b040b490c2f4dd50c945840bc176bfcccb29 (patch)
tree6d837ebbcd51c6439deed9b3ce2b5a551c91d0a9 /src
parent8ad80dea089ffeb1a845199c013e9bb4be1cd22e (diff)
downloadvim-git-c5e2b040b490c2f4dd50c945840bc176bfcccb29.tar.gz
patch 8.0.0622: selecting quoted text fails with 'selection' "exclusive"v8.0.0622
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)
Diffstat (limited to 'src')
-rw-r--r--src/search.c15
-rw-r--r--src/testdir/test_textobjects.vim26
-rw-r--r--src/version.c2
3 files changed, 33 insertions, 10 deletions
diff --git a/src/search.c b/src/search.c
index bd5d08c34..c1197160a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4364,7 +4364,7 @@ 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 */
@@ -4372,8 +4372,19 @@ current_quote(
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);
}
diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim
index 5e67f2528..dca8f6320 100644
--- a/src/testdir/test_textobjects.vim
+++ b/src/testdir/test_textobjects.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index bd02b5a92..0304389b3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 622,
+/**/
621,
/**/
620,