-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Simplify first-in-line computation for indent queries #10527
Simplify first-in-line computation for indent queries #10527
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this up! The new implementation makes sense to me. But I am curious what cases the old one was supposed to cover that the simplified one doesn't
helix-core/src/indent.rs
Outdated
@@ -863,7 +839,7 @@ pub fn treesitter_indent_for_pos<'a>( | |||
loop { | |||
// This can safely be unwrapped because `first_in_line` contains | |||
// one entry for each ancestor of the node (which is what we iterate over) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment can be removed now
This fixes issues for grammars with nodes containing only whitespace (e.g. Go).
4f1abcc
to
269cd2e
Compare
It was supposed to correctly handle things like lines starting with a specific symbol that isn't considered a node in the syntax tree, e.g. for marking an environment. The main example I could think of is Literate Haskell, where lines starting with |
I originally thought that it might be necessary to look at the syntax tree to decide whether a node is the first node on its line. Since then, I haven't really seen any example where this is the case, so we can replace my initial implementation with a simpler one that just checks if all preceeding characters on the same line are whitespace.
This fixes #10336 and should generally prevent issues with tree-sitter grammars that insert nodes for whitespace.