diff --git a/src/SIL.LCModel/DomainImpl/AnalysisAdjuster.cs b/src/SIL.LCModel/DomainImpl/AnalysisAdjuster.cs index e571b889..98f82b4f 100644 --- a/src/SIL.LCModel/DomainImpl/AnalysisAdjuster.cs +++ b/src/SIL.LCModel/DomainImpl/AnalysisAdjuster.cs @@ -1455,9 +1455,9 @@ private void DetermineWhatToMove(int ichSource, int cchInsert, IStTxtPara source else if (cchInsert > 0 && seg.EndOffset <= ichSource + cchInsert) m_segPartlyMoved = seg; } - if (m_segPartlyMoved != null && m_segPartlyMoved.EndOffset == ichSource) + if (m_segPartlyMoved != null && DeltaIsEmpty(m_segPartlyMoved.EndOffset, ichSource, source)) { - // We are splitting the paragraph right at a segment boundary so there is + // We are splitting the paragraph at the equivalent of a segment boundary so there is // no need to copy this segment (as if it was split in the middle of this segment). m_segPartlyMoved = null; } @@ -1474,6 +1474,24 @@ private void DetermineWhatToMove(int ichSource, int cchInsert, IStTxtPara source } } + /// + /// Is the delta between the old segment boundary and the new segment boundary empty? + /// This fixes LT-18897. + /// + private bool DeltaIsEmpty(int endOffset, int ichSource, IStTxtPara source) + { + int start = Math.Min(endOffset, ichSource); + int end = Math.Max(endOffset, ichSource); + for (int i = start; i < end; i++) + { + if (!Char.IsWhiteSpace(source.Contents.Text[i])) + { + return false; + } + } + return true; + } + private List MoveAnalysisAndReferencesFromOldPara(int cchInsert, IStTxtPara source, bool fParaIsNew) {