Bug 342322

Summary: bidi text with parentheses enclosing Hebrew: both parentheses face the same direction
Product: [Applications] kate Reporter: phma
Component: Vi Input ModeAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: minor CC: ilmari.lauhakangas, jpmbatrina01
Priority: NOR    
Version First Reported In: 16.04.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Sample text which shows the bug.
Screenshot of Kate showing the above file
Screenshot from 16.04.2
Screenshot from 20.08.1 (windows) in comparison to Firefox rendering

Description phma 2014-12-30 01:22:51 UTC
Using capital letters to represent right-to-left text, the bidirectional text is:
parsha 21 is YOU COUNT (THE HEADS OF ISRAELITES); this is COUNTING (THE HEADS OF GERSHONITES)
expected rendering:
parsha 21 is (SETILEARSI FO SDAEH EHT) TNUOC UOY; this is (SETINOHSREG FO SDAEH EHT) GNITNUOC
actual rendering:
parsha 21 is SETILEARSI FO SDAEH EHT) TNUOC UOY); this is SETINOHSREG FO SDAEH EHT) GNITNUOC)
As the text between the parentheses is entirely in Hebrew, this shouldn't happen, but even with bidirectional embedding characters, it does. (I hope those characters are right. I inserted them as bytes using okteta.)

Note that two lines have wrong parentheses )like this(. I was unaware that the Hebrew keyboard layout has 0x28 on shift-0 and 0x29 on shift-9. I duplicated the lines and fixed them in the other two lines.

The text is a comment I inserted at parsha 35 in a translation of the Bible into Lojban.

Reproducible: Always

Steps to Reproduce:
1. Type some text in left-to-right alphabet, then a left parenthesis.
2. Switch to the Hebrew layout and type some text.
3. Switch back to Latin/Cyrillic/Greek/autc. and type more text.
4. Insert a Hebrew word before the parenthesis.

Actual Results:  
Before step 4, the opening parenthesis is on the left, facing right, and the closing parenthesis is on the right, facing left. After step 4, the opening parenthesis is where the closing parenthesis was, facing left, and the closing parenthesis jumped past the inserted word, which is right of the words in parentheses, and is also facing left.

Putting the cursor on one parenthesis correctly highlights both, even though they are facing the same direction.

Expected Results:  
Before step 4, the opening parenthesis is on the right, facing left, and the closing parenthesis is on the left, facing right (indistinguishable from the actual, unless you highlight one parenthesis). After step 4, the parentheses have not moved, and the inserted word is right of the words in parentheses.

Kate version is 3.13.3, not 3.13.2.
Comment 1 phma 2014-12-30 01:24:58 UTC
Created attachment 90164 [details]
Sample text which shows the bug.
Comment 2 phma 2014-12-30 01:26:41 UTC
Created attachment 90165 [details]
Screenshot of Kate showing the above file
Comment 3 Buovjaga 2016-06-21 17:39:38 UTC
Created attachment 99646 [details]
Screenshot from 16.04.2

I get a different, but still messed up result.

Arch Linux 64-bit
Kate 16.04.2
KDE Frameworks 5.22.0
Qt 5.6.1
xcb wm
Comment 4 Jan Paul Batrina 2020-12-25 14:54:20 UTC
Created attachment 134324 [details]
Screenshot from 20.08.1 (windows) in comparison to Firefox rendering
Comment 5 Jan Paul Batrina 2020-12-25 14:55:58 UTC
I think this has been fixed (not sure from which version, at the very least it is fixed in version 20.08.1)

My only point of comparison is the rendering from firefox, so feel free to reopen if more examples come up that exhibit the wrong behavior.