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