pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.33k stars 140 forks source link

1.114: PHP color highlight broken #931

Closed m1ga closed 8 months ago

m1ga commented 9 months ago

Thanks in advance for your bug report!

What happened?

Opening a PHP file that starts with HTML code won't show any highlight colors with 1.114.

Screenshot_20240216_111316

If I move the <?php ?> block to the first line it will work.

Pulsar version

1.114

Which OS does this happen on?

🐧 Red Hat based (Fedora, Alma, RockyLinux, CentOS Stream, etc.)

OS details

Fedora 39

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

Create a new PHP file and add

<table>
  <thead>
    <tr></tr>
</thead>
</table>

<?php
echo 1;
?>

Additional Information:

Works fine with 1.113, using experimental tree sitter

savetheclocktower commented 9 months ago

Thanks for the report. Is it a matter of it choosing the wrong grammar, or is the PHP grammar selected when the file is opened?

m1ga commented 9 months ago

PHP is selected in both tabs

savetheclocktower commented 9 months ago

Oof. I can't reproduce this with the exact code block you included.

Do you see any errors in the console?

If not, I’m at a loss here because most of the possible explanations I can think of for this behavior would involve partial highlighting; perhaps the HTML would be highlighted but the PHP wouldn't. At least if there's a console error it'd suggest that something was going wrong in the injection phase (where we figure out which parts are HTML and which parts are PHP).

garrettboone commented 9 months ago

I can reproduce with php selected as grammar. Seems to work fine at first if auto-detect is allowed to choose.

With Auto Detect showing as selected (which I think means no selection yet?) in grammar selection list and no other languages have a check mark next to them, though PHP is diplayed in the footer bar: image

With PHP selected with check mark showing on the list: image

The file is local to my Windows 10 machine. Project is remote. No errors occur in console when switching selection back and forth.

version: 1.113.2024013007, going to try 114 shortly...

EDIT: this was at first with Settings > Use Tree Sitter Parsers unchecked. Then, I tried with 1.114.0 and could not reproduce (below). When I came back with 1.113.2024013007 I cannot reproduce so I would assume that 1.114.0 has introduced something to the settings that would fix the above behavior as a I did not clear out config/settings files first.

garrettboone commented 9 months ago

I cannot reproduce in 1.114.0 - here are the results:

With Auto Detect: image

With PHP selected: image

These examples are with Settings > Use Tree Sitter Parsers unchecked. With checked, PHP is being selected from the list and checked and styling looks the same.

savetheclocktower commented 9 months ago

My head hurts.

@m1ga, with @garrettboone's findings in mind, can you perhaps close your project window and relaunch it via the command line using

pulsar --clear-window-state [the path to your project]

to see if this is some strange artifact of window state?

And to be clear — @m1ga, your “Use Tree-sitter Parsers” setting is enabled, correct?

m1ga commented 9 months ago

It's strange. Today I reopened my file and test file and it is looking correct. I didn't change anything in my Pulsar settings or updated any package. The only thing I did between last time and today was working on other files and make git pushes.

Screenshot_20240219_112828

so I guess I can close this one. It wasn't working on the day I've made the update of Pulsar

savetheclocktower commented 9 months ago

It's strange. Today I reopened my file and test file and it is looking correct. I didn't change anything in my Pulsar settings or updated any package. The only thing I did between last time and today was working on other files and make git pushes. […] so I guess I can close this one. It wasn't working on the day I've made the update of Pulsar

I think this is still our fault, somehow. I've noticed very strange side effects sometimes immediately after upgrading Pulsar versions; my theory is that Pulsar gets very confused trying to restore window state from a previous version, but that's just a hunch.

If you notice strange symptoms next time you update, keep the --clear-window-state flag in mind.