Skip to content

pp: fix the width and indentation of second and later line contents #5978

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

Merged

Conversation

makenowjust
Copy link
Contributor

For example,

class X
  def pretty_print(pp : PrettyPrint)
    100.times do
      pp.group do
        pp.text "x"
        pp.breakable
      end
    end
  end
end

pp X.new

Above code prints this:

X.new # => x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
           x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
           x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
           x x x x x x x

This second and third lines are shorter than first line, it seems odd.

Expected result:

X.new # => x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
           x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
           x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x

This PR fixes pp and PrettyPrint to output correctly.

Verified

This commit was signed with the committer’s verified signature.
makenowjust Hiroya Fujinami
@RX14 RX14 added this to the Next milestone Apr 21, 2018
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Apr 21, 2018
@RX14 RX14 merged commit 32f46c1 into crystal-lang:master Apr 21, 2018
chris-huxtable pushed a commit to chris-huxtable/crystal that referenced this pull request Jun 6, 2018

Verified

This commit was signed with the committer’s verified signature. The key has expired.
chris-huxtable Chris Huxtable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants