[orca] Web: Don't collapse newlines from a single text object into one line



commit d0c1fc177a6c4a0a8dac97c73da412076db35d40
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Feb 17 14:11:44 2021 +0100

    Web: Don't collapse newlines from a single text object into one line
    
    Given a plain text file viewed in a browser or browser-based email
    application, we were collapsing a series of newlines into a single
    newline in browse mode. This results in a different presentation
    than one gets in plain text editors such as Gedit, so stop doing
    this.

 src/orca/scripts/web/script_utilities.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index ea68c2e07..c7ae50e73 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -726,7 +726,7 @@ class Utilities(script_utilities.Utilities):
 
         if skipSpace:
             text = self.queryNonEmptyText(nextobj)
-            while text and text.getText(nextoffset, nextoffset + 1).isspace():
+            while text and text.getText(nextoffset, nextoffset + 1) in [" ", "\xa0"]:
                 nextobj, nextoffset = self.findNextCaretInOrder(nextobj, nextoffset)
                 text = self.queryNonEmptyText(nextobj)
 
@@ -742,7 +742,7 @@ class Utilities(script_utilities.Utilities):
 
         if skipSpace:
             text = self.queryNonEmptyText(prevobj)
-            while text and text.getText(prevoffset, prevoffset + 1).isspace():
+            while text and text.getText(prevoffset, prevoffset + 1) in [" ", "\xa0"]:
                 prevobj, prevoffset = self.findPreviousCaretInOrder(prevobj, prevoffset)
                 text = self.queryNonEmptyText(prevobj)
 
@@ -1760,6 +1760,9 @@ class Utilities(script_utilities.Utilities):
             if text and text.getText(pOffset, pOffset + 1) in [" ", "\xa0"]:
                 prevObj, pOffset = self.findPreviousCaretInOrder(prevObj, pOffset)
 
+            if text and text.getText(pOffset, pOffset + 1) == "\n" and firstObj == prevObj:
+                break
+
             onLeft = self._getContentsForObj(prevObj, pOffset, boundary)
             onLeft = list(filter(_include, onLeft))
             if not onLeft:
@@ -1778,6 +1781,9 @@ class Utilities(script_utilities.Utilities):
             if text and text.getText(nOffset, nOffset + 1) in [" ", "\xa0"]:
                 nextObj, nOffset = self.findNextCaretInOrder(nextObj, nOffset)
 
+            if text and text.getText(nOffset, nOffset + 1) == "\n" and lastObj == nextObj:
+                break
+
             onRight = self._getContentsForObj(nextObj, nOffset, boundary)
             if onRight and self._contentIsSubsetOf(objects[0], onRight[-1]):
                 onRight = onRight[0:-1]


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