mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-20 04:10:06 -04:00
indents(cpp): indent at field_initializer_list
This commit is contained in:
parent
7654bbc04b
commit
62982378b8
3 changed files with 20 additions and 1 deletions
|
|
@ -117,7 +117,7 @@ function M.get_indent(lnum)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum)
|
-- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum)
|
||||||
if not is_processed_by_row[srow] and (q.indent[node:id()] and srow ~= erow and srow ~= lnum - 1) then
|
if not is_processed_by_row[srow] and (q.indent[node:id()] and srow ~= erow and ((srow ~= lnum - 1) or q.indent[node:id()].start_at_same_line)) then
|
||||||
indent = indent + indent_size
|
indent = indent + indent_size
|
||||||
is_processed = true
|
is_processed = true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,6 @@
|
||||||
(condition_clause)
|
(condition_clause)
|
||||||
] @indent
|
] @indent
|
||||||
|
|
||||||
|
((field_initializer_list) @indent
|
||||||
|
(#set! "start_at_same_line" 1))
|
||||||
(access_specifier) @branch
|
(access_specifier) @branch
|
||||||
|
|
|
||||||
17
tests/indent/cpp/initializer_list.cpp
Normal file
17
tests/indent/cpp/initializer_list.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
class Foo {
|
||||||
|
|
||||||
|
Foo(int a, int b, int c, int d)
|
||||||
|
: m_a(a)
|
||||||
|
, m_b(b)
|
||||||
|
, m_c(c)
|
||||||
|
, m_d(d) {}
|
||||||
|
|
||||||
|
Foo(int a, int b, int c) :
|
||||||
|
m_a(a),
|
||||||
|
m_b(b),
|
||||||
|
m_c(c)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int m_a, m_b, m_c, m_d;
|
||||||
|
};
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue