]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.350 v7.4.350
authorBram Moolenaar <Bram@vim.org>
Wed, 2 Jul 2014 16:27:48 +0000 (18:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 2 Jul 2014 16:27:48 +0000 (18:27 +0200)
Problem:    Using C indenting for Javascript does not work well for a {} block
            inside parenthesis.
Solution:   When looking for a matching paren ignore one that is before the
            start of a {} block.

src/misc1.c
src/testdir/test3.in
src/testdir/test3.ok
src/version.c

index c0a045d14dfe2470619e3ecf3f5632db5f45a7f9..fbebd5aec08d19157a39c3b43dfa5a84fcdf37cb 100644 (file)
@@ -6614,7 +6614,7 @@ find_start_brace()            /* XXX */
 }
 
 /*
- * Find the matching '(', failing if it is in a comment.
+ * Find the matching '(', ignoring it if it is in a comment.
  * Return NULL if no match found.
  */
     static pos_T *
@@ -6644,6 +6644,32 @@ find_match_paren(ind_maxparen)       /* XXX */
     return trypos;
 }
 
+/*
+ * Find the matching '(', ignoring it if it is in a comment or before an
+ * unmatched {.
+ * Return NULL if no match found.
+ */
+    static pos_T *
+find_match_paren_after_brace(ind_maxparen)         /* XXX */
+    int                ind_maxparen;
+{
+    pos_T      *trypos = find_match_paren(ind_maxparen);
+
+    if (trypos != NULL)
+    {
+       pos_T   *tryposBrace = find_start_brace();
+
+       /* If both an unmatched '(' and '{' is found.  Ignore the '('
+        * position if the '{' is further down. */
+       if (tryposBrace != NULL
+               && (trypos->lnum != tryposBrace->lnum
+                   ? trypos->lnum < tryposBrace->lnum
+                   : trypos->col < tryposBrace->col))
+           trypos = NULL;
+    }
+    return trypos;
+}
+
 /*
  * Return ind_maxparen corrected for the difference in line number between the
  * cursor position and "startpos".  This makes sure that searching for a
@@ -7419,7 +7445,8 @@ get_c_indent()
                {
                    curwin->w_cursor.lnum = our_paren_pos.lnum;
                    curwin->w_cursor.col = col;
-                   if (find_match_paren(curbuf->b_ind_maxparen) != NULL)
+                   if (find_match_paren_after_brace(curbuf->b_ind_maxparen)
+                                                                     != NULL)
                        amount += curbuf->b_ind_unclosed2;
                    else
                    {
index a7543945c4b8a202371aac1fbbda61b7518f7063..a33a4cba60562dbcc3c913ac1c9e95ab6a53a022 100644 (file)
@@ -1950,6 +1950,10 @@ ENDTEST
 JSSTART
 (function($){
 
+if (cond &&
+cond) {
+stmt;
+}
 var class_name='myclass';
 
 function private_method() {
index d73a5e12303652b10c7d6dd752d15ebf3dfc0914..edd9e236a621e2421f174c3cef90fbec80047f96 100644 (file)
@@ -1728,6 +1728,10 @@ JSEND
 JSSTART
 (function($){
 
+       if (cond &&
+                       cond) {
+               stmt;
+       }
        var class_name='myclass';
 
        function private_method() {
index e86b43ddf3c1c9225b16cc8f856e89df482f74f4..82685ce56d0e07961ca21b5db361d09d909c25e0 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    350,
 /**/
     349,
 /**/