Conversation
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
This was referenced Aug 23, 2023
Contributor
PR Check ResultsBenchmarkLinuxWindows |
c8543f8 to
04d372f
Compare
5051db4 to
c80afd8
Compare
c80afd8 to
3fa14d5
Compare
charliermarsh
approved these changes
Aug 23, 2023
Member
charliermarsh
left a comment
There was a problem hiding this comment.
I'm out of my depth here as I've never grappled with the printer -- but I did spend 10 minutes or so reading the PR summary and the code.
| StartTagMissing { kind: TagKind }, | ||
| StartTagMissing { | ||
| kind: TagKind, | ||
| }, |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes a bug in the Printer where the mode for a group was stale when testing if some content fits.
The input must have been of the form
What happened is:
Expandedmode to theprint_modesstate that is shared between printing and measuringFits::No, because the line ultimately doesn't fit, but it doesn't undo the writtengroup_modes[2] = Expandif_group_breakslooks up the value of group2ingroup_modeswhich still contains the staleExpandentry (it breaks)(. It won't print the(, but it assumes the layout as if group 2 breaks when measuring if it fitsThis PR implements a fix by always writing
group_modes[group_id] = Flatof the current group that should be measured. We already do this after measuring and inside offits_groups. This only extends it to override any stale entry for the outermost group too.This seems to come at a performance cost because there's now one additional write for every group (and there are many!). What would be nice is if there's a cheap way to restore
group_modesafter measuring fits but that would require that the group ids in the document are monotonic. While it's true that group ids are always increasing, it isn't guaranteed that their groups are written in the same order as the ids have been created.I used the chance to remove the (last?)
unwrapin thePrinterby returning ganErrif a document uses agroup_idthat hasn't been seen to this point.