mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
vim-patch:9.2.0610: cindent: closing brace in a comment affects the next line's indent (#40155)
Problem: A '}' inside a // line comment changes the indentation of the
following line inside an enum or struct (rendcrx).
Solution: Stop scanning the line once a line comment is reached, so a brace
inside the comment is no longer mistaken for an unmatched brace.
fixes: vim/vim#20455
closes: vim/vim#20458
9dd86dff9b
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5590,6 +5590,37 @@ func Test_cindent_comment_brackets()
|
||||
call assert_equal(' arg3);', getline(3))
|
||||
bwipe!
|
||||
|
||||
" stray } in a // line comment inside an aggregate (enum/struct) whose
|
||||
" opening brace is at the end of the line must not affect the next member
|
||||
new
|
||||
setl cindent sw=4
|
||||
let code6 =<< trim [CODE]
|
||||
typedef enum {
|
||||
ND_BLOCK, // { ... }
|
||||
ND_FUNCALL,
|
||||
} NodeKind;
|
||||
[CODE]
|
||||
call setline(1, code6)
|
||||
call cursor(3, 1)
|
||||
normal ==
|
||||
call assert_equal(' ND_FUNCALL,', getline(3))
|
||||
bwipe!
|
||||
|
||||
" same, a struct member with a trailing // } comment
|
||||
new
|
||||
setl cindent sw=4
|
||||
let code7 =<< trim [CODE]
|
||||
struct S {
|
||||
int a; // }
|
||||
int b;
|
||||
};
|
||||
[CODE]
|
||||
call setline(1, code7)
|
||||
call cursor(3, 1)
|
||||
normal ==
|
||||
call assert_equal(' int b;', getline(3))
|
||||
bwipe!
|
||||
|
||||
endfunc
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user