[orca: 2/3] Fix braille updating when backspacing text on long lines



commit 24ad901c7414b8437f54ad0867019e5a4b9f75d3
Author: Samuel Thibault <samuel thibault ens-lyon org>
Date:   Sun Jul 1 23:35:44 2018 +0200

    Fix braille updating when backspacing text on long lines
    
    By making getTextLineAtCaret target startOffset when provided, instead of
    only text.caretOffset, called targetOffset.
    
    This also renames caretOffset into fixedTargetOffset since it is not
    necessarily the caret offset any more.

 src/orca/scripts/default.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index c54b4e65b..c2749d833 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3592,7 +3592,11 @@ class Script(script.Script):
         except NotImplementedError:
             return ["", 0, 0]
 
-        # The caret might be positioned at the very end of the text area.
+        targetOffset = startOffset
+        if targetOffset is None:
+            targetOffset = max(0, text.caretOffset)
+
+        # The offset might be positioned at the very end of the text area.
         # In these cases, calling text.getTextAtOffset on an offset that's
         # not positioned to a character can yield unexpected results.  In
         # particular, we'll see the Gecko toolkit return a start and end
@@ -3606,17 +3610,17 @@ class Script(script.Script):
         # to see if that character is a newline - if it is, we'll treat it
         # as the line.
         #
-        if text.caretOffset == text.characterCount:
-            caretOffset = max(0, text.caretOffset - 1)
-            character = text.getText(caretOffset, caretOffset + 1)
+        if targetOffset == text.characterCount:
+            fixedTargetOffset = max(0, targetOffset - 1)
+            character = text.getText(fixedTargetOffset, fixedTargetOffset + 1)
         else:
-            caretOffset = text.caretOffset
+            fixedTargetOffset = targetOffset
             character = None
 
-        if (text.caretOffset == text.characterCount) \
+        if (targetOffset == text.characterCount) \
             and (character == "\n"):
             lineString = ""
-            startOffset = caretOffset
+            startOffset = fixedTargetOffset
         else:
             # Get the line containing the caret.  [[[TODO: HACK WDW - If
             # there's only 1 character in the string, well, we get it.  We
@@ -3624,14 +3628,14 @@ class Script(script.Script):
             # is broken if there is just one character in the string.]]]
             #
             if (text.characterCount == 1):
-                lineString = text.getText(caretOffset, caretOffset + 1)
-                startOffset = caretOffset
+                lineString = text.getText(fixedTargetOffset, fixedTargetOffset + 1)
+                startOffset = fixedTargetOffset
             else:
-                if caretOffset == -1:
-                    caretOffset = text.characterCount
+                if fixedTargetOffset == -1:
+                    fixedTargetOffset = text.characterCount
                 try:
                     [lineString, startOffset, endOffset] = text.getTextAtOffset(
-                        caretOffset, pyatspi.TEXT_BOUNDARY_LINE_START)
+                        fixedTargetOffset, pyatspi.TEXT_BOUNDARY_LINE_START)
                 except:
                     return ["", 0, 0]
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]