[orca: 1/3] Revert part of "Fix braille updating when backspacing text on long lines"



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

    Revert part of "Fix braille updating when backspacing text on long lines"
    
    This partly reverts commit e758beabf9dee604be353230f9d5e5ed3a98ae2b
    which mixed offsets a bit too much in getTextLineAtCaret.

 src/orca/scripts/default.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index bf37cecf6..c54b4e65b 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -3592,10 +3592,7 @@ class Script(script.Script):
         except NotImplementedError:
             return ["", 0, 0]
 
-        if startOffset is None:
-            startOffset = max(0, text.caretOffset)
-
-        # The offset might be positioned at the very end of the text area.
+        # The caret 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
@@ -3609,15 +3606,17 @@ class Script(script.Script):
         # to see if that character is a newline - if it is, we'll treat it
         # as the line.
         #
-        if startOffset == text.characterCount:
-            startOffset = max(0, startOffset - 1)
-            character = text.getText(startOffset, startOffset + 1)
+        if text.caretOffset == text.characterCount:
+            caretOffset = max(0, text.caretOffset - 1)
+            character = text.getText(caretOffset, caretOffset + 1)
         else:
+            caretOffset = text.caretOffset
             character = None
 
-        if (startOffset == text.characterCount) \
+        if (text.caretOffset == text.characterCount) \
             and (character == "\n"):
             lineString = ""
+            startOffset = caretOffset
         else:
             # Get the line containing the caret.  [[[TODO: HACK WDW - If
             # there's only 1 character in the string, well, we get it.  We
@@ -3625,13 +3624,14 @@ class Script(script.Script):
             # is broken if there is just one character in the string.]]]
             #
             if (text.characterCount == 1):
-                lineString = text.getText(startOffset, startOffset + 1)
+                lineString = text.getText(caretOffset, caretOffset + 1)
+                startOffset = caretOffset
             else:
-                if startOffset == -1:
-                    startOffset = text.characterCount
+                if caretOffset == -1:
+                    caretOffset = text.characterCount
                 try:
                     [lineString, startOffset, endOffset] = text.getTextAtOffset(
-                        startOffset, pyatspi.TEXT_BOUNDARY_LINE_START)
+                        caretOffset, pyatspi.TEXT_BOUNDARY_LINE_START)
                 except:
                     return ["", 0, 0]
 


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