migueldeicaza / SwiftTerm

Xterm/VT100 Terminal emulator in Swift
MIT License
993 stars 146 forks source link

Undesired wrap #316

Closed migueldeicaza closed 1 year ago

migueldeicaza commented 1 year ago

On a terminal with 97 columns, the following text wraps around due to an extra space.

This should render like this:

image

Instead it renders like this:

image

base64 encoded repro:

ICAgIBtbMW1HbGFtb3VyG1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMzg7NTsyNDNtIFVwZGF0ZWQgMjIgaG91 cnMgYWdvG1swbSAgCiAgICAbWzM4OzU7MjQzbVN0eWxlc2hlZXQtYmFzZWQgbWFya2Rvd24g cmVuZGVyaW5nIGZvciB5b3VyIENMSSBhcHBzIOKAje+4jyBbbWlycm9yXRtbMG0gICAgICAg ICAgICAgICAgICAgICAgICAgICAgIAogICAgG1szODs1OzEzMm1naXQgY2xvbmUgZ2l0QGdp dC5jaGFybS5zaDpnbGFtb3VyLmdpdBtbMG0gICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgCg==

migueldeicaza commented 1 year ago

fixed, there was a Zero-Width-Rejoinder in the output (ZWJ, U+200D) which caused the line to advance further.

I suspect that I should not advance if chWidth == 0, but other terminals seem to only special case this character (in fact, this sample file contains both U+200D and immediately after a U+FE0F, but the second gets added, while the first is not.