Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(windows): Revert and the heard-as chips name an added word whole (in → in now), not "→ now" with nothing before the arrow

wquguru183f0491c9aa
diff --git a/windows/src/Cicada.Core/Correction.cs b/windows/src/Cicada.Core/Correction.cs
index d5ad5ac..5578e9b 100644
--- a/windows/src/Cicada.Core/Correction.cs
+++ b/windows/src/Cicada.Core/Correction.cs
@@ -29,6 +29,14 @@ public static class Correction
static bool Word(string c) => c.Length == 1 && char.IsAsciiLetterOrDigit(c[0]);
+ /// A fix as the UI names it (听成 X → Y, 已改回 X): the changed words, or the whole fix when
+ /// it only adds or drops words ("in" → "in now", whose changed part alone would be "" → " now").
+ public static (string From, string To) Label(LineFix f)
+ {
+ var c = Core(f.From, f.To);
+ return c.From.Length == 0 || c.To.Length == 0 ? (f.From, f.To) : c;
+ }
+
/// The part an edit changes, as a word: "解除质压" → "解除质押" is "质压" → "质押" (at least two
/// characters, so one refusal doesn't block every 压 → 押), and a Latin word stays whole
/// ("Un450P三" → "Uniswap V3", not "450P三" → "iswap V3").
diff --git a/windows/src/Cicada.Core/LiveFixes.cs b/windows/src/Cicada.Core/LiveFixes.cs
index 3ac2c0f..3b415e0 100644
--- a/windows/src/Cicada.Core/LiveFixes.cs
+++ b/windows/src/Cicada.Core/LiveFixes.cs
@@ -206,7 +206,7 @@ public sealed class LiveFixes
if (refusals[key] >= 2) Vocabulary.Forget(c.From, c.To);
}
Log.Debug($"fix reverted line={lineId}");
- Say(Strings.LF("已改回 %@,这场不再改", c.From));
+ Say(Strings.LF("已改回 %@,这场不再改", Correction.Label(fix).From));
}
// MARK: 改这句…
diff --git a/windows/src/Cicada/FixViews.cs b/windows/src/Cicada/FixViews.cs
index 065a1b7..cddeab6 100644
--- a/windows/src/Cicada/FixViews.cs
+++ b/windows/src/Cicada/FixViews.cs
@@ -57,7 +57,7 @@ static class FixViews
var wrap = new WrapPanel { Margin = new Thickness(0, 4, 0, 0) };
foreach (var f in (l.Fixes ?? []).Where(f => f.Applied))
{
- var c = Correction.Core(f.From, f.To);
+ var c = Correction.Label(f);
var words = new TextBlock { FontFamily = Palette.Font, FontSize = 11, Foreground = Palette.Ink, VerticalAlignment = VerticalAlignment.Center };
words.Inlines.Add(new Run(L("听成")) { Foreground = Palette.Tertiary });
words.Inlines.Add(new Run(" " + c.From));
@@ -88,7 +88,7 @@ static class FixViews
/// off until after the meeting (稍后再看).
public static FrameworkElement ConfirmCard(TranscriptLine line, LineFix fix, int count, Action<bool> answer, Action? later)
{
- var c = Correction.Core(fix.From, fix.To);
+ var c = Correction.Label(fix);
var head = new DockPanel();
if (count > 1)
{
@@ -136,7 +136,7 @@ static class FixViews
if (waiting.Count == 0)
return fixedCount > 0 ? Ui.Text(LF("改了 %lld 处听错的词", fixedCount), 12, Palette.Tertiary) : null;
var (line, fix) = waiting[0];
- var c = Correction.Core(fix.From, fix.To);
+ var c = Correction.Label(fix);
var title = Ui.Text(LF("改了 %lld 处听错的词,%lld 处等你确认", fixedCount, waiting.Count), 13, Palette.Ink, FontWeights.SemiBold);
var what = new TextBlock { FontFamily = Palette.Font, FontSize = 12, Foreground = Palette.Secondary };
what.Inlines.Add(new Run($"{c.From} → {c.To}?"));
diff --git a/windows/tests/Cicada.Tests/Program.cs b/windows/tests/Cicada.Tests/Program.cs
index 6e04874..7f63a4d 100644
--- a/windows/tests/Cicada.Tests/Program.cs
+++ b/windows/tests/Cicada.Tests/Program.cs
@@ -2861,6 +2861,22 @@ static class Tests
Equal(true, Correction.UserEdit("我木娜找了", "我Monad找了", "我木娜找了", [])?.Swap, "swap");
}
+ public static void FixLabelNamesAnAddedWordWhole()
+ {
+ Equal(("in", "in now"), Correction.Label(new LineFix("in", "in now", user: true)), "added at the end");
+ Equal(("Great", "OK Great"), Correction.Label(new LineFix("Great", "OK Great", user: true)), "added at the start");
+ Equal(("质压", "质押"), Correction.Label(new LineFix("解除质压", "解除质押")), "a swap: the changed words");
+ }
+
+ public static void FixesRevertNamesAnAddedWordWhole()
+ {
+ var (fx, store, id) = FixSetup("Great, let's lock that in.");
+ fx.Edit("l0", id, "Great, let's lock that in now.", everywhere: false, remember: false);
+ fx.Revert(FixLine(store, id, "l0").Fixes![0], "l0", id);
+ Equal("Great, let's lock that in.", FixLine(store, id, "l0").Shown, "reverted");
+ Check(fx.Toast?.Text.Contains("已改回 in,") == true, "toast: " + fx.Toast?.Text);
+ }
+
public static void FixesAddedWordEditStaysOnItsLine()
{
var (fx, store, id) = FixSetup("Great, let's lock that in.", "Done.");