Karsten Hopp 6a5e4b
To: vim_dev@googlegroups.com
Karsten Hopp 6a5e4b
Subject: Patch 7.3.201
Karsten Hopp 6a5e4b
Fcc: outbox
Karsten Hopp 6a5e4b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6a5e4b
Mime-Version: 1.0
Karsten Hopp 6a5e4b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 6a5e4b
Content-Transfer-Encoding: 8bit
Karsten Hopp 6a5e4b
------------
Karsten Hopp 6a5e4b
Karsten Hopp 6a5e4b
Patch 7.3.201 (after 7.3.195)
Karsten Hopp 6a5e4b
Problem:    "} else" still causes following lines to be indented too much.
Karsten Hopp 6a5e4b
Solution:   Better detection for the "else" block. (Lech Lorens)
Karsten Hopp 6a5e4b
Files:	    src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
Karsten Hopp 6a5e4b
Karsten Hopp 6a5e4b
Karsten Hopp 6a5e4b
*** ../mercurial/vim73/src/misc1.c	2011-05-19 16:35:05.000000000 +0200
Karsten Hopp 6a5e4b
--- src/misc1.c	2011-05-25 13:29:45.000000000 +0200
Karsten Hopp 6a5e4b
***************
Karsten Hopp 6a5e4b
*** 7541,7557 ****
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
  			/*
Karsten Hopp 6a5e4b
  			 * When searching for a terminated line, don't use the
Karsten Hopp 6a5e4b
! 			 * one between the "if" and the "else".
Karsten Hopp 6a5e4b
  			 * Need to use the scope of this "else".  XXX
Karsten Hopp 6a5e4b
  			 * If whilelevel != 0 continue looking for a "do {".
Karsten Hopp 6a5e4b
  			 */
Karsten Hopp 6a5e4b
! 			if (cin_iselse(l)
Karsten Hopp 6a5e4b
! 				&& whilelevel == 0
Karsten Hopp 6a5e4b
! 				&& ((trypos = find_start_brace(ind_maxcomment))
Karsten Hopp 6a5e4b
! 								    == NULL
Karsten Hopp 6a5e4b
  				    || find_match(LOOKFOR_IF, trypos->lnum,
Karsten Hopp 6a5e4b
! 					ind_maxparen, ind_maxcomment) == FAIL))
Karsten Hopp 6a5e4b
! 			    break;
Karsten Hopp 6a5e4b
  		    }
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
  		    /*
Karsten Hopp 6a5e4b
--- 7541,7565 ----
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
  			/*
Karsten Hopp 6a5e4b
  			 * When searching for a terminated line, don't use the
Karsten Hopp 6a5e4b
! 			 * one between the "if" and the matching "else".
Karsten Hopp 6a5e4b
  			 * Need to use the scope of this "else".  XXX
Karsten Hopp 6a5e4b
  			 * If whilelevel != 0 continue looking for a "do {".
Karsten Hopp 6a5e4b
  			 */
Karsten Hopp 6a5e4b
! 			if (cin_iselse(l) && whilelevel == 0)
Karsten Hopp 6a5e4b
! 			{
Karsten Hopp 6a5e4b
! 			    /* If we're looking at "} else", let's make sure we
Karsten Hopp 6a5e4b
! 			     * find the opening brace of the enclosing scope,
Karsten Hopp 6a5e4b
! 			     * not the one from "if () {". */
Karsten Hopp 6a5e4b
! 			    if (*l == '}')
Karsten Hopp 6a5e4b
! 				curwin->w_cursor.col =
Karsten Hopp 6a5e4b
! 						   (l - ml_get_curline()) + 1;
Karsten Hopp 6a5e4b
! 
Karsten Hopp 6a5e4b
! 			    if ((trypos = find_start_brace(ind_maxcomment))
Karsten Hopp 6a5e4b
! 								       == NULL
Karsten Hopp 6a5e4b
  				    || find_match(LOOKFOR_IF, trypos->lnum,
Karsten Hopp 6a5e4b
! 					ind_maxparen, ind_maxcomment) == FAIL)
Karsten Hopp 6a5e4b
! 				break;
Karsten Hopp 6a5e4b
! 			}
Karsten Hopp 6a5e4b
  		    }
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
  		    /*
Karsten Hopp 6a5e4b
*** ../mercurial/vim73/src/testdir/test3.in	2011-05-19 16:35:05.000000000 +0200
Karsten Hopp 6a5e4b
--- src/testdir/test3.in	2011-05-25 13:23:51.000000000 +0200
Karsten Hopp 6a5e4b
***************
Karsten Hopp 6a5e4b
*** 1413,1418 ****
Karsten Hopp 6a5e4b
--- 1413,1433 ----
Karsten Hopp 6a5e4b
  }
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
  STARTTEST
Karsten Hopp 6a5e4b
+ :set cino&
Karsten Hopp 6a5e4b
+ 2kdd=][
Karsten Hopp 6a5e4b
+ ENDTEST
Karsten Hopp 6a5e4b
+ 
Karsten Hopp 6a5e4b
+ void func(void)
Karsten Hopp 6a5e4b
+ {
Karsten Hopp 6a5e4b
+ 	for (int i = 0; i < 10; ++i)
Karsten Hopp 6a5e4b
+ 		if (i & 1) {
Karsten Hopp 6a5e4b
+ 			foo(1);
Karsten Hopp 6a5e4b
+ 		} else
Karsten Hopp 6a5e4b
+ 			foo(0);
Karsten Hopp 6a5e4b
+ baz();
Karsten Hopp 6a5e4b
+ }
Karsten Hopp 6a5e4b
+ 
Karsten Hopp 6a5e4b
+ STARTTEST
Karsten Hopp 6a5e4b
  :g/^STARTTEST/.,/^ENDTEST/d
Karsten Hopp 6a5e4b
  :1;/start of AUTO/,$wq! test.out
Karsten Hopp 6a5e4b
  ENDTEST
Karsten Hopp 6a5e4b
*** ../mercurial/vim73/src/testdir/test3.ok	2011-05-19 16:35:05.000000000 +0200
Karsten Hopp 6a5e4b
--- src/testdir/test3.ok	2011-05-25 13:23:51.000000000 +0200
Karsten Hopp 6a5e4b
***************
Karsten Hopp 6a5e4b
*** 1262,1264 ****
Karsten Hopp 6a5e4b
--- 1262,1275 ----
Karsten Hopp 6a5e4b
  	foo();
Karsten Hopp 6a5e4b
  }
Karsten Hopp 6a5e4b
  
Karsten Hopp 6a5e4b
+ 
Karsten Hopp 6a5e4b
+ void func(void)
Karsten Hopp 6a5e4b
+ {
Karsten Hopp 6a5e4b
+ 	for (int i = 0; i < 10; ++i)
Karsten Hopp 6a5e4b
+ 		if (i & 1) {
Karsten Hopp 6a5e4b
+ 			foo(1);
Karsten Hopp 6a5e4b
+ 		} else
Karsten Hopp 6a5e4b
+ 			foo(0);
Karsten Hopp 6a5e4b
+ 	baz();
Karsten Hopp 6a5e4b
+ }
Karsten Hopp 6a5e4b
+ 
Karsten Hopp 6a5e4b
*** ../vim-7.3.200/src/version.c	2011-05-25 12:51:17.000000000 +0200
Karsten Hopp 6a5e4b
--- src/version.c	2011-05-25 13:33:16.000000000 +0200
Karsten Hopp 6a5e4b
***************
Karsten Hopp 6a5e4b
*** 711,712 ****
Karsten Hopp 6a5e4b
--- 711,714 ----
Karsten Hopp 6a5e4b
  {   /* Add new patch number below this line */
Karsten Hopp 6a5e4b
+ /**/
Karsten Hopp 6a5e4b
+     201,
Karsten Hopp 6a5e4b
  /**/
Karsten Hopp 6a5e4b
Karsten Hopp 6a5e4b
-- 
Karsten Hopp 6a5e4b
Laughing helps. It's like jogging on the inside.
Karsten Hopp 6a5e4b
Karsten Hopp 6a5e4b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6a5e4b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6a5e4b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 6a5e4b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///