Skip to content

Align control structure statements with method chaining #63

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

Closed
kddnewton opened this issue May 3, 2022 · 2 comments
Closed

Align control structure statements with method chaining #63

kddnewton opened this issue May 3, 2022 · 2 comments

Comments

@kddnewton
Copy link
Member

In case that some control structure statement chain methods, the indentations are not aligned.

ok:

if condition
  #...
  value1
else
  #...
  value2
end.method1 do |this|
  #...
end.method2

ng:

if condition
  #...
  value1
  else         # <- x
    #...
    value2
  end.method1  # <- x
  .method2     # <- cause by the beginning of the line is a dot
  .method3 do
    #...
  end
  .method4

Originally from prettier/plugin-ruby#1211.

@wenderjean
Copy link
Contributor

I figured out that for this specific case if I do not consider those blocks as chained at this point the formater behaves like expected but I'm not sure yet how to create the condition.

def self.chained?(node)
  case node
  in Call | MethodAddBlock[call: Call]
    true
  else
    false
  end
end

@kddnewton
Copy link
Member Author

Closing this until it's rereported, as it's been open for a long time and I don't have the energy to get to it.

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

No branches or pull requests

2 participants