fix(categories): keep notes when deleting a category#1927
Open
MiMoHo wants to merge 1 commit into
Open
Conversation
Deleting a category previously deleted the category folder including all note files in it. Move all notes of the category and its subcategories to the uncategorized root folder instead, reusing the per-note category move which resolves file name collisions. Only folders that contain no files at all are removed afterwards, so non-note files are never deleted. The confirmation dialog and the client-side store update reflect the new behavior: notes are kept and reassigned to Uncategorized. Assisted-by: Claude Code:claude-fable-5 AI-assistant: Claude Code 2.1.187 (Claude Fable 5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deleting a category currently deletes the category folder including all note files inside it — a single confirmation click can destroy many notes. This change makes "Delete category" keep the notes: they are moved to Uncategorized instead, and only the empty folder goes away.
How it works
Note::setCategory('')), so file name collisions are resolved the same way as when changing a single note's category (Title (2).md).deleteFoldersWithoutFiles). Non-note files that happen to live in the category folder are never deleted.Note on the behavior change
This intentionally changes the semantics of an existing action, based on the expectation that "deleting a folder" should not silently destroy its notes. If you would rather keep the destructive delete and offer a choice (e.g. "delete notes" vs. "keep notes"), I am happy to rework this accordingly.
Testing
Name (2).md, non-note files untouched.php -lclean, production webpack build clean.🤖 AI (if applicable)
I reviewed and tested the changes myself.