helm-swoop
helm-swoop copied to clipboard
Cache sometimes not cleared properly leading to wrong results [reproducable/fix]
Reproduce:
- Make new file
- Insert "foo" and save
- Delete the line
- M-x helm-swoop (write in something and cancel)
- Undo
- M-x helm-swoop (after "foo")
No results is displayed. This is due the line cache not being cleared when undoing into a state where the buffer isn't modified.
The relevant lines:
(cond ((not (boundp 'helm-swoop-list-cache))
(set (make-local-variable 'helm-swoop-list-cache) nil))
((buffer-modified-p)
(setq helm-swoop-list-cache nil)))
Here: https://github.com/ShingoFukuyama/helm-swoop/blob/master/helm-swoop.el#L630
Might be what #106 is experiencing.
@ShingoFukuyama -- is this fixable?
I have the same issue.
This can be fixed by adding an advice around your undo function. I was trying to find a universal solution to this but I can't seem to find an undo primitive to use (for example undo-tree implements it's own functions).
(advice-add 'undo :after (lambda (&rest _) (helm-swoop--clear-cache)))
I catch this quite frequently, most of the times when files changes on disk, for example when I checkout - Emacs changes the buffer, but cache persists.