diff options
author | Bram Moolenaar <bram@vim.org> | 2014-08-06 17:44:14 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2014-08-06 17:44:14 +0200 |
commit | 91e30a1aed1abc50039e597890427a849ef114dd (patch) | |
tree | d3cc4d25e541c4bbb111c90bb9f0b4fd285b8748 | |
parent | 5d5ef92275da69fed08da56a949d3d364f079d1d (diff) | |
download | vim-91e30a1aed1abc50039e597890427a849ef114dd.tar.gz |
Problem: C indent is wrong below an if with wrapped condition followed by
curly braces. (Trevor Powell)
Solution: Make a copy of tryposBrace.
-rw-r--r-- | src/misc1.c | 5 | ||||
-rw-r--r-- | src/testdir/test3.in | 8 | ||||
-rw-r--r-- | src/testdir/test3.ok | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 23 insertions, 0 deletions
diff --git a/src/misc1.c b/src/misc1.c index 2c28aae8..6ae72cfb 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -6995,6 +6995,7 @@ get_c_indent() char_u *linecopy; pos_T *trypos; pos_T *tryposBrace = NULL; + pos_T tryposBraceCopy; pos_T our_paren_pos; char_u *start; int start_brace; @@ -7532,7 +7533,11 @@ get_c_indent() /* * We are inside braces, there is a { before this line at the position * stored in tryposBrace. + * Make a copy of tryposBrace, it may point to pos_copy inside + * find_start_brace(), which may be changed somewhere. */ + tryposBraceCopy = *tryposBrace; + tryposBrace = &tryposBraceCopy; trypos = tryposBrace; ourscope = trypos->lnum; start = ml_get(ourscope); diff --git a/src/testdir/test3.in b/src/testdir/test3.in index de867003..7757569e 100644 --- a/src/testdir/test3.in +++ b/src/testdir/test3.in @@ -464,6 +464,14 @@ label: if (asdf && asdfasdf } +{ +for ( int i = 0; + i < 10; i++ ) +{ +} + i = 0; +} + class bob { int foo() {return 1;} diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok index 0d0e76fc..e75de0ff 100644 --- a/src/testdir/test3.ok +++ b/src/testdir/test3.ok @@ -452,6 +452,14 @@ label: if (asdf && asdfasdf } +{ + for ( int i = 0; + i < 10; i++ ) + { + } + i = 0; +} + class bob { int foo() {return 1;} diff --git a/src/version.c b/src/version.c index 082c5fc4..aa641559 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 395, +/**/ 394, /**/ 393, |