Add some test cases and asserts for new pretty printing - we were not
properly handing the case when print formatter was not at the start of
the buffer.
A simple fix is to add a lookback_barrier, which is an index into the
buffer that backtracking print formatter can't go past. This ensures
that, whatever newlines are replace with spaces, we don't mess with any
explicit newlines that should be printed.
Also some tweaks to logic to try an make invariants more obvious and
simplify looping and indexing.
Indentation levels are not sufficiently clear for deeply nested
data structures. Instead, align items in a collection
with its opening bracket, also known as hanging indentation.
To avoid guessing the length of a "short" collection to print it
on one line, items are now always printed on separate lines.