[PATCH] conhost: Fix wrapping when write_console finishes on line end.

Gabriel Ivăncescu gabrielopcode at gmail.com
Wed Mar 31 06:42:54 CDT 2021


On 30/03/2021 22:21, Jacek Caban wrote:
> Hi Gabriel,
> 
> On 3/30/21 6:33 PM, Gabriel Ivăncescu wrote:
>> Remember the fact we completed the entire line in cursor_x, but report it
>> as usual in other cases as the last character on the line. When writing a
>> new character, a newline is then written so it wraps properly.
> 
> This doesn't seem to match what we should report to console client. See 
> the attached test (which applies on top of your patch).
> 
> Thanks,
> Jacek

Ok so, I admit I don't really understand the existing tests—or wine's 
behavior here. It seems that wine's conhost delays outputting a newline 
until a character is written. Then it writes the newline before the 
character. This is the current behavior.

On the other hand, from the tests I seen, Windows writes a newline as 
soon as a character is written that reaches the screen buffer width and 
needs to wrap around.

For example, if we have 2 characters until the end of the line, and we 
write "abc":

wine: a, b, \r\nc
windows: a, b\r\n, c

If we write "ab":

wine: a, b, \b
windows: a, b\r\n

In second case, wine doesn't output a newline at all. Instead, because 
of the "cursor_x--" thing, it outputs a \b instead. And of course since 
we don't keep track of this, the next write will overwrite the last 
character on the line (i.e. the "b") which is the problem here.

What I don't understand, though, is why the tests accommodate for Wine's 
behavior? I assumed it was intentional, that is why my patch keeps this 
current behavior and just fixes this corner case where writes finish on 
line end (like the second example above with "ab").

In the current *existing* tests, you can see stuff like:

     if (!skip_sequence("\b")) expect_output_sequence("\r\n");

This makes it pass on Windows, since it always outputs a newline 
immediately and never a backspace. In fact, removing the condition at 
all will *still* pass on Windows. So this condition is there for Wine? 
Is there a reason for it? And what should I keep in mind here to solve 
this "properly"?

If you remove the condition, of course wine will fail the tests, but 
Windows won't. I really don't understand it.

Thanks,
Gabriel



More information about the wine-devel mailing list