Bug Hunting Session
Bug 101361 - Cursor keys move cursor to the opposite direction in RTL text
Summary: Cursor keys move cursor to the opposite direction in RTL text
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.2.0.4 release
Hardware: All All
: high normal
Assignee: Khaled Hosny
URL:
Whiteboard: target:5.3.0 target:5.2.2
Keywords: bibisected, bisected, regression, text:rtl
: 101441 101969 (view as bug list)
Depends on:
Blocks: RTL-CTL
  Show dependency treegraph
 
Reported: 2016-08-06 20:13 UTC by Yotam Benshalom
Modified: 2016-10-29 19:33 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yotam Benshalom 2016-08-06 20:13:04 UTC
Cursor keys move cursor to the opposite direction in RTL text.
To reproduce:
1. Open a writer document (I use the gtk3 rendering - it may be related).
2. Type in some text in an RTL language, such as Hebrew or Arabic. Make sure that the paragraph language is properly identified.
3. Try to move the cursor with the keys. The cursor moves in the opposite direction.

This is a regression from the 5.1 series.
This renders writer unusable for RTL texts.
Comment 1 Khaled Hosny 2016-08-06 21:12:02 UTC
I can confirm this. Changing “Tools → Options → Language Settings → Complex Text → Layout → Cursor Control” from Logical to Visual has no effect either.
Comment 2 V Stuart Foote 2016-08-10 19:30:45 UTC
*** Bug 101441 has been marked as a duplicate of this bug. ***
Comment 3 Gil Shwartz 2016-08-26 15:56:21 UTC
Confirmed regression LO5.2.0.4 on Mint 17.3 Mate.

Note that 5.2 tooltip for "Logical" cursor control describes the observed cursor behavior for logical movement. However, this movement is different from previous LO versions for logical, which was paragraph directionality dependent (and rightfully so). The new tooltip for Logical described LTR logical behavior, and misses the RTL logical behavior.

This is independent of "Visual", which again has a tooltip that describes the LTR visual behavior, but not the RTL visual behavior.

Changing CTL Cursor Control between Logical and Visual works fine (you must have mixed LTR and RTL characters in the same sentence to see that), however, the bug of not switching the roles of the left and right arrows for RTL paragraphs (in both Logical and Visual modes) indeed exists and is a regression from previous LO versions.
Comment 4 Khaled Hosny 2016-08-31 23:32:16 UTC
I did some digging and found a change that fixes this issue for my limited testing:
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 63d8994..1babc48 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -905,7 +905,7 @@ static void lcl_VisualMoveRecursion( const SwLineLayout& rCurrLine, sal_Int32 nI
         pPor = pPor->GetPortion();
     }
 
-    if ( bRight )
+    if ( !bRight )
     {
         bool bRecurse = pPor && pPor->IsMultiPortion() &&
                            static_cast<const SwMultiPortion*>(pPor)->IsBidi();

However this code have not been changed since almost forever, so I’m puzzled why it broke now. It would be very helpful if we can get a bisect here, or at least the exact release where it broke, any one volunteering?

PS. The issue happens also without GTK, and happens only in Writer.
Comment 5 Maxim Monastirsky 2016-09-01 06:44:16 UTC
Regression of:

commit a215cec969f7401b08cabb686c5b2b1d803399d0
Author: Jaskaran <jvsg1303@gmail.com>
Date:   Thu Mar 10 08:33:39 2016 +0530

    tdf#32531 Fix for key movement in table cell of different directionality
    
    Change-Id: I7bd864176c9766dc8d030dd73d9b8ddd81ea2ee5
    Reviewed-on: https://gerrit.libreoffice.org/23107
    Tested-by: Jenkins <ci@libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Comment 6 Khaled Hosny 2016-09-01 11:36:54 UTC
Thanks Maxim, much appreciated.
Comment 7 Commit Notification 2016-09-01 12:53:23 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=67192b3cfa54be7b0b60d450783ac2ac4c38bbc6

tdf#101361: Fix cursor key movement in RTL text

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2016-09-02 13:02:04 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=438a76a9a261b9ada7b2758a66cd935d1760da39&h=libreoffice-5-2

tdf#101361: Fix cursor key movement in RTL text

It will be available in 5.2.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Maxim Monastirsky 2016-09-07 17:08:47 UTC
*** Bug 101969 has been marked as a duplicate of this bug. ***