3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.350
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.350
3ef2ca
Problem:    Using C indenting for Javascript does not work well for a {} block
3ef2ca
	    inside parenthesis.
3ef2ca
Solution:   When looking for a matching paren ignore one that is before the
3ef2ca
	    start of a {} block.
3ef2ca
Files:	    src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.349/src/misc1.c	2014-07-02 17:02:29.722212319 +0200
3ef2ca
--- src/misc1.c	2014-07-02 18:09:39.670274070 +0200
3ef2ca
***************
3ef2ca
*** 6614,6620 ****
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Find the matching '(', failing if it is in a comment.
3ef2ca
   * Return NULL if no match found.
3ef2ca
   */
3ef2ca
      static pos_T *
3ef2ca
--- 6614,6620 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Find the matching '(', ignoring it if it is in a comment.
3ef2ca
   * Return NULL if no match found.
3ef2ca
   */
3ef2ca
      static pos_T *
3ef2ca
***************
3ef2ca
*** 6645,6650 ****
3ef2ca
--- 6645,6676 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
+  * Find the matching '(', ignoring it if it is in a comment or before an
3ef2ca
+  * unmatched {.
3ef2ca
+  * Return NULL if no match found.
3ef2ca
+  */
3ef2ca
+     static pos_T *
3ef2ca
+ find_match_paren_after_brace(ind_maxparen)	    /* XXX */
3ef2ca
+     int		ind_maxparen;
3ef2ca
+ {
3ef2ca
+     pos_T	*trypos = find_match_paren(ind_maxparen);
3ef2ca
+ 
3ef2ca
+     if (trypos != NULL)
3ef2ca
+     {
3ef2ca
+ 	pos_T	*tryposBrace = find_start_brace();
3ef2ca
+ 
3ef2ca
+ 	/* If both an unmatched '(' and '{' is found.  Ignore the '('
3ef2ca
+ 	 * position if the '{' is further down. */
3ef2ca
+ 	if (tryposBrace != NULL
3ef2ca
+ 		&& (trypos->lnum != tryposBrace->lnum
3ef2ca
+ 		    ? trypos->lnum < tryposBrace->lnum
3ef2ca
+ 		    : trypos->col < tryposBrace->col))
3ef2ca
+ 	    trypos = NULL;
3ef2ca
+     }
3ef2ca
+     return trypos;
3ef2ca
+ }
3ef2ca
+ 
3ef2ca
+ /*
3ef2ca
   * Return ind_maxparen corrected for the difference in line number between the
3ef2ca
   * cursor position and "startpos".  This makes sure that searching for a
3ef2ca
   * matching paren above the cursor line doesn't find a match because of
3ef2ca
***************
3ef2ca
*** 7419,7425 ****
3ef2ca
  		{
3ef2ca
  		    curwin->w_cursor.lnum = our_paren_pos.lnum;
3ef2ca
  		    curwin->w_cursor.col = col;
3ef2ca
! 		    if (find_match_paren(curbuf->b_ind_maxparen) != NULL)
3ef2ca
  			amount += curbuf->b_ind_unclosed2;
3ef2ca
  		    else
3ef2ca
  		    {
3ef2ca
--- 7445,7452 ----
3ef2ca
  		{
3ef2ca
  		    curwin->w_cursor.lnum = our_paren_pos.lnum;
3ef2ca
  		    curwin->w_cursor.col = col;
3ef2ca
! 		    if (find_match_paren_after_brace(curbuf->b_ind_maxparen)
3ef2ca
! 								      != NULL)
3ef2ca
  			amount += curbuf->b_ind_unclosed2;
3ef2ca
  		    else
3ef2ca
  		    {
3ef2ca
*** ../vim-7.4.349/src/testdir/test3.in	2013-03-07 12:39:35.000000000 +0100
3ef2ca
--- src/testdir/test3.in	2014-07-02 18:08:06.430272641 +0200
3ef2ca
***************
3ef2ca
*** 1950,1955 ****
3ef2ca
--- 1950,1959 ----
3ef2ca
  JSSTART
3ef2ca
  (function($){
3ef2ca
  
3ef2ca
+ if (cond &&
3ef2ca
+ cond) {
3ef2ca
+ stmt;
3ef2ca
+ }
3ef2ca
  var class_name='myclass';
3ef2ca
  
3ef2ca
  function private_method() {
3ef2ca
*** ../vim-7.4.349/src/testdir/test3.ok	2013-03-07 12:40:03.000000000 +0100
3ef2ca
--- src/testdir/test3.ok	2014-07-02 18:09:14.470273684 +0200
3ef2ca
***************
3ef2ca
*** 1728,1733 ****
3ef2ca
--- 1728,1737 ----
3ef2ca
  JSSTART
3ef2ca
  (function($){
3ef2ca
  
3ef2ca
+ 	if (cond &&
3ef2ca
+ 			cond) {
3ef2ca
+ 		stmt;
3ef2ca
+ 	}
3ef2ca
  	var class_name='myclass';
3ef2ca
  
3ef2ca
  	function private_method() {
3ef2ca
*** ../vim-7.4.349/src/version.c	2014-07-02 17:16:51.334225522 +0200
3ef2ca
--- src/version.c	2014-07-02 18:06:31.330271184 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     350,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
FATHER:    You killed eight wedding guests in all!
3ef2ca
LAUNCELOT: Er, Well ... the thing is ... I thought your son was a lady.
3ef2ca
FATHER:    I can understand that.
3ef2ca
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///