fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
773 stars 194 forks source link

Fantomas does not support extended interpolated strings #3012

Closed DedSec256 closed 7 months ago

DedSec256 commented 9 months ago

Issue created from fantomas-online

Code

$$$"""{{{5}}}"""

Result

$$$"""{{{5}"""

Problem description

Fantomas eats braces

image

Options

Fantomas main branch at 2023-12-06T16:47:58Z - 0f8ee237a452f3772afe7989e031b5f65ba389f5

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file? PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

nojaf commented 9 months ago

Thanks for the report Alex! We'll take a look at it in the coming days.

nojaf commented 9 months ago

So, this is a lexer problem, reported https://github.com/dotnet/fsharp/issues/16418.

josh-degraw commented 8 months ago

While we wait for the compiler to fix the range issue here, would it be feasible to calculate the correct range based on the source text & e.g. taking the number of $ and just generating our own, more correct range that way? Or would you expect that to be too error prone? Depending on how long we'll need to wait for that fix, it may be worth just monkey-patching this in the meantime. Otherwise I'd be happy to take a stab at trying to fix it in the lexer, though I worry I may be fighting an uphill battle if you and other core contributors already took a stab and couldn't figure it out 😅

nojaf commented 8 months ago

You will wait forever if you expect someone else to fix the compiler. The team isn't going to pick this up, so I would suggest you take a stab at fixing this problem in the lexer.