contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.31k stars 100 forks source link

Alt screen does not move cursor same amount as primary screen for some emoji #1461

Open rockorager opened 4 months ago

rockorager commented 4 months ago

Contour Terminal version

contour-git from AUR

Installer source

something else (please specify below)

Operating System

Arch linux

Architecture

x86-64

Other Software

No response

Steps to reproduce

#!/bin/sh

echo "primary screen:"
echo "|--|"
echo "|🏳️‍🌈|"
echo "|📎|"
echo "|📡|"
sleep 5

echo -e "\x1b[?1049h\x1b[?2027h" # enter alt screen and turn on 2027
echo "alternate screen:"
echo "|--|"
echo "|🏳️‍🌈|"
echo "|📎|"
echo "|📡|"

sleep 5

echo -e "\x1b[?1049l"

Expected Behavior

In the alt screen, the cursor only moves one cell for some emoji

Actual Behavior

The cursor should move the same (correct) amount in the primary screen and alt screen

Additional notes

No response

christianparpart commented 4 months ago

Cursor movement mistakes are most likely a bug in unicode grapheme cluster's width handling. I wonder why it's only happening on alt screen and not on primary. Will figure it out. Many thanks for your report, @rockorager :)

christianparpart commented 4 months ago

Okay, this is a dup of #1375 - technically speaking. I am having a PR open over at libunicode that attempts to fix this (with better API and implementation). this should be fixed by the next major Contour release :)