jcs-legacy / helm-file-preview

Preview the current helm file selection.
GNU General Public License v3.0
11 stars 5 forks source link

Preview not working with helm-do-ag or helm-ag #7

Open rdiaz02 opened 1 year ago

rdiaz02 commented 1 year ago

Hi, I do not know if I am doing something wrong, but preview is not working with helm-ag and helm-do-ag. Minimal example:

  1. Start emacs as emacs -Q

  2. Evaluate this code

    (require 'package)
    (package-initialize)
    (require 'helm)
    (require 'helm-ag)
    (require 'helm-file-preview)
    (helm-file-preview-mode 1)
  3. Use helm-ag or helm-do-ag.

The preview is not shown.

jcs090218 commented 1 year ago

Sorry, I don't use helm anymore. But to answer your question, this package parse helm's candidate to get the file path. The suspect the candidate isn't viable for this package to parse.

rdiaz02 commented 1 year ago

Thanks for your reply anyway. (Candidates were text files, org files, etc).

MattMicheletti commented 7 months ago

I figured I would tackle this since I would occasionally experience this issue but not always. I did a little digging with this issue. As @jcs090218 notes, it was essentially a parsing issue. The default format returned by helm-do-grep-ag, for example, is just the filename. That only works if any given match's file is in the same directory as the root directory used by Helm File Preview's helm-file-preview--helm-move-selection-after-hook function (i.e. whatever the project root is based on your current project management package).

TL;DR To fix this, simply set helm-grep-file-path-style to any of the alternative options such as 'relative or 'absolute.

The file name provided by Helm AG will then have important file path components that Helm File Preview can use as it parses them out.

Hope this helps anyone else running into this issue.