mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 16:30:02 -04:00
indents(c): Refactor indent queries
This commit is contained in:
parent
5ac2c92060
commit
2f5deed456
6 changed files with 179 additions and 15 deletions
60
tests/indent/c/if_else.c
Normal file
60
tests/indent/c/if_else.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
int foo(int x){
|
||||
if (x > 10)
|
||||
return 10;
|
||||
|
||||
if (x > 10)
|
||||
return 10;
|
||||
else
|
||||
return 10;
|
||||
|
||||
if (x > 20)
|
||||
return 20;
|
||||
else if (x > 15)
|
||||
return 15;
|
||||
else
|
||||
return 10;
|
||||
}
|
||||
|
||||
int bar(int x){
|
||||
if (x > 20)
|
||||
return 10;
|
||||
else {
|
||||
return 10;
|
||||
}
|
||||
|
||||
if (x > 20)
|
||||
return 10;
|
||||
else if (x > 10) {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
int baz(int x){
|
||||
if (x > 20)
|
||||
return x;
|
||||
else if(x > 10) {
|
||||
if(x > 10) {
|
||||
if(x > 10)
|
||||
return 10;
|
||||
if(x > 5) {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x > 20)
|
||||
if (x > 19)
|
||||
if(x > 18)
|
||||
return x;
|
||||
|
||||
if (x > 20)
|
||||
return x;
|
||||
else if (x > 19) {
|
||||
if (x > 18)
|
||||
return x;
|
||||
else
|
||||
x++;
|
||||
}
|
||||
else
|
||||
return x;
|
||||
}
|
||||
7
tests/indent/c/issue-4079.c
Normal file
7
tests/indent/c/issue-4079.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
int main(){
|
||||
for(;;)
|
||||
}
|
||||
|
||||
int foo(){
|
||||
while(1)
|
||||
}
|
||||
6
tests/indent/c/issue-4117.c
Normal file
6
tests/indent/c/issue-4117.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
int main(){
|
||||
if(1){
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
|
@ -10,3 +10,4 @@ int foo(int x) {
|
|||
for (int i = 0; i < 3; ++i)
|
||||
x--;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue