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

[Fix #4719] Detect tabs between string literals #7202

Merged
merged 1 commit into from Jul 13, 2019

Conversation

buehmann
Copy link
Contributor

@buehmann buehmann commented Jul 10, 2019

This fixes #4719 and simplifies Layout/Tab code.

The problem was that entire :dstr expressions were considered "inside a string", whereas they can be composed of multiple individual string literals:

"foo" \
	"bar"
s(:dstr,
  s(:str, "foo"),
  s(:str, "bar"))
"foo" \
~~~~~~~... expression

s(:str, "foo")
"foo" \
    ~ end
~ begin
~~~~~ expression

s(:str, "bar")
        "bar"
            ~ end
        ~ begin
        ~~~~~ expression

In the AST this looks very similar to a multiline string, but the begin (and end) locations differ:

"foo
	bar"
s(:dstr,
  s(:str, "foo\n"),
  s(:str, "\tbar"))
"foo
~ begin
~~~~... expression
        bar"
           ~ end

s(:str, "foo\n")
"foo
 ~~~... expression

s(:str, "\tbar")
        bar"
       ~~~~ expression

@koic koic merged commit 3c70aad into rubocop:master Jul 13, 2019
@koic
Copy link
Member

koic commented Jul 13, 2019

Thanks!

@buehmann buehmann deleted the tab/4719 branch July 13, 2019 07:03
@bquorning
Copy link
Contributor

@buehmann I would be interested in hearing your opinion on the somewhat related issue #6420 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layout/Tab ignores indentation for “string split over multiple lines”
3 participants