dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Incorrect syntax highlighting with expressions inside of formatted strings

Open Nikita0x opened this issue 6 months ago • 1 comments

Problem

Incorrect syntax highlighting when accessing props fields (see screenshot). It works, but would be great if you can visually distinguish and see as the usual comment (see screenshot)

Steps To Reproduce

Steps to reproduce the behavior:

  • define props
  • try to access fields of those props in the string

Expected behavior

Correct syntax highlighted - string is like string, whatever is inside { } highlighted differently

Screenshots

Image

Environment:

  • Dioxus version: 0.6.0
  • Rust version: rustc 1.86.0 (05f9846f8 2025-03-31)
  • OS info: Linux Mint 21.2 x86_64
  • App platform: web

Questionnaire I would've loved to fix it, but I am myself a newbie and wanted to learn Rust via Web because its the most comfortable thing for me.

Nikita0x avatar Jun 18 '25 06:06 Nikita0x

We only have limited control over syntax highlighting inside of macros. Rust analyzer highlights macros based on the tokens they expand to. For formatted strings, we highlight strings that only contain formatted idents like "{count}" by expanding into the format macro directly, but we don't have that option for expressions the format macro does not support like "{props.counter}".

The subspan API with RA integration might unblock this in the future if it is stabilized. If we can expand specific parts of the string literal to specific expressions, then rust analyzer should have the information to highlight this properly

ealmloff avatar Jun 18 '25 13:06 ealmloff