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