sw/source/core/text/frminf.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 8e1ab38cfef6d64e11fc9e6bf63317ad83514318
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Jun 12 17:16:01 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Jun 14 13:48:02 2024 +0200

    sw: fix SwTextFrameInfo::GetSpaces() for line containing only spaces
    
    This would assert:
    frminf.cxx:139: void AddRange(): Assertion `rRanges.empty() || 
rRanges.back().second <= nPos' failed.
    
    Change-Id: Ib41f4c6c971fee9307140c108e74d5df7d94c973
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168824
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit f97008c50ff88a7cf0a80a583a743ee1fb041327)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168807

diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx
index a123691db703..386f40942f5f 100644
--- a/sw/source/core/text/frminf.cxx
+++ b/sw/source/core/text/frminf.cxx
@@ -172,14 +172,15 @@ void SwTextFrameInfo::GetSpaces(
             // in the selection
             if( aLine.GetNext() )
             {
-                nPos = aLine.GetTextEnd();
+                TextFrameIndex const nEndPos{aLine.GetTextEnd()};
 
-                if( nPos < aLine.GetEnd() )
+                // if only whitespace in line, nEndPos < nPos !
+                if (nPos < nEndPos && nEndPos < aLine.GetEnd())
                 {
                     TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK ==
                         aLine.GetInfo().GetChar(aLine.GetEnd() - 
TextFrameIndex(1))
                                 ? 1 : 0 );
-                    AddRange( rRanges, nPos, aLine.GetEnd() - nPos - nOff );
+                    AddRange(rRanges, nEndPos, aLine.GetEnd() - nEndPos - 
nOff);
                 }
             }
         }

Reply via email to