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

Moves comments in class methods around #295

Closed
mikker opened this issue May 31, 2021 · 3 comments
Closed

Moves comments in class methods around #295

mikker opened this issue May 31, 2021 · 3 comments

Comments

@mikker
Copy link
Contributor

mikker commented May 31, 2021

Only seems to happen in def self.blahblah style class methods.

  • Ruby version: 2.7.3p183
  • Rubyfmt git sha: 9090 [...] (latest, tag:v0.6.0)

Input file

class A
  def self.m
    # @@formatted_op_names.compute_if_absent(operation_name) do
    #   operation_name.to_s.split('_').collect(&:capitalize).join
    # end
    operation_name
  end
end

Rubyfmt's output

class A
  def self.m
  # @@formatted_op_names.compute_if_absent(operation_name) do
  #   operation_name.to_s.split('_').collect(&:capitalize).join
  # end
    operation_name
  end
end

ALSO

Input file

class A
  def self.m
    operation_name
    # @@formatted_op_names.compute_if_absent(operation_name) do
    #   operation_name.to_s.split('_').collect(&:capitalize).join
    # end
  end
end

Rubyfmt's output

class A
  def self.m
    operation_name
  end

  # @@formatted_op_names.compute_if_absent(operation_name) do
  #   operation_name.to_s.split('_').collect(&:capitalize).join
  # end
end

This breaks because

I expected the comments to stay where they were.

@fables-tales
Copy link
Owner

Comments shakes fist

@fables-tales
Copy link
Owner

@mikker this was a very easy bug to fix, and along with your other one, I'm gonna cut a 0.6.7 release today which includes both

@mikker
Copy link
Contributor Author

mikker commented May 31, 2021

You're the best, thank you!

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