Skip to content

fix(notes): keep no file on disk for an empty note - #3

Merged
reybits merged 1 commit into
masterfrom
bugfix/empty-note-file
Sep 5, 2026
Merged

reybits merged 1 commit into
masterfrom
bugfix/empty-note-file

Conversation

@reybits

@reybits reybits commented Sep 5, 2026

Copy link
Copy Markdown
Owner

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.

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.
Copilot AI lite review requested due to automatic review settings September 5, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@reybits
reybits merged commit f38f494 into master Sep 5, 2026
1 check passed
@reybits
reybits deleted the bugfix/empty-note-file branch September 5, 2026 16:52
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