Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Auto-indent doesn't respect string and symbol literals #609

Closed
jamshark70 opened this Issue · 4 comments

3 participants

@jamshark70
Owner

I can enter a block like this by manually deleting the auto-indent tabs.

f = {
    "This is a multiline string literal.
I don't want the lines to start with tabs.
But, auto-indentation inserts tabs for me,
both while typing and also when selecting
this block and hitting tab to re-indent."
};

f.value;

This is a multiline string literal.
I don't want the lines to start with tabs.
But, auto-indentation inserts tabs for me,
both while typing and also when selecting
this block and hitting tab to re-indent.

But if I reindent the block, SC-IDE changes the content of the string. IMO auto-indent should only insert whitespace where it is syntactically insignificant, but not modify the code's behavior.

f = {
    "This is a multiline string literal.
    I don't want the lines to start with tabs.
    But, auto-indentation inserts tabs for me,
    both while typing and also when selecting
    this block and hitting tab to re-indent."
};

f.value;

This is a multiline string literal.
    I don't want the lines to start with tabs.
    But, auto-indentation inserts tabs for me,
    both while typing and also when selecting
    this block and hitting tab to re-indent.
@timblechmann

yes, multi-line string/symbol literals should not be indented ... but for the last 5 lines of your example, afaict, it would be invalid code.

regarding the implementation, jakob, atm, we are tokenizing the content of a string, too, don't we? what's the current way to figure out, if a specific block or position is in a string?

@jleben
Owner

regarding the implementation, jakob, atm, we are tokenizing the content of a string, too, don't we? what's the current way to figure out, if a specific block or position is in a string?

No, we're not tokenizing contents of strings and symbols, but we do tokenize the opening (and maybe also closing) quotation marks.

That means if you look for tokens left and right of a position, and if the only token on both sides is a quotation mark, you're in a string.

@timblechmann

seems, that we are not tokenizing the closing quotation marks atm :/

@jamshark70
Owner

but for the last 5 lines of your example, afaict, it would be invalid code.

Oh, right... to clarify, the last 5 lines are the printed output of f.value, demonstrating that the code's behavior changed as a result of automatic indentation. Not meant to be executed as code.

@jleben jleben closed this issue from a commit
@jleben jleben sc ide: do not indent string continuation lines
Note: the same does not apply to symbols, because the sclang lexer does not
allow symbols to span multiple lines anyway.

Fixes #609.
63069d4
@jleben jleben closed this in 63069d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.