Skip to content

Commit

Permalink
Fix kara replacer after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Dec 1, 2023
1 parent 22eb866 commit d44655f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion libaegisub/common/karaoke_matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ namespace agi {
void KaraokeMatcher::SetInputData(std::vector<ass::KaraokeSyllable>&& src, std::string&& dst) {
syllables = std::move(src);
matched_groups.clear();
character_positions.clear();
src_start = 0;
src_len = syllables.size() ? 1 : 0;

Expand All @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/dialog_kara_timing_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d44655f

Please sign in to comment.