Bug 423814 - Backspace and Delete keys only delete one Byte, not a whole character
Summary: Backspace and Delete keys only delete one Byte, not a whole character
Status: RESOLVED NOT A BUG
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 20.04.1
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-02 21:54 UTC by Oussema Bouaneni
Modified: 2020-07-03 23:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Visual demonstration of the bug (1.25 MB, video/webm)
2020-07-02 21:54 UTC, Oussema Bouaneni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oussema Bouaneni 2020-07-02 21:54:30 UTC
Created attachment 129854 [details]
Visual demonstration of the bug

Summary

Say you wanted to check for updates, you go into Konsole and type `sudo pacman -Syu`.

>[oussema@glorious-manjaro ~]$ سعيخ حشؤةشى -ٍغع

Then you discover you typed the command in the wrong keyboard layout.
You switch the layout to US and press backspace until you're only left with the bash prompt.

>[oussema@glorious-manjaro ~]$ 

Then you type it again, properly this time, and press enter.

>[oussema@glorious-manjaro ~]$ sudo pacman -Syu
>bash: $'\330\263\330\271\331\212\330\256': command not found

What happened?
You try the exact same thing except you don't release the backspace key once you're only left with the bash prompt.
You discover that you can actually delete characters of the bash prompt.

>[oussema@gloriou

You go ahead and retype the command once the backspace key doesn't delete any characters anymore.

>[oussema@gloriousudo pacman -Syu
>[sudo] password for oussema:

It works properly this time.
A little research online shows being able to delete the bash prompt is usually due to unescaped color codes in the bash prompt.
But I can reproduce it even with a very simple bash prompt like 'Hello There: '.




STEPS TO REPRODUCE
1. Open Konsole
2. Paste in any character that takes more than one byte.
An illustrative example is 🜁  (U+1F701) which is 4 bytes. ('\360\237\234\201' in ANSI escape codes) 
3. Press backspace exactly once
4. Press Enter

OBSERVED RESULT
Only one byte is deleted, not the entire character. Bash think the remaining 3 bytes are a command.

>[oussema@glorious-manjaro ~]$ 
>bash: $'\360\237\234': command not found

You have to press backspace 4 times to delete the entire character at which point you're deleting part of the bash prompt.



EXPECTED RESULT
The entire character is deleted with only one press of backspace.

>[oussema@glorious-manjaro ~]$ 
>[oussema@glorious-manjaro ~]$ 


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Linux Manjaro
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.70.0
Qt Version: 5.15.0

ADDITIONAL INFORMATION
This bug is also in qterminal if it helps. 
I did my best to convey the issue purely through text. But if you want a visual demonstration, see the attached video.



This is my first time submitting a bug report here. I am aware that I probably included way too much useless information and that I could have gone straight to the point.
But I don't know what will be useful to you and what will just be a waste of your time so bear with me.
Thank you in advance. Have a good day!
Comment 1 Oussema Bouaneni 2020-07-03 23:40:37 UTC
Sorry about that. Turns out this was due to a weird locale issue I was having. Once I fixed that, everything started working properly once again and now I can't reproduce the issue anymore.