pulsar-edit / pulsar

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

[language-php] Injection logic should not throw exceptions #1032

Closed savetheclocktower closed 4 months ago

savetheclocktower commented 4 months ago

Thanks in advance for your bug report!

What happened?

Because of the strange way that tree-sitter-php structures its tree, I use an unusual method to determine which ranges of a .php file are HTML and which are PHP. It tries to match balanced pairs of <?php (and equivalent) and ?>.

But I did something silly: when it finds an unbalanced token, it throws an exception! This exception goes uncaught and ends up preventing any editing attempts by the user.

Instead, it should be more tolerant of errors, and do something logical, even if it's not going to be correct. (The code is syntactically invalid in this scenario, so there is no such thing as “correct”; favor the solution that keeps the editor running.)

Pulsar version

1.118

Which OS does this happen on?

❓ Other(Please specify in the OS details field below)

OS details

(any OS)

Which CPU architecture are you running this on?

None

What steps are needed to reproduce this?

I was able to reproduce this issue by following the instructions in this issue comment.

Additional Information:

No response