diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-07-02 18:27:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-07-02 18:27:48 +0200 |
commit | 81439a6d1b45bbef9c8dc03d76f01b6a8165e2ce (patch) | |
tree | 1e15dcd6ee0a9487a4d06c7db9bc71c6c9460084 /src | |
parent | dab70c63e16687b2cb784a3a9eecdbea6ecd7065 (diff) | |
download | vim-git-81439a6d1b45bbef9c8dc03d76f01b6a8165e2ce.tar.gz |
updated for version 7.4.350v7.4.350
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/misc1.c | 31 | ||||
-rw-r--r-- | src/testdir/test3.in | 4 | ||||
-rw-r--r-- | src/testdir/test3.ok | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 39 insertions, 2 deletions
diff --git a/src/misc1.c b/src/misc1.c index c0a045d14..fbebd5aec 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -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 * @@ -6645,6 +6645,32 @@ find_match_paren(ind_maxparen) /* XXX */ } /* + * 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 * matching paren above the cursor line doesn't find a match because of @@ -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 { diff --git a/src/testdir/test3.in b/src/testdir/test3.in index a7543945c..a33a4cba6 100644 --- a/src/testdir/test3.in +++ b/src/testdir/test3.in @@ -1950,6 +1950,10 @@ ENDTEST JSSTART (function($){ +if (cond && +cond) { +stmt; +} var class_name='myclass'; function private_method() { diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok index d73a5e123..edd9e236a 100644 --- a/src/testdir/test3.ok +++ b/src/testdir/test3.ok @@ -1728,6 +1728,10 @@ JSEND JSSTART (function($){ + if (cond && + cond) { + stmt; + } var class_name='myclass'; function private_method() { diff --git a/src/version.c b/src/version.c index e86b43ddf..82685ce56 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 350, +/**/ 349, /**/ 348, |