I have been misunderstanding the intention of the "trailing whitespace" metric. This should not be about counting any and all whitespace at the end of a line, but rather the range of trailing whitespace that is not relevant for layout. A good heuristic for this is "whitespace the absence of which would not change the drawing of a selection that spans multiple lines".
For our purposes, this should also always include the trailing newline.
I think it's probably worth getting this in for the next piet release, which should be quite imminent.
expanding on https://github.com/linebender/piet/issues/409#issuecomment-791806965:
I have been misunderstanding the intention of the "trailing whitespace" metric. This should not be about counting any and all whitespace at the end of a line, but rather the range of trailing whitespace that is not relevant for layout. A good heuristic for this is "whitespace the absence of which would not change the drawing of a selection that spans multiple lines".
For our purposes, this should also always include the trailing newline.
I think it's probably worth getting this in for the next piet release, which should be quite imminent.