sw/source/core/doc/DocumentRedlineManager.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 53560aa06462f1cf04d69acafed20da971bc5c27
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Mar 8 13:48:03 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Mar 9 10:40:47 2022 +0100

    sw: fix merging of format redlines in AppendRedline()
    
    This can cause:
    
    soffice.bin: sw/source/core/undo/undobj.cxx:1486: static void 
SwUndo::SetSaveData(SwDoc&, SwRedlineSaveDatas&): Assertion `rSData.empty() || 
rSData[0].m_bRedlineMoved || (rSData[0].m_nRedlineCount == 
rDoc.getIDocumentRedlineAccess().GetRedlineTable().size())' failed.
    
    When one character in middle of Format redline is deleted, then Undo.
    
    The condition is quite odd and apparently from initial CVS import; try
    to copy condition for merging Insert redlines instead.
    
    Change-Id: Ib56e12914269b878c16813b9e95b2f0df3330bbe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131208
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 2c2f4a1b080b..c2ddb046ef8b 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2156,8 +2156,8 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
 
                 case SwComparePosition::CollideEnd:
                     if( pRedl->IsOwnRedline( *pNewRedl ) &&
-                        pRedl->CanCombine( *pNewRedl ) && n &&
-                        *maRedlineTable[ n-1 ]->End() < *pStt )
+                        pRedl->CanCombine( *pNewRedl ) &&
+                        (n == 0 || *maRedlineTable[ n-1 ]->End() < *pStt))
                     {
                         // If that's the case we can merge it, meaning
                         // the new one covers this well
@@ -2169,8 +2169,9 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
                 case SwComparePosition::CollideStart:
                     if( pRedl->IsOwnRedline( *pNewRedl ) &&
                         pRedl->CanCombine( *pNewRedl ) &&
-                        n+1 < maRedlineTable.size() &&
-                        *maRedlineTable[ n+1 ]->Start() < *pEnd )
+                        (n+1 >= maRedlineTable.size() ||
+                         (*maRedlineTable[ n+1 ]->Start() >= *pEnd &&
+                          *maRedlineTable[ n+1 ]->Start() != *pREnd)))
                     {
                         // If that's the case we can merge it, meaning
                         // the new one covers this well

Reply via email to