Undoing a tag rename leaves an unused destination parent

Aperta
#23,221 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
android, kotlin
Ambito
database, testing

Direzione di ricerca

Start with ManageTagsViewModel.renameTag and the expansion restoration path; the issue says parent creation occurs outside undo history and points to a backend transaction change. Read the new ManageTagsRenameUndoRegressionTest.kt and run that regression test to reproduce the problem. Done means undo restores the original note tags and removes the unused destination parent from the tag cache.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

upstream-issue

Assisted-by: GPT-6.1-Sol xhigh & GPT-6-Astra xhigh

Undoing a tag rename leaves an unused destination parent
Subject: Undoing a tag rename leaves an unused destination parent

Undoing an expanded branch rename restores note tags but leaves the destination parent in the tag list, blocking later renames to that name.

Fix unresolved: no compatible temporary fix verified.
Expansion restoration creates the parent outside undo history; preserving its creation and expansion together requires a backend transaction change.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/tags/ManageTagsRenameUndoRegressionTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/tags/ManageTagsRenameUndoRegressionTest.kt
new file mode 100644
index 0000000000..d587b1d8ee
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/tags/ManageTagsRenameUndoRegressionTest.kt
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.tags
+
+import com.ichi2.testutils.JvmTest
+import com.ichi2.testutils.rules.IcuCaseFoldingRule
+import com.ichi2.testutils.withViewModel
+import org.junit.Rule
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class ManageTagsRenameUndoRegressionTest : JvmTest() {
+    @get:Rule
+    val caseFolding = IcuCaseFoldingRule()
+
+    @Test
+    fun `undoing an expanded branch rename removes the destination from the tag cache`() =
+        runTest {
+            val source = requireNotNull(TagName.build("source"))
+            val destination = requireNotNull(TagName.build("destination"))
+            val note = addBasicNote().update { addTag("source::child") }
+            withViewModel(ManageTagsViewModel()) {
+                toggleCollapsed(source).join()
+                val originalTags = col.tags.all().sorted()
+                renameTag(source, destination).join()
+                assertEquals(listOf("destination::child"), col.getNote(note.id).tags)
+
+                col.undo()
+
+                assertEquals(listOf("source::child"), col.getNote(note.id).tags)
+                assertEquals(originalTags, col.tags.all().sorted(), "Undo must also remove the unused destination parent")
+            }
+        }
+}

Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/22849#pullrequestreview-5875867983

Lingua principale
Kotlin
Stelle
12.3k
Fork
3.1k
Merge medio
1g 11h
PR unite (30g)
383

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ankidroid/Anki-Android

Tutte le issue di ankidroid/Anki-Android

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.