From 899c55f230d96649bdd3a3f4a8a0302ecf2df994 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 19:28:05 -0500 Subject: feat(refresh): prompt instead of silently deferring a dirty refresh Running pearl-list-issues on a buffer with unsaved edits used to print a passive "refresh deferred" message and do nothing visible, so it read as a no-op. Now it prompts: (d)iscard and rebuild, (m)erge by LINEAR-ID keeping the edits, or (q) cancel. Branch C of pearl--update-org-from-issues dispatches on the choice: discard rebuilds in place, merge hands off to the same by-id merge that pearl-refresh-current-view uses, and cancel leaves the buffer untouched. --- tests/test-pearl-org-write.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/test-pearl-org-write.el') diff --git a/tests/test-pearl-org-write.el b/tests/test-pearl-org-write.el index 6c30380..e467436 100644 --- a/tests/test-pearl-org-write.el +++ b/tests/test-pearl-org-write.el @@ -69,19 +69,20 @@ (should-not (string-match-p "old content" (buffer-string))))))) (ert-deftest test-pearl-update-org-dirty-buffer-not-overwritten () - "A buffer with unsaved edits is left untouched, not clobbered." + "Cancelling the dirty-refresh prompt leaves a buffer with unsaved edits untouched." (test-pearl--with-org-file tmp (let ((buf (find-file-noselect tmp))) (with-current-buffer buf (insert "unsaved edits")) - (pearl--update-org-from-issues test-pearl--sample-issues) + (cl-letf (((symbol-function 'pearl--dirty-refresh-choice) (lambda (_p) ?q))) + (pearl--update-org-from-issues test-pearl--sample-issues)) (with-current-buffer buf (should (buffer-modified-p)) (should (string-match-p "unsaved edits" (buffer-string))) (should-not (string-match-p "ENG-1" (buffer-string))))))) (ert-deftest test-pearl-update-org-dirty-buffer-preserves-disk-and-surfaces () - "A dirty buffer is left as-is, the on-disk file is untouched, and the buffer is surfaced." + "Cancelling the prompt leaves the dirty buffer and on-disk file as-is, and surfaces it." (test-pearl--with-org-file tmp (let ((buf (find-file-noselect tmp)) (surfaced nil)) @@ -92,7 +93,8 @@ (goto-char (point-max)) (insert "UNSAVED EDIT\n")) (cl-letf (((symbol-function 'pearl--surface-buffer) - (lambda (b) (setq surfaced b)))) + (lambda (b) (setq surfaced b))) + ((symbol-function 'pearl--dirty-refresh-choice) (lambda (_p) ?q))) (pearl--update-org-from-issues test-pearl--sample-issues)) ;; buffer keeps the unsaved edit and stays modified (with-current-buffer buf -- cgit v1.2.3