changeset 6675:24e0b6dd52e1 v7.4.662

updated for version 7.4.662 Problem: When 'M' is in the 'cpo' option then selecting a text object in parenthesis does not work correctly. Solution: Keep 'M' in 'cpo' when finding a match. (Hirohito Higashi)
author Bram Moolenaar <bram@vim.org>
date Fri, 13 Mar 2015 15:03:00 +0100
parents 72f4e9a8a05e
children a0198cebc8f4
files src/search.c src/testdir/Make_amiga.mak src/testdir/Make_dos.mak src/testdir/Make_ming.mak src/testdir/Make_os2.mak src/testdir/Make_vms.mms src/testdir/Makefile src/testdir/test_textobjects.in src/testdir/test_textobjects.ok src/version.c
diffstat 10 files changed, 69 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c
+++ b/src/search.c
@@ -3583,10 +3583,11 @@ current_block(oap, count, include, what,
     /*
      * Search backwards for unclosed '(', '{', etc..
      * Put this position in start_pos.
-     * Ignore quotes here.
+     * Ignore quotes here.  Keep the "M" flag in 'cpo', as that is what the
+     * user wants.
      */
     save_cpo = p_cpo;
-    p_cpo = (char_u *)"%";
+    p_cpo = (char_u *)(vim_strchr(p_cpo, CPO_MATCHBSL) != NULL ? "%M" : "%");
     while (count-- > 0)
     {
 	if ((pos = findmatch(NULL, what)) == NULL)
--- a/src/testdir/Make_amiga.mak
+++ b/src/testdir/Make_amiga.mak
@@ -53,6 +53,7 @@ SCRIPTS = test1.out test3.out test4.out 
 		test_options.out \
 		test_qf_title.out \
 		test_signs.out \
+		test_textobjects.out \
 		test_utf8.out
 
 .SUFFIXES: .in .out
@@ -194,4 +195,5 @@ test_nested_function.out: test_nested_fu
 test_options.out: test_options.in
 test_qf_title.out: test_qf_title.in
 test_signs.out: test_signs.in
+test_textobjects.out: test_textobjects.in
 test_utf8.out: test_utf8.in
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -52,6 +52,7 @@ SCRIPTS =	test3.out test4.out test5.out 
 		test_options.out \
 		test_qf_title.out \
 		test_signs.out \
+		test_textobjects.out \
 		test_utf8.out
 
 SCRIPTS32 =	test50.out test70.out
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -74,6 +74,7 @@ SCRIPTS =	test3.out test4.out test5.out 
 		test_options.out \
 		test_qf_title.out \
 		test_signs.out \
+		test_textobjects.out \
 		test_utf8.out
 
 SCRIPTS32 =	test50.out test70.out
--- a/src/testdir/Make_os2.mak
+++ b/src/testdir/Make_os2.mak
@@ -54,6 +54,7 @@ SCRIPTS = test1.out test3.out test4.out 
 		test_options.out \
 		test_qf_title.out \
 		test_signs.out \
+		test_textobjects.out \
 		test_utf8.out
 
 SCRIPTS_BENCH = bench_re_freeze.out
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -4,7 +4,7 @@
 # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
 #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
 #
-# Last change:  2014 Dec 13
+# Last change:  2015 Mar 13
 #
 # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
 # Edit the lines in the Configuration section below to select.
@@ -113,6 +113,7 @@ SCRIPT = test1.out  test2.out  test3.out
 	 test_options.out \
 	 test_qf_title.out \
 	 test_signs.out \
+	 test_textobjects.out \
 	 test_utf8.out
 
 # Known problems:
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -50,6 +50,7 @@ SCRIPTS = test1.out test2.out test3.out 
 		test_options.out \
 		test_qf_title.out \
 		test_signs.out \
+		test_textobjects.out \
 		test_utf8.out
 
 SCRIPTS_GUI = test16.out
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_textobjects.in
@@ -0,0 +1,40 @@
+Tests for text-objects     vim: set ft=vim :
+
+STARTTEST
+:so small.vim
+:if !has('textobjects') | e! test.ok | wq! test.out | endif
+:set nocompatible
+:"
+:function SelectionOut(data)
+:  new
+:  call setline(1, a:data)
+:  call setreg('"', '')
+:  normal! ggfrmavi)y
+:  $put =getreg('\"')
+:  call setreg('"', '')
+:  normal! `afbmavi)y
+:  $put =getreg('\"')
+:  call setreg('"', '')
+:  normal! `afgmavi)y
+:  $put =getreg('\"')
+:  %yank a
+:  q!
+:  $put =getreg('a')
+:endfunction
+:"
+:$put ='# Test for vi) without cpo-M'
+:set cpo-=M
+:call SelectionOut('(red \(blue) green)')
+:"
+:$put ='# Test for vi) with cpo-M #1'
+:set cpo+=M
+:call SelectionOut('(red \(blue) green)')
+:"
+:$put ='# Test for vi) with cpo-M #2'
+:set cpo+=M
+:call SelectionOut('(red (blue\) green)')
+:/^Results/,$w test.out
+:qa!
+ENDTEST
+
+Results of text-objects
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_textobjects.ok
@@ -0,0 +1,16 @@
+Results of text-objects
+# Test for vi) without cpo-M
+(red \(blue) green)
+red \(blue
+red \(blue
+
+# Test for vi) with cpo-M #1
+(red \(blue) green)
+red \(blue) green
+blue
+red \(blue) green
+# Test for vi) with cpo-M #2
+(red (blue\) green)
+red (blue\) green
+blue\
+red (blue\) green
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    662,
+/**/
     661,
 /**/
     660,