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

Use any whitespace in indentation of multiline regular strings #131

Closed
Lyrth opened this issue Nov 19, 2023 · 5 comments
Closed

Use any whitespace in indentation of multiline regular strings #131

Lyrth opened this issue Nov 19, 2023 · 5 comments
Labels
enhancement New feature or request experimental The changes may break something or be a bad idea

Comments

@Lyrth
Copy link

Lyrth commented Nov 19, 2023

Currently, multiline regular strings trim away newlines and literal tab characters so that the string can be indented when multilined. Some (or most) editors insert multiple spaces instead of the tab character when the tab key is pressed, so it takes a bit more effort to get a tab character for use here.

For ergonomics, an alternative (possibly breaking change) is if the first " is immediately followed by a newline, the first sequence of spaces right after that newline (e.g. 4 spaces) will become the reference sequence spacing, that would be removed in the following lines.
As an example, given:

local a = "
    this is a 
    regular string
        and maybe i need this spacing here
        and here too
    and back to no spacing

    hello
    world
"

it will become

local a = "this is aregular string    and maybe i need this spacing here    and here tooand back to no spacinghelloworld"

This might be unnecessary complexity or might be too confusing, so it should probably be a flag instead of being a default if implemented.

@Maiori44 Maiori44 added enhancement New feature or request experimental The changes may break something or be a bad idea labels Nov 19, 2023
@Maiori44 Maiori44 added this to the 4.0 milestone Nov 19, 2023
@Maiori44
Copy link
Member

the flag could let you choose between X spaces or tabs, or between letting the preprocessor figure it out on its own on every file
But then, what should the default value of the flag be?

@Lyrth
Copy link
Author

Lyrth commented Nov 19, 2023

Having a set amount of whitespace (constant) might be detrimental since the string can be in any depth.

local a, b
if A {
    a = "
        hello
        world
    "
    if B {
        b = "
            and hello
            Clue
        "
    }
}

Probably best to make it figure it out on its own for each string.

@Maiori44
Copy link
Member

okay, but what if someone does want a bit of spaces before? how could it tell the preprocessor "no wait stop a bit earlier"

@Maiori44
Copy link
Member

okay, but what if someone does want a bit of spaces before? how could it tell the preprocessor "no wait stop a bit earlier"

local str = "

  spaces will now be preserved
"

This would turn into:
local str = " spaces will now be preserved"
So that's not an issue.

@Maiori44 Maiori44 removed this from the 4.0 milestone Nov 30, 2023
@Maiori44
Copy link
Member

Maiori44 commented Dec 8, 2023

This was now implemented in 4.0.

@Maiori44 Maiori44 closed this as completed Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request experimental The changes may break something or be a bad idea
Projects
Status: Done
Development

No branches or pull requests

2 participants