-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
language-php #787
Comments
This is presumably due to the fact that this language is a TextMate grammar, and not a Tree-Sitter grammar What the ends up meaning is that all of the syntax highlighting is performed via regex. So, once I get to line 7, I ran
When read top-to-bottom, shows that there's actually a hand-off to another language,
So, the problem isn't that The first double quote is considered to be php, but then the Which is why the highlighting works here just fine, and doesn't in your example - because the linked comment is using backtick for its embedded SQL instead of additional double quotes (so there's are two double quotes, scoped to php and the rest of the SQL strings are wrapped with backtick instead). For succinctness, this is the code: <?php
if (isset($value)) {
foreach($value as $valuex) {
if ($ii === 0) {
$sql = $sql . " AND ($key LIKE '" . $valuex . "'";
#$sql = $sql . " AND ($key LIKE " . $valuex ;
}
if ($ii > 0) {
$sql = $sql . " OR $key LIKE '" . $valuex . "'";
}
$ii++;
}
} else {
$sql = $sql . " AND ($key='0'";
}
$sql = $sql . ")";
?> |
Amendment: The reason the GitHub syntax highlighting works, is due to the fact that GitHub utilizes Tree-Sitter grammars |
I've got a PHP Tree-sitter grammar that's more or less ready, and I keep forgetting to put a PR together. I'll try to get that done sometime this week. I can confirm that this issue is fixed in said grammar. The main problem in the TextMate grammar is that it tries to be clever and inject the SQL grammar into any string that looks like it could be SQL. I'm not certain that I want to replicate that strategy for the Tree-sitter grammar (for which I haven't yet implemented any special highlighting of SQL queries), but it would be safer to attempt that strategy because injections wouldn't be able to bleed out into the parent grammar like we're seeing in this bug. Tree-sitter would say “SQL grammar, you may inject into this specific range of the buffer” and it would do the best it could at highlighting that area. |
@savetheclocktower Considering a php Tree-sitter grammar was added in #852 are we good to close this one? |
Thanks in advance for your bug report!
What happened?
When the "language-php" package is enabled and I'm in a PHP script, if I create a "(" character but don't close it, this screws up the formatting for everything after it for the rest of the script, whether it's 10 lines or 7000 lines and regardless of whether or not I later close the parenthesis.
This seems like it's an issue that's been around and mentioned before in the Atom issues, but since it hasn't been addressed in years and is now an issue in Pulsar, I figured I should mention it.
I propose that we add some kind of logic to the language-php package that says, if we can't find a closing parenthesis character ")" by the end of the line, we reset the formatting to normal.
Could also add some kind of toggle to turn off the string formatting in case it annoys anyone.
Pulsar version
1.110.0
Which OS does this happen on?
🪟 Windows
OS details
Windows 10 Pro
Which CPU architecture are you running this on?
x86_64/AMD64
What steps are needed to reproduce this?
Additional Information:
Old issue: atom/language-php#442
The text was updated successfully, but these errors were encountered: