Skip to content

fix(library): renaming a snippet to a rejected name no longer deletes it (for #1) - #3

Merged
lukisch merged 1 commit into
claude/determined-mayer-marfcufrom
claude/determined-mayer-i1vsa8
Nov 11, 2026
Merged

lukisch merged 1 commit into
claude/determined-mayer-marfcufrom
claude/determined-mayer-i1vsa8

Conversation

@lukisch

@lukisch lukisch commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #1, found in the second review. This PR targets the branch of #1 so that #1 picks up the fix.

Problem

edit_library_item deletes the old entry first, then calls save_snippet and ignores the result. #1 makes save_snippet reject names containing : or ending in .. Renaming a snippet to Regex: Gruppen or Kap. 1. therefore deletes it without any message. On master those renames succeed (the same loss already existed there for names containing /).

Change

  • New LibraryManager.rename_snippet: saves under the new name first and removes the old entry only if that succeeded. If old and new name resolve to the same file (case-only rename on a case-insensitive file system), the delete is skipped.
  • edit_library_item uses it and shows a warning when saving fails, also for a plain edit without rename.
  • CHANGELOG entry.

Verification

  • pytest -q (Linux, Python 3.11, PySide6 offscreen): 131 passed (126 before, 5 new).
  • New tests cover: rejected names keep the old snippet, valid rename moves it, locked target keeps both, same-file rename keeps the file, and the dialog calls rename_snippet and reports failures.
  • ruff check: 368 findings versus 369 on the base, none new. The repository does not lint clean today.

Not covered

  • Not run on Windows locally; the case-only rename path is tested with a mocked os.path.samefile.
  • The dialog path is checked by source inspection, not by driving the Qt dialog.
  • The other notes from the review of fix(library,editor): block snippet path traversal, preserve line endings on save #1 (names ending in a dot rejected for snippets too, control characters accepted, changelog wording on mixed line endings) are unchanged.

Generated by Claude Code

edit_library_item deleted the old entry first and ignored the result of
save_snippet. With the stricter name check, renaming to a rejected name
(e.g. 'Regex: Gruppen', 'Kap. 1.') silently lost the snippet.

LibraryManager.rename_snippet now saves first and removes the old entry
only on success, skips the delete when both names resolve to the same
file, and the dialog reports a failed save.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01THB2F13CQQqFzZB38FkYF7
@github-actions

Copy link
Copy Markdown

Welcome! 👋 Thanks for your first pull request in this repository.

A maintainer will review it soon. Please make sure:

  • Your changes are tested
  • Documentation is updated if needed
  • The PR description explains what and why

Thanks for contributing!

@lukisch
lukisch merged commit 0b1c208 into claude/determined-mayer-marfcu Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants