From 11060c410f2d3d4caaa67c752baf8805bc2b0700 Mon Sep 17 00:00:00 2001 From: John Lambert Date: Thu, 20 Jun 2024 12:08:16 -0400 Subject: [PATCH] Fix 2, 2a, 2b verse merging --- src/SIL.Machine/Corpora/UsfmTextUpdater.cs | 3 +-- .../Corpora/UsfmTextUpdaterTests.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/SIL.Machine/Corpora/UsfmTextUpdater.cs b/src/SIL.Machine/Corpora/UsfmTextUpdater.cs index 785d61a1..9265a317 100644 --- a/src/SIL.Machine/Corpora/UsfmTextUpdater.cs +++ b/src/SIL.Machine/Corpora/UsfmTextUpdater.cs @@ -328,9 +328,8 @@ private IReadOnlyList AdvanceRows(IReadOnlyList segScrRefs if (compare == 0) { // source and row match - // grab the text and increment both + // grab the text - both source and row will be incremented in due time... rowTexts.Add(text); - sourceIndex++; break; } } diff --git a/tests/SIL.Machine.Tests/Corpora/UsfmTextUpdaterTests.cs b/tests/SIL.Machine.Tests/Corpora/UsfmTextUpdaterTests.cs index 2d5af667..4264fbe3 100644 --- a/tests/SIL.Machine.Tests/Corpora/UsfmTextUpdaterTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UsfmTextUpdaterTests.cs @@ -189,6 +189,20 @@ public void GetUsfm_Verse_RangeMultipleRowsSingleVerse() ); } + [Test] + public void GetUsfm_MergeVerseSegments() + { + var rows = new List<(IReadOnlyList, string)> + { + (ScrRef("MAT 2:2"), "Verse 2."), + (ScrRef("MAT 2:2a"), "Verse 2a."), + (ScrRef("MAT 2:2b"), "Verse 2b.") + }; + + string target = UpdateUsfm(rows); + Assert.That(target, Contains.Substring("\\v 2-3 Verse 2. Verse 2a. Verse 2b.\r\n")); + } + [Test] public void GetUsfm_Verse_OptBreak() {