Bug 217669 - Wrong behavior for 'delete char' ansi code
Summary: Wrong behavior for 'delete char' ansi code
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-07 01:20 UTC by Joel
Modified: 2010-04-28 04:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
The attached patch fixes the bug. (510 bytes, patch)
2010-04-20 05:15 UTC, Alexandre Becoulet
Details
The attached patch fixes the bug and the Q_ASSERT. (606 bytes, patch)
2010-04-23 02:08 UTC, Alexandre Becoulet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel 2009-12-07 01:20:49 UTC
Version:            (using KDE 4.3.4)
OS:                Linux
Installed from:    Archlinux Packages

The character deletion ansi code "[P" fails to delete the last character of a line.

This behavior is due to the void Screen::deleteChars(int n) function in Screen.cpp. The line lenght check seems wrong:

208	    if ( cuX+n >= screenLines[cuY].count() ) 
209	        n = screenLines[cuY].count() - 1 - cuX;

should probably be:

208	    if ( cuX+n > screenLines[cuY].count() ) 
209	        n = screenLines[cuY].count() - cuX;

which would be coherent with the existing Q_ASSERT:

212	    Q_ASSERT( cuX+n < screenLines[cuY].count() );

Regards,
Comment 1 Alexandre Becoulet 2009-12-14 14:11:45 UTC
*** This bug has been confirmed by popular vote. ***
Comment 2 Alexandre Becoulet 2010-04-20 05:13:26 UTC
The following bash command trigger the bug:

echo -n $'AB\x1b[1D\x1b[1P' ; sleep 5

This command writes 'AB' then moves backward with ESC [1D and fails to delete the 'B' character under cursor with ESC [1P. xterm, linux, screen and other terminal emulators do have the correct behavior and delete 'B'.
Comment 3 Alexandre Becoulet 2010-04-20 05:15:18 UTC
Created attachment 42911 [details]
The attached patch fixes the bug.
Comment 4 Kurt Hindenburg 2010-04-20 06:15:37 UTC
Did that patch actually work for you?  When I did, the ASSERT crashed my konsole.
Comment 5 Alexandre Becoulet 2010-04-20 15:04:58 UTC
Yes, I used it for a while on kdebase-4.3.4 before upgrading recently. I might not have Q_ASSERT enabled.

I realize that this line seems wrong too:

    Q_ASSERT( cuX+n < screenLines[cuY].count() )

    screenLines[cuY].remove(cuX,n);

For instance lets assume curX == 0, Q_ASSERT prevents removing all characters on the line. However screenLines[cuY].remove(0, screenLines[cuY].count()) is a valid operation. Isn't it ?
Comment 6 Alexandre Becoulet 2010-04-23 02:08:04 UTC
Created attachment 42977 [details]
The attached patch fixes the bug and the Q_ASSERT.
Comment 7 Kurt Hindenburg 2010-04-27 17:22:32 UTC
SVN commit 1119662 by hindenburg:

Correct ANSI's 'delete char' to delete the last character in a line.

Patch provided by Alexandre Becoulet

BUG: 217669


 M  +3 -3      Screen.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1119662
Comment 8 Kurt Hindenburg 2010-04-28 04:41:27 UTC
SVN commit 1119960 by hindenburg:

Correct ANSI's 'delete char' to delete the last character in a line.

Patch provided by Alexandre Becoulet

CCBUG: 217669


 M  +3 -3      Screen.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1119960