mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.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. https://code.google.com/p/vim/source/detail?r=v7-4-350
This commit is contained in:
parent
949fb9721f
commit
12b3f49ea1
@ -1198,7 +1198,7 @@ static pos_T *find_start_brace(void)
|
||||
return trypos;
|
||||
}
|
||||
|
||||
/// Find the matching '(', failing if it is in a comment.
|
||||
/// Find the matching '(', ignoring it if it is in a comment.
|
||||
/// @returns NULL or the found match.
|
||||
static pos_T *find_match_paren(int ind_maxparen)
|
||||
{
|
||||
@ -1223,6 +1223,29 @@ static pos_T *find_match_paren(int ind_maxparen)
|
||||
return trypos;
|
||||
}
|
||||
|
||||
/// Find the matching '(', ignoring it if it is in a comment or before an
|
||||
/// unmatched {.
|
||||
/// @returns NULL or the found match.
|
||||
static pos_T *find_match_paren_after_brace(int ind_maxparen)
|
||||
{
|
||||
pos_T *trypos = find_match_paren(ind_maxparen);
|
||||
if (trypos == NULL) {
|
||||
return 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
|
||||
@ -1934,15 +1957,16 @@ int get_c_indent(void)
|
||||
else {
|
||||
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)) {
|
||||
amount += curbuf->b_ind_unclosed2;
|
||||
else {
|
||||
if (is_if_for_while)
|
||||
} else {
|
||||
if (is_if_for_while) {
|
||||
amount += curbuf->b_ind_if_for_while;
|
||||
else
|
||||
} else {
|
||||
amount += curbuf->b_ind_unclosed;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* For a line starting with ')' use the minimum of the two
|
||||
* positions, to avoid giving it more indent than the previous
|
||||
|
@ -1950,6 +1950,10 @@ ENDTEST
|
||||
JSSTART
|
||||
(function($){
|
||||
|
||||
if (cond &&
|
||||
cond) {
|
||||
stmt;
|
||||
}
|
||||
var class_name='myclass';
|
||||
|
||||
function private_method() {
|
||||
|
@ -1728,6 +1728,10 @@ JSEND
|
||||
JSSTART
|
||||
(function($){
|
||||
|
||||
if (cond &&
|
||||
cond) {
|
||||
stmt;
|
||||
}
|
||||
var class_name='myclass';
|
||||
|
||||
function private_method() {
|
||||
|
@ -387,7 +387,7 @@ static int included_patches[] = {
|
||||
353,
|
||||
352,
|
||||
351,
|
||||
//350,
|
||||
350,
|
||||
349,
|
||||
348,
|
||||
347,
|
||||
|
Loading…
Reference in New Issue
Block a user