From ecfc66294e57788df715c98297ef425fd9dbd9ef Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 5 Jun 2026 06:01:13 -0500 Subject: feat(render): save the buffer to disk after a fetch or refresh The full-replace render saved the Org file, but the in-place paths didn't, so a refresh or a comment fetch left the buffer modified-but-unsaved and the file on disk stale. Five paths now save through pearl--save-if-visiting: refresh-current-view, refresh-current-issue, fetch-all-comments, create-comment, and the merge branch of a dirty source-switch. The helper saves only when the buffer visits a file, so it's a no-op in a test buffer. Saving the Org file never pushes to Linear, so an unpushed edit still waits for pearl-save-issue. This only keeps the disk copy in step with what's on screen. fetch-all-comments surfaced the gap first. An audit turned up the other four. --- tests/test-pearl-fetch-all-comments.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/test-pearl-fetch-all-comments.el b/tests/test-pearl-fetch-all-comments.el index 04dfe31..4449314 100644 --- a/tests/test-pearl-fetch-all-comments.el +++ b/tests/test-pearl-fetch-all-comments.el @@ -124,5 +124,30 @@ (test-pearl-fac--goto-issue) (should-not (pearl--unpushed-comment-edits-p)))) +;;; save-after-fetch helper + +(ert-deftest test-pearl-save-if-visiting-noop-without-file () + "In a non-file buffer the save helper is a no-op, not an error." + (with-temp-buffer + (insert "x") + (should-not (pearl--save-if-visiting)))) + +(ert-deftest test-pearl-save-if-visiting-saves-file-buffer () + "In a file-visiting buffer the helper writes the buffer to disk." + (let ((f (make-temp-file "pearl-save-" nil ".org"))) + (unwind-protect + (let ((buf (find-file-noselect f))) + (unwind-protect + (with-current-buffer buf + (insert "hello pearl") + (should (buffer-modified-p)) + (pearl--save-if-visiting) + (should-not (buffer-modified-p)) + (should (string-match-p + "hello pearl" + (with-temp-buffer (insert-file-contents f) (buffer-string))))) + (kill-buffer buf))) + (delete-file f)))) + (provide 'test-pearl-fetch-all-comments) ;;; test-pearl-fetch-all-comments.el ends here -- cgit v1.2.3