diff --git a/libaegisub/common/karaoke_matcher.cpp b/libaegisub/common/karaoke_matcher.cpp index 8d8477b4a7..5ac79ee755 100644 --- a/libaegisub/common/karaoke_matcher.cpp +++ b/libaegisub/common/karaoke_matcher.cpp @@ -213,6 +213,7 @@ namespace agi { void KaraokeMatcher::SetInputData(std::vector&& src, std::string&& dst) { syllables = std::move(src); matched_groups.clear(); + character_positions.clear(); src_start = 0; src_len = syllables.size() ? 1 : 0; @@ -239,7 +240,7 @@ std::string KaraokeMatcher::GetOutputLine() const { } bool KaraokeMatcher::IncreaseSourceMatch() { - if (src_start + src_len < syllables.size()) { // FIXME: off-by-one? + if (src_start + src_len < syllables.size()) { ++src_len; return true; } diff --git a/src/dialog_kara_timing_copy.cpp b/src/dialog_kara_timing_copy.cpp index b7cd4ce8d9..115a860b8d 100644 --- a/src/dialog_kara_timing_copy.cpp +++ b/src/dialog_kara_timing_copy.cpp @@ -82,9 +82,9 @@ class KaraokeLineMatchDisplay final : public wxControl { std::string GetOutputLine() const { return matcher.GetOutputLine(); } /// Number of syllables not yet matched from source - size_t GetRemainingSource() const { return matcher.UnmatchedSource().size(); } + size_t GetRemainingSource() const { return matcher.UnmatchedSource().size() + matcher.CurrentSourceSelection().size(); } /// Number of characters not yet matched from destination - size_t GetRemainingDestination() const { return matcher.UnmatchedDestination().size(); } + size_t GetRemainingDestination() const { return matcher.UnmatchedDestination().size() + matcher.CurrentDestinationSelection().size(); } // Adjust source and destination match lengths void IncreaseSourceMatch(); @@ -301,7 +301,8 @@ void KaraokeLineMatchDisplay::OnPaint(wxPaintEvent &) void KaraokeLineMatchDisplay::SetInputData(AssDialogue *src, AssDialogue *dst) { last_total_matchgroup_render_width = 0; - matcher.SetInputData(ParseKaraokeSyllables(src), dst->GetStrippedText()); + matcher.SetInputData(ParseKaraokeSyllables(src), dst ? dst->GetStrippedText() : ""); + Refresh(true); } void KaraokeLineMatchDisplay::IncreaseSourceMatch()