helm-swoop icon indicating copy to clipboard operation
helm-swoop copied to clipboard

Cache sometimes not cleared properly leading to wrong results [reproducable/fix]

Open olejorgenb opened this issue 7 years ago • 4 comments

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.

olejorgenb avatar Mar 18 '17 11:03 olejorgenb

@ShingoFukuyama -- is this fixable?

indigoviolet avatar Aug 10 '17 02:08 indigoviolet

I have the same issue.

krizex avatar Nov 08 '17 06:11 krizex

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)))

CeleritasCelery avatar Jun 08 '18 06:06 CeleritasCelery

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.

troglotit avatar Nov 13 '18 11:11 troglotit