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

Highlighting issue when function has a comment #3

Open
chtenb opened this issue Jun 10, 2024 · 12 comments
Open

Highlighting issue when function has a comment #3

chtenb opened this issue Jun 10, 2024 · 12 comments

Comments

@chtenb
Copy link

chtenb commented Jun 10, 2024

// Generate True with probability k/n
fun gen-bool(k: int, n: int) : random bool
  rnd-int32(0, n) < k

image

@mtoohey31
Copy link
Owner

I can't seem to reproduce this on the latest commit (96d070c). Is it possible there's whitespace in the text where the parsing error appears?

@chtenb
Copy link
Author

chtenb commented Jun 17, 2024

I do run on the latest version that was included with helix-editor/helix#10379
There is no invisible whitespace, I can just copy the text from here into a new koka buffer in helix and it reproduces right away for me. It also reproduces on helix master without config

image

@mtoohey31
Copy link
Owner

Hmm, that's strange... Running helix from master at helix-editor/helix@dbacaad, it looks like this for me:

image

Just double checking: the issue is that the fun keyword's first letter is highlighted incorrectly, right? Is there any chance you haven't run hx --grammar fetch and hx --grammar build since the update?

@chtenb
Copy link
Author

chtenb commented Jun 17, 2024

I did not, is that necessary? The helix docs suggest that is not needed for pre-packaged grammars.

@mtoohey31
Copy link
Owner

Whether it's necessary very much depends on how you've installed Helix/how you're running it with Cargo. You can try checking hx --health to figure out what runtime directory it's using (which is where the compiled grammars are located). If you want to be certain that you're running the exact same version of Helix (and the grammars) that I'm testing with, you can use the Nix package manager and run nix run github:helix-editor/helix/dbacaaddcaa4a9dd39c73d0102d03ea7c24ca647#.

@chtenb
Copy link
Author

chtenb commented Jun 18, 2024

I don't believe nix runs on windows, which is where I'm running helix.

I build from source using cargo install --path helix-term --locked. According to the docs this will "construct the tree-sitter grammars in the local runtime folder.". And I set HELIX_RUNTIME to the local runtime folder, ~/prj/helix/runtime in my case.

(If I were to -g fetch manually, it would write the grammars in %AppData%, which I don't want, because then I'd have to copy the queries etc also manually to %AppData%)

@chtenb
Copy link
Author

chtenb commented Jun 18, 2024

I found something strange, I noticed the same thing in a nushell script, also with an if statement prepended with a comment:

# Nushell Environment Config File
if 1 == 1 {
}

image

This, and the fact that you cannot reproduce, suggests to me that something else is going on. Though I have no clue what that could be 🤔

@chtenb chtenb closed this as completed Jun 18, 2024
@chtenb
Copy link
Author

chtenb commented Jun 18, 2024

Oh yeah, it's a line ending issue. Setting them to lf removes the artifact in both cases. Now the question is, is that a generic helix problem, or do the queries/grammars of both languages happen to have the same incorrect logic. I'm going to update my helix installation to the latest, to see if the issue persists.

@chtenb
Copy link
Author

chtenb commented Jun 18, 2024

Yeah, it seems the issue persists. Can you reproduce the issue too, with CRLF line endings?

@mtoohey31
Copy link
Owner

Ah, that's it, yes I can!

image

Will see if I can figure out what's going on. I suspect I just forgot to allow for \r somewhere.

@mtoohey31 mtoohey31 reopened this Jun 18, 2024
@mtoohey31
Copy link
Owner

Actually it looks like the problem might be on Helix's end, not the grammar's. If you check :tree-sitter-subtree with the whole document highlighted, there don't appear to be any errors in the tree and I think it looks correct... Given that it happens with Nushell too this should probably be reported to the Helix people. I'm going to keep this open until we've confirmed that it's for sure a Helix problem though.

@chtenb
Copy link
Author

chtenb commented Jun 19, 2024

Issue created at the Helix repo

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

No branches or pull requests

2 participants