editeng/source/editeng/impedit2.cxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 8bbe0eacd826f33f9cd4f1aec77220b29d4a4e7b
Author:     Eike Rathke <[email protected]>
AuthorDate: Wed Jan 19 21:32:21 2022 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Fri Jan 21 15:32:19 2022 +0100

    Resolves: tdf#139974 Do not munge character after forced line break
    
    A classical +-1 error..
    
    Change-Id: I8b6bc0843fa585d8a710c74f757098ab9c6f823d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128637
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins
    (cherry picked from commit 2cfa04cbf03fe5c2ce32a7384082cdc5de5a4785)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128541
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit 2b8946e52fa170c7df4bf71440e2ed63474db28f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128671
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 1381e416780a..5880948068cb 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2728,8 +2728,10 @@ EditPaM ImpEditEngine::ImpInsertText(const 
EditSelection& aCurSel, const OUStrin
             if (nChars > MAXCHARSINPARA)
             {
                 sal_Int32 nMaxNewChars = std::max<sal_Int32>(0, MAXCHARSINPARA 
- nExistingChars);
-                nEnd -= ( aLine.getLength() - nMaxNewChars ); // Then the 
characters end up in the next paragraph.
-                aLine = aLine.copy( 0, nMaxNewChars );        // Delete the 
Rest...
+                // Remaining characters end up in the next paragraph. Note that
+                // new nStart will be nEnd+1 below so decrement by one more.
+                nEnd -= (aLine.getLength() - nMaxNewChars + 1);
+                aLine = aLine.copy( 0, nMaxNewChars );  // Delete the Rest...
             }
             if ( IsUndoEnabled() && !IsInUndo() )
                 InsertUndo(std::make_unique<EditUndoInsertChars>(pEditEngine, 
CreateEPaM(aPaM), aLine));

Reply via email to