Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude curly braces for c and ts #517

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

mortezadadgar
Copy link
Contributor

@mortezadadgar mortezadadgar commented Nov 7, 2023

partially fixes #516

@theHamsta theHamsta requested a review from kiyoon November 7, 2023 16:08
@kiyoon
Copy link
Collaborator

kiyoon commented Nov 8, 2023

I tested with C and noticed two things.

  1. It still includes the curly braces.
  2. Previously, it used to select inner part of the conditional or loop statements (broken into semicolons). Now, it only selects the statements inside the loop. Whether this makes sense than the previous version is debatable, and if we decide to change the behaviour we need to warn users about this breaking change.

@mortezadadgar
Copy link
Contributor Author

I tested with C and noticed two things.

1. It still includes the curly braces.

in which scenario?

2. Previously, it used to select inner part of the conditional or loop statements (broken into semicolons). Now, it only selects the statements inside the loop. Whether this makes sense than the previous version is debatable, and if we decide to change the behaviour we need to warn users about this breaking change.

by "broken into semicolons" you mean for loops?
I don't think it was selecting the inner part of loop condition previously

for example in this case being inside if condition @loop.inner selects the loop printf and if condition and its curly braces now it's just excluding curly braces
in same cursor position @conditional.inner select the break and condition printf

int main() {
	for (int i = 0 ; i < 3; i++) {
		printf("loop\n");
		if (1) {
			printf("Test condition\n");
			break;
		}
	}
}

selecting inside a loop seems to be a expected change no need to warn the users about it

@kiyoon
Copy link
Collaborator

kiyoon commented Nov 9, 2023

Yes, inside the for loop and also inside the if condition used to be selected.

Also, if your cursor is on the curly brace opening or before, it will still select them.

@mortezadadgar
Copy link
Contributor Author

@kiyoon I think that's fixed now, can you take a another look?

@kiyoon
Copy link
Collaborator

kiyoon commented Nov 10, 2023

It works great on both C and TS. Thanks a lot for this!

@kiyoon kiyoon merged commit dbcd938 into nvim-treesitter:master Nov 10, 2023
5 of 6 checks passed
@mortezadadgar mortezadadgar deleted the patch-1 branch November 11, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inconsistency of selecting @conditional.inner across different languages
3 participants