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

PHP Syntax highlight doesn't handle {$variables} in double-quoted strings #454

Closed
php4fan opened this issue Dec 1, 2023 · 11 comments
Closed

Comments

@php4fan
Copy link

php4fan commented Dec 1, 2023

I have reported this also against VSCode itself, because it does do PHP syntax highlight even without any extension, and I believe that if they do syntax highlight for any given language they must do it right.

However, I assume the extension also improves syntax highlight, right? so maybe this is also relevant for the extension.

image

The screenshot should speak for itself, otherwise see microsoft/vscode#199790

@jakubmisek
Copy link
Member

Correct; thank you for reporting it to vscode.

We are extending the highlighting with our semantic (to improve the colorization of type names in doc comments), so I assume we could do it for string interpolation. If vscode team won't reply any time soon, we may implement it.

@jakubmisek
Copy link
Member

Tracked on KapitanOczywisty/language-php#15

@jakubmisek
Copy link
Member

It looks like this issues has been fixed in the recent VSCode (mine is 1.86.2):

image

@jakubmisek
Copy link
Member

jakubmisek commented Jun 21, 2024

The highlighting seems to work as expected now.

We still need to trigger suggestion when a user types $ inside double-quoted strings:

  • trigger suggestion when typing $ in double-quoted strings

@jakubmisek
Copy link
Member

The next pre-release will trigger suggestions after typing $ in a string!

The highlighting seems to be fixed in the latest VSCode as well.

@php4fan
Copy link
Author

php4fan commented Feb 26, 2025

The highlighting seems to be fixed in the latest VSCode as well.

I'm still observing it, and KapitanOczywisty/language-php#15 is still open 🤔

The next pre-release will trigger suggestions after typing $ in a string!

It's still not triggering after typing {$ in a string though.

@jakubmisek
Copy link
Member

@php4fan thank you for letting me know;

@php4fan
Copy link
Author

php4fan commented Feb 28, 2025

I guess KapitanOczywisty/language-php#15 is too much work in already overcomplicated PHP grammar, but it's the only way fixing that

There seems to have been no activity in KapitanOczywisty
language-php in almost 2 years, i.e. since way before the issue was opened there 🤦

What confuses me is you posted a screenshot in this comment that showed the correct syntax highlight.

@jakubmisek
Copy link
Member

@php4fan that means it must be a color theme thing! Try changing the color theme; and we will have to contact the theme author.

Image

@php4fan
Copy link
Author

php4fan commented Feb 28, 2025

What theme were you using when you had the right syntax highlight? I can't see any that gives that result.

The one I'm using is "Default Dark modern" (never changed it) and the highlight of variables in strings is full of issues, beyond just variables in {}:

Image

  • the {} are not highlighted any different from regular string contents
  • nor are the [] neither in {} variables nor in non-{} variables, even though all of them are replaced in the example above
  • the '' are not highlighted

None of the themes seem to get the $info[aaa] one right; some do seem to highlight the {}. None looks like the one you posted in february 2024.

@jakubmisek
Copy link
Member

It's "Dark Modern". You can also use this command:

Image

and check the actual tokens:

Image

so you can customize it using settings as described at https://stackoverflow.com/a/46946515/601646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants