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

XML highlighting fails with comment of certain length in document root #5470

Closed
LeoniePhiline opened this issue Jan 9, 2023 · 6 comments · Fixed by #5685
Closed

XML highlighting fails with comment of certain length in document root #5470

LeoniePhiline opened this issue Jan 9, 2023 · 6 comments · Fixed by #5685
Labels
A-language-support Area: Support for programming/text languages C-bug Category: This is a bug upstream

Comments

@LeoniePhiline
Copy link
Contributor

Summary

XML highlighting fails if there is a comment in the XML document root which has at least a certain length.

This fails:

<?xml version="1.0" encoding="utf-8"?>
<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
</svg>

image

This works (One "X" less in the comment line):

<?xml version="1.0" encoding="utf-8"?>
<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
</svg>

image

Reproduction Steps

I tried this:

  1. hx
  2. Paste "This fails" XML content
  3. Set :lang xml
  4. Observe failed highlighting
  5. Remove one X from the comment line
  6. Observe successful highlighting

I expected this to happen:

Highlighting succeeds

Instead, this happened:

Highlighting fails (see screenshot)

Helix log

(Nothing in the helix log.)

Platform

openSUSE Tumbleweed - Linux

Terminal Emulator

Konsole

Helix Version

helix 22.12

@LeoniePhiline LeoniePhiline added the C-bug Category: This is a bug label Jan 9, 2023
@Ordoviz
Copy link
Contributor

Ordoviz commented Jan 9, 2023

This is a bug in https://github.com/RenjiSann/tree-sitter-xml. Putting the comment near the top of the file seems to cause problems. @RenjiSann, can you take a look at this when you have time?

@RenjiSann
Copy link

Thank you for letting me know about this. I will try to investigate

@the-mikedavis the-mikedavis added upstream A-language-support Area: Support for programming/text languages labels Jan 9, 2023
@RenjiSann
Copy link

The error is already present in the project I forked, I only modified it slightly and added a default highlight.scm. I will try to dive in the XML syntax and find the error, but I'm not sure I will succeed.

@RenjiSann
Copy link

I've tried to understand how's the grammar working, but tbh it's to big for me to track the bug down any time soon. I might do it all over again, though it will be much simpler, just to ensure syntax highlighting

@ghost
Copy link

ghost commented Jan 15, 2023

Maybe the author of the original repository will find a bug? Can you take a look @dorgnarg?

@RenjiSann
Copy link

Hi ! I was able to take a look at the bug. It appeared that the project I forked confused single and multiple spaces in the grammar. This is not entirely fixed yet because I am trying to avoid regression and lack proper testing.
Anyway, release 0.0.2 should fix this particular issue. Please keep me informed of any other bugs you find, that will help me to test more thoroughly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages C-bug Category: This is a bug upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants