Bug 385694 - Backspace deletes the wrong character in Arabic text
Summary: Backspace deletes the wrong character in Arabic text
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: 17.08.1
Platform: Neon Linux
: NOR major
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: rtl
: 367722 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-10-13 11:25 UTC by Fahad Al-Saidi
Modified: 2022-03-23 07:15 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
the problem (72.08 KB, image/gif)
2020-11-02 07:35 UTC, Fahad Al-Saidi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fahad Al-Saidi 2017-10-13 11:25:03 UTC
In Arabic text, If you have only one line, things looks fine but if you have multi-lines and you enabled dynamic word warp, if you click in the middle line and press backspace button, the forward character will be deleted instead of the backward letter.

This bug is very annoyed. It makes using kate for text editing in Arabic frustrating experience. 

Steps to reproduce:

1- make sure that you enabled dynamic word warp.
2- enter any Arabic text, that get warped, such as:
السلام السلام السلام السلام السلام السلامالسلام السلام السلامالسلام السلام السلام السلام السلام السلامالسلام السلام السلام السلام السلام السلامالسلام السلام السلامالسلام السلام السلام السلام السلام السلام

3- choose any word and try to delete a letter.
Comment 1 Justin Zobel 2020-10-30 05:36:33 UTC
Fahad I've just tried this on kate from git master and deleting letters from words in the text you provided works as I would expect.

Can you please confirm if this issue is still present for you.
Comment 2 Fahad Al-Saidi 2020-11-02 07:30:43 UTC
(In reply to Justin Zobel from comment #1)
> Fahad I've just tried this on kate from git master and deleting letters from
> words in the text you provided works as I would expect.
> 
> Can you please confirm if this issue is still present for you.

NO the bug still there. I check it.
Comment 3 Fahad Al-Saidi 2020-11-02 07:35:38 UTC
Created attachment 132956 [details]
the problem

this screen recording about the problem. notice that put the cursor after "لا" then I hit backspace the letter "م" deleted!
Comment 4 Christoph Feck 2020-11-09 23:53:00 UTC
Thanks for the update; changing status.
Comment 5 Waqar Ahmed 2020-12-14 10:10:36 UTC
This bug happens because of how text is wrapped dynamically and it is easier to understand it if you turn on "Show spaces".

Consider the following sentence:

This is a sentence.

Assume this sentence reached the view width, and now I enter a space character. The line will not wrap, and the space will be added to the end of the sentence, outside the border. 
                   |
This is a sentence.| [space][space]
                   |

This is all good, now lets see what happens when the text is RTL:

X .Some RTL Text

Assume "X" is the position of the cursor, and now I enter a space. The space is added to the sentence correctly, and the sentence is not wrapped as expected. However, Instead of increasing the cursor position on the left border, it is done on the right border like LTR text. The result is something like this (assume two spaces added):

                            |
X [space][space].Some RTL Te| xt
                            |

The above is what "actually" happens. If "Show spaces" is turned on, it can be seen directly. The text is painted according to the expectation, however the cursor is pointing to the wrong position.

In the above case, if I try to delete a character, the character that will get deleted will be the one that is two positions forward(because of two spaces).

I have tried to figure out where exactly this is handled but i have been unsuccessful so far. This can be a bug in Qt even, but I am not sure about it completely. Can any Kate Dev drop some hints?
Comment 6 Christoph Cullmann 2020-12-14 17:46:41 UTC
*** Bug 367722 has been marked as a duplicate of this bug. ***
Comment 8 Bug Janitor Service 2022-03-22 15:12:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/342
Comment 9 Waqar Ahmed 2022-03-22 17:52:42 UTC
Git commit dc7d5b99a7691327d0da97e17906c9bba4e35371 by Waqar Ahmed.
Committed on 22/03/2022 at 15:11.
Pushed by cullmann into branch 'master'.

Fix cursor in RTL text with dyn wrap on

Also fix the issue that the cursor is not visible in column 0.
Related: bug 368182

M  +11   -0    src/render/katerenderer.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/dc7d5b99a7691327d0da97e17906c9bba4e35371
Comment 10 Fahad Al-Saidi 2022-03-23 07:15:42 UTC
thanks @Waqar for fixing RTL bugs in kate.