helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.48k stars 2.48k forks source link

Weird syntax highlight issue with Odin language map[string]bool #11520

Open Akselmo opened 2 months ago

Akselmo commented 2 months ago

Summary

Hi, I wasn't exactly sure where to report this, since https://github.com/tree-sitter-grammars/tree-sitter-odin mentioned following:

If your issue is related to a bug in your editor-experience because your editor leverages tree-sitter and this parser, then it is likely your issue does NOT belong here and belongs in the relevant editor's repository.

The bug

If I create a map with strings as keys, the coloring seems to get confused.

Best shown with a screenshot:

image

The first line, MOVE_FRONT, is correct. Any subsequent lines look wrong.

Tree-sitter scopes seem to error out?

image

image

Reproduction Steps

I tried this: 1. `hx` 2. Paste following snippet ```odin package test import rl "vendor:raylib" WeirdMap := map[string]bool \ { "MOVE_FRONT" = rl.IsKeyDown(cast(rl.KeyboardKey)settings.Values.keyMoveForward), "MOVE_BACK" = rl.IsKeyDown(cast(rl.KeyboardKey)settings.Values.keyMoveBackward), "MOVE_RIGHT" = rl.IsKeyDown(cast(rl.KeyboardKey)settings.Values.keyMoveRight), "MOVE_LEFT" = rl.IsKeyDown(cast(rl.KeyboardKey)settings.Values.keyMoveLeft), } ``` I expected this to happen: Syntax highlighting for string would be correct, like on the first line. Instead, this happened: Seems helix thinks for some reason that the next line with `MOVE_BACK` with the first `"` is not start of string? ### Helix log
~/.cache/helix/helix.log ``` please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines ```
### Platform Linux ### Terminal Emulator konsole 24.11.70 ### Installation Method fedora packages ### Helix Version helix 24.7 (079f5442)
archseer commented 2 months ago

No, this is definitely a parsing issue that has to be fixed by the grammar upstream. (I also can't find that quote anywhere)

Akselmo commented 2 months ago

I saw the quote when making a bug report. Anyhow, thanks for clarification, will make a bug upstream :)

leo-unglaub commented 2 months ago

Just for reference, this is not just linked to the odin language. This happens also in php and other languages, most of the time if the letter M is involved.

Screenshot from 2024-08-21 12-56-43

the-mikedavis commented 2 months ago

That's unrelated - it's because the k is lowercase so it's not highlighted as a constant. That's up to php's queries in runtime/queries/php/highlights.scm