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;
|
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.
|
/// @returns NULL or the found match.
|
||||||
static pos_T *find_match_paren(int ind_maxparen)
|
static pos_T *find_match_paren(int ind_maxparen)
|
||||||
{
|
{
|
||||||
@ -1223,6 +1223,29 @@ static pos_T *find_match_paren(int ind_maxparen)
|
|||||||
return trypos;
|
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
|
* Return ind_maxparen corrected for the difference in line number between the
|
||||||
* cursor position and "startpos". This makes sure that searching for a
|
* cursor position and "startpos". This makes sure that searching for a
|
||||||
@ -1934,13 +1957,14 @@ int get_c_indent(void)
|
|||||||
else {
|
else {
|
||||||
curwin->w_cursor.lnum = our_paren_pos.lnum;
|
curwin->w_cursor.lnum = our_paren_pos.lnum;
|
||||||
curwin->w_cursor.col = col;
|
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;
|
amount += curbuf->b_ind_unclosed2;
|
||||||
else {
|
} else {
|
||||||
if (is_if_for_while)
|
if (is_if_for_while) {
|
||||||
amount += curbuf->b_ind_if_for_while;
|
amount += curbuf->b_ind_if_for_while;
|
||||||
else
|
} else {
|
||||||
amount += curbuf->b_ind_unclosed;
|
amount += curbuf->b_ind_unclosed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1950,6 +1950,10 @@ ENDTEST
|
|||||||
JSSTART
|
JSSTART
|
||||||
(function($){
|
(function($){
|
||||||
|
|
||||||
|
if (cond &&
|
||||||
|
cond) {
|
||||||
|
stmt;
|
||||||
|
}
|
||||||
var class_name='myclass';
|
var class_name='myclass';
|
||||||
|
|
||||||
function private_method() {
|
function private_method() {
|
||||||
|
@ -1728,6 +1728,10 @@ JSEND
|
|||||||
JSSTART
|
JSSTART
|
||||||
(function($){
|
(function($){
|
||||||
|
|
||||||
|
if (cond &&
|
||||||
|
cond) {
|
||||||
|
stmt;
|
||||||
|
}
|
||||||
var class_name='myclass';
|
var class_name='myclass';
|
||||||
|
|
||||||
function private_method() {
|
function private_method() {
|
||||||
|
@ -387,7 +387,7 @@ static int included_patches[] = {
|
|||||||
353,
|
353,
|
||||||
352,
|
352,
|
||||||
351,
|
351,
|
||||||
//350,
|
350,
|
||||||
349,
|
349,
|
||||||
348,
|
348,
|
||||||
347,
|
347,
|
||||||
|
Loading…
Reference in New Issue
Block a user