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

Triple-quoted strings are incorrectly indented in _ren.py files #5525

Open
eevee opened this issue May 18, 2024 · 5 comments
Open

Triple-quoted strings are incorrectly indented in _ren.py files #5525

eevee opened this issue May 18, 2024 · 5 comments
Labels
duration - day Resolving this is estimated to a day of development unintended behavior Something not working the way it's supposed to, without causing a crash or exception

Comments

@eevee
Copy link
Contributor

eevee commented May 18, 2024

This:

"""renpy
init python:
"""

a = """foo
bar"""

is transformed into this:

init python:
    a = """foo
    bar"""

which changes the contents of a.

Took me a while to realize where the extra space was coming from. That said, this doesn't look pleasant to fix, either.

@Gouvernathor
Copy link
Member

That's how it is intended and documented to behave.

@renpytom
Copy link
Member

Sure, but it's also kinda bad - and wasn't intended. I need to think about if a fix is possible.

@Gouvernathor
Copy link
Member

That wouldn't be easy.
You need to flag the lines that are between opening triple quotes (exclusive) and closing triple quotes (inclusive) ; where no quote is protected by backslash ; not included in a string of the other type of quote (double vs single) ; and that aren't in a comment.

@renpytom
Copy link
Member

Yes, but we do this in other parts of Ren'Py's parser, so we could do it here.

@eevee
Copy link
Contributor Author

eevee commented May 23, 2024

It's actually even more not-easy — you can escape newlines in single-quoted strings, so the line after that shouldn't be indented either. And f-strings can contain arbitrary Python expressions, including the same quotes again, as of 3.12.

I suspect it could still be done without the full Python parser, with a Sufficiently Clever™ regex, but it may not be worth it.

@renpytom renpytom added unintended behavior Something not working the way it's supposed to, without causing a crash or exception duration - day Resolving this is estimated to a day of development labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duration - day Resolving this is estimated to a day of development unintended behavior Something not working the way it's supposed to, without causing a crash or exception
Projects
None yet
Development

No branches or pull requests

3 participants