Bug 426655

Summary: ANSI Escape Codes result in incorrect or truncated rendering of content; git-delta titles truncated
Product: [Applications] konsole Reporter: andydecleyre
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: normal CC: andydecleyre
Priority: NOR    
Version: 20.07.80   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Intermittent hiding of that character (video)

Description andydecleyre 2020-09-17 21:51:55 UTC
Created attachment 131733 [details]
Intermittent hiding of that character (video)

SUMMARY

.. note:: Not sure about proper component, maybe emulation, maybe font
.. note:: Initially reported @ https://github.com/dandavison/delta/issues/324

First tested with:

konsole 20.08.1
git-delta 0.4.3

Reproduced with konsole down through 20.07.80, but not reproduced with 20.04.3.

STEPS TO REPRODUCE
1. Install konsole and git-delta
2. 

    % printf '%s\n' 1 2 3 4 >a.txt
    % printf '%s\n' 1 TWO 3 FOUR >b.txt
    % diff -u a.txt b.txt | delta

OBSERVED RESULT

The final 't' in 'b.txt' is not displayed.

EXPECTED RESULT

The final 't' in 'b.txt' is displayed.

SOFTWARE/OS VERSIONS

KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1

ADDITIONAL INFORMATION

    % diff -u a.txt b.txt | delta | cat -A
    $
    ^[[38;5;4mcomparing: a.txt M-bM-^_M-6   b.txt^[[0m$
    ^[[38;5;4mM-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@^[[0m$
    $
    ^[[38;5;4m1^[[0m$
    ^[[38;5;7m1^[[0m$
    ^[[48;2;63;0;1m2^[[0m^[[48;2;63;0;1m^[[0K^[[0m$
    ^[[48;2;0;40;0;38;5;7mTWO^[[0m^[[48;2;0;40;0m^[[0K^[[0m$
    ^[[38;5;7m3^[[0m$
    ^[[48;2;63;0;1m4^[[0m^[[48;2;63;0;1m^[[0K^[[0m$
    ^[[48;2;0;40;0;38;5;7mFOUR^[[0m^[[48;2;0;40;0m^[[0K^[[0m$

---

I used git bisect to find the problem was introduced with:

    commit 8ad28a12574cadc7a41e152ec683380d7743c2a8
    Author: Mariusz Glebocki <mglb@arccos-1.net>
    Date:   Sat Mar 28 10:42:53 2020 -0400
    
        Group rendered characters by script
    
        https://invent.kde.org/mglebocki/konsole complex-scripts-support
        CCBUG: 401094
    
     src/TerminalDisplay.cpp | 54 ++++++++++++++++++++++---------------------------
     1 file changed, 24 insertions(+), 30 deletions(-)

So I'll link:

- https://bugs.kde.org/show_bug.cgi?id=401094
- https://invent.kde.org/utilities/konsole/-/commit/8ad28a12

---

Actually, it displays and hides that character on and off as window/cursor states change. I'll attach a video.
Comment 1 andydecleyre 2020-09-19 02:59:33 UTC
Thanks to dandavison, a simple reproduction:

    $ printf "\x1b[38;5;4mcomparing: a.txt ⟶  b.txt\x1b[0m\n"

And with the arrow removed, the visible text is not truncated, so seems like a character width disagreement.