Skip to content

Inspect.Algebra.pretty and .line #2014

@tallakt

Description

@tallakt

It seems that when implementing a multi-line inspect, if you use the line() function the column width counter is not reset for each line. The result being that the second line is broken too early.

Better explained with some code:

defmodule X do                                      
  import Inspect.Algebra                              

  def possible_bug do                                            
    IO.puts(pretty(line(glue("aaaaa", "bbbbb"), glue("ccccc", "ddddd")), 20))
  end
end
iex(114)> X.possible_bug                                                               
aaaaa bbbbb
ccccc
ddddd
:ok

I would have expected the output to be broken into two lines in this instance. It seems that the break between ccccc and ddddd occurs as they all won't fit in 20 characters.

Elixir 0.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions