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
Format: spurious space at end of line #7720
Comments
Comment author: @Octachron The space at the end of the line is not spurious from the point of view of Format's implementation. This is due to the fact that "Format.set_margin 10" also sets the maximum indentation limit to 5. Consequently, the second box is rejected to the left with a forced new line. Since the break is introduced by the opening of the box, the previous break hint "@ " is printed as a space. The easiest fix in this situation is to also adjust the maximum indentation limit: Format.set_margin 10; Format.set_max_indent 8; displays the expected output 123456·A Similarly, the difference in behavior that you observed by shortening the length of the format string is due to the fact that when the content of a box fits on a line, all formatting indication (and the maximum indentation limit) are ignored because the box is replaced by a fits box. |
Comment author: gmelquiond There is something I am missing. The documentation of set_max_indent says: "once this limit is reached, new pretty-printing boxes are rejected to the left, if they do not fit on the current line." But the box containing A does fit on the line. So why would it be rejected to the left? |
Comment author: @Octachron You are right, there is a mismatch between the documentation and the implementation here: the rejection to the left happens if the parent box does not fit on the line, i.e. "once this limit is reached, new pretty-printing boxes are rejected to the left, if their parent box do not fit on the current line." |
Comment author: @Octachron I have proposed a documentation fix at #1596. |
Original bug ID: 7720
Reporter: gmelquiond
Assigned to: @Octachron
Status: assigned (set by @Octachron on 2018-02-04T17:24:44Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.06.0
Category: standard library
Has duplicate: #7804
Bug description
The code
Format.set_margin 10; Format.printf "@[@[123456@ @[A@]@ B@]@]@\n";;
produces
123456=
A B
where = denotes a spurious space.
I am also wondering why A was not put at the end of the first line. (Removing the box around A does so. Removing one of the outer boxes does so too. Removing B does so too.) I guess the two issues are related.
The text was updated successfully, but these errors were encountered: