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(linux): the toast after Edit line… shows the span an added word changed (in → in now), not a fragment

wquguru4f3f75a862f1
diff --git a/linux/cicada/core/live_fixes.py b/linux/cicada/core/live_fixes.py
index a30dc4b..a46d644 100644
--- a/linux/cicada/core/live_fixes.py
+++ b/linux/cicada/core/live_fixes.py
@@ -266,8 +266,11 @@ class LiveFixes:
if learned:
self.vocabulary.confirm(heard, word, source="user")
Log.d("fix edited lines=%d learned=%s" % (len(targets), learned))
- self._say(LF("已改 %lld 处:%@ → %@,记进词表", len(targets), heard, word) if learned
- else LF("已改 %lld 处:%@ → %@", len(targets), heard, word))
+ # A swap reads as the words swapped; an added or dropped word as the span it changed
+ # ("in → in now", not "in → now").
+ a, b = (heard, word) if swap else (fix.from_, fix.to)
+ self._say(LF("已改 %lld 处:%@ → %@,记进词表", len(targets), a, b) if learned
+ else LF("已改 %lld 处:%@ → %@", len(targets), a, b))
return len(targets)
# 撤销
diff --git a/linux/tests/test_fixes.py b/linux/tests/test_fixes.py
index 40abde6..26fb71f 100644
--- a/linux/tests/test_fixes.py
+++ b/linux/tests/test_fixes.py
@@ -352,6 +352,7 @@ class Live(Base):
self.assertEqual(store.line(sid, "l1").shown, "We are in.")
self.assertEqual(store.line(sid, "l2").shown, "Fine.")
self.assertEqual(fx.vocabulary.terms, [])
+ self.assertEqual(fx.toast_text(), "已改 1 处:in → in now")
def test_one_off_edit_does_not_teach_the_list(self):
fx, store, sid = self.setup(["我木娜找了一个", "木娜那边也有"])