Subject: Re: [PATCH v4] pretty-formats: add hard truncation, without ellipsis, options

From: Junio C Hamano <[email-masked]>
Date: Tue, 29 Nov 2022 09:18:51 +0900

Philip Oakley <[email-masked]> writes:

>> If the given display space is 5 columns, the desirable behaviour for
>> trunk and ltrunk is still clear.  Instead of consuming two dots, we
>> could use a single dot as the filler.  As I said, I suspect that the
>> implementation of trunk and ltrunc does this correctly, though.
>
> I believe there is a possible solution that, if we detect a column
> over-run, then we can go back and replace the current two column double
> dot with a narrow U+2026 Horizontal ellipsis, to regain the needed column.

It would work, too.  As "trunc" and "ltrunc" (and "mtrunc") are
about "truncate and show the filler to indicate some letters in the
original are not shown, and make the result exactly N columns", it
can use a narrower filler than the originally specified and use the
alloted space.

>> My worry is it is not clear what Trunk and Ltrunk should do in that
>> case.  There is no way to fit a substring of [1][2][3][4] into 5
>> columns without any filler.
> For this case where the final code point overruns, my solution
> could/would be to use the Vertical ellipsis U+22EE "⋮" to re-write that
> final character (though the Unicode Replacement Character "�" could be
> used, but that's ugly)

That would be "trunc" not "Trunc", wouldn't it?  If the capital
letter verions are "hard truncate" without filler, it fundamentally
cannot be done to fill 5 display spaces only with letters each of
which take 2 display spaces.

I am not saying that there is an impossible situation to handle and
"hard truncate" primitives should not be invented.  I just want us
to specify (and document) what happens in such a case, so that it no
longer is an "impossible" situation (we can say "odd/leftover
columns are filled with minimum number of SP to make the result N
display spaces", for example).  And not calling it "hard truncate"
might be a good place to start, as it won't be "hard truncate" with
such a padding.