fix(notes): keep no file on disk for an empty note - #3
Merged
Merged
Conversation
Opening a persistent note was enough to create its file: the save
path wrote the buffer unconditionally, so an untouched Local note
left a stray .scratch.md in the project (and a global.md plus its
directory in stdpath("data")). Clearing a note left the file behind
as an empty one.
Write the file only when the note has content, and delete an
existing file when the note holds nothing but blank lines.
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, well-scoped, and consistently enforces the intended “no empty note files on disk” behavior without introducing new API surface.
Pull request overview
This PR adjusts scratch.nvim’s persistence behavior so that persistent notes (local/global) don’t leave empty files on disk, aligning file creation/deletion with whether the note actually contains non-blank content.
Changes:
- Update persistence logic to skip writing when the buffer is blank and to delete any existing note file when the buffer becomes blank.
- Add a helper to detect “blank-only” notes (whitespace/empty lines).
- Document the new behavior in the README features list.
File summaries
| File | Description |
|---|---|
| README.md | Documents that empty notes do not create/retain files on disk. |
| lua/scratch/init.lua | Implements “write only when non-blank; delete file when blank-only” persistence behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Opening a persistent note was enough to create its file: the save path wrote the buffer unconditionally, so an untouched Local note left a stray .scratch.md in the project (and a global.md plus its directory in stdpath("data")). Clearing a note left the file behind as an empty one.
Write the file only when the note has content, and delete an existing file when the note holds nothing but blank lines.