nojanath / SublimeKSP

Fork of Nils Liberg's SublimeKSP plugin. See README for details.
GNU General Public License v3.0
87 stars 18 forks source link

f-string fails on shorthand "->" expressions #462

Closed blackeyedpony closed 1 month ago

blackeyedpony commented 1 month ago

It would be nice if you could get this to work:

on init 
    declare ui_slider sl (0, 100)
    message(f'test slider value: <sl -> value>')
end on

the precompiler fails to recognise the "->" keyword and stops the variable insertion at the first found ">" and logically comes up with: message("test slider value: " & sl - & " value>") Could you try changing the insertion regex to span to [^-]> ?

mkruselj commented 1 month ago

Regex is not used for f-strings, as I was told by @eitherys... Well it's also obvious from the source code.

mkruselj commented 1 month ago

@blackeyedpony There will be a fix for this but you will have to escape the > character inside the outer <> brackets, so instead of -> it will have to be -\>.

blackeyedpony commented 1 month ago

ah ok. I didn't look at your code yet. Nevertheless, the string formatting is a very handy addition, thanks Mario!

mkruselj commented 1 month ago

All the thanks goes to @eitherys who actually coded it :)

mkruselj commented 1 month ago

@blackeyedpony Try the latest commit!

eitherys commented 1 month ago

This was fixed but that commit contained an error I didn't test; a new commit is on the way that also adds support explicitly for -> without the use of an escape. So your original code compiles now on my end.

eitherys commented 1 month ago

image