diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-26 12:52:48 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-26 12:52:48 -0400 |
| commit | 06143c61c3782b24c738587ae5e1f427ceb0518c (patch) | |
| tree | 1e8ec8c6c77bdc331bce36b311c5daffdf3da8db /tests | |
| parent | 9459a0b30f86adb9066312672c7bd96e70bc1f6f (diff) | |
| download | emacs-wttrin-06143c61c3782b24c738587ae5e1f427ceb0518c.tar.gz emacs-wttrin-06143c61c3782b24c738587ae5e1f427ceb0518c.zip | |
fix: keep saved locations and search history disjoint
Pressing d cleaned the location from history, but saving with s did not. A place saved under a friendly name kept its raw query as a separate history candidate, and removing the saved entry let that query resurface in the picker.
wttrin-save-location now drops the saved name and its query from history, and wttrin-remove-location drops both the removed name and its query (captured before removal). A new wttrin--drop-from-location-history helper does the work. A place now lives in the directory or in history, never both.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-wttrin-saved-locations.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test-wttrin-saved-locations.el b/tests/test-wttrin-saved-locations.el index c2f44b8..267e5cc 100644 --- a/tests/test-wttrin-saved-locations.el +++ b/tests/test-wttrin-saved-locations.el @@ -373,5 +373,29 @@ so it persists as a named entry rather than only as the favorite string." (should (null wttrin--location-history))) (testutil-wttrin-teardown))) +;;; history stays in sync with the directory + +(ert-deftest test-wttrin-saved-locations-normal-save-drops-query-from-history () + "Normal: saving a location drops its query from history, so the place lives in +the directory only and does not also appear as a separate history candidate." + (let ((wttrin-saved-locations nil) + (wttrin--location-history '("New Orleans" "Paris"))) + (cl-letf (((symbol-function 'message) (lambda (&rest _) nil))) + (wttrin-save-location "Home" "New Orleans")) + (should-not (member "New Orleans" wttrin--location-history)) + (should (member "Paris" wttrin--location-history)))) + +(ert-deftest test-wttrin-saved-locations-normal-remove-forgets-history () + "Normal: removing a saved location drops both its name and its query from +history, so a removed place does not resurface as a history candidate." + (let ((wttrin-saved-locations '(("Home" . "New Orleans"))) + (wttrin--location-history '("Home" "New Orleans" "Paris"))) + (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) + ((symbol-function 'message) (lambda (&rest _) nil))) + (wttrin-remove-location "Home")) + (should-not (member "Home" wttrin--location-history)) + (should-not (member "New Orleans" wttrin--location-history)) + (should (member "Paris" wttrin--location-history)))) + (provide 'test-wttrin-saved-locations) ;;; test-wttrin-saved-locations.el ends here |
