PSFzf icon indicating copy to clipboard operation
PSFzf copied to clipboard

Show completions' `ToolTip` as `--preview`

Open cspotcode opened this issue 5 months ago • 3 comments

Would be nice to see CompletionMatches' .ToolTips in the fzf --preview-window.

Here's how I think this could work:

  • get array of completions
  • Generate JSON object: keys == CompletionText, values == ToolTip
  • Write JSON to a temp file
  • pass a command to fzf --preview that can lookup a value from a key in the JSON
    • If using jq, could be: fzf --preview 'jq --raw-output --arg key "{1}" ".[$key]" /path/to/tempfile.json'
    • relying on an external binary is not ideal
    • fzf might get support for reading directly from JSON, no need for external jq binary

cspotcode avatar Nov 20 '25 00:11 cspotcode

Asked fzf about feasibility of adding a --preview mechanism that reads all previews as structured data, either via stdin or from a temp file: https://github.com/junegunn/fzf/issues/4601

cspotcode avatar Nov 20 '25 00:11 cspotcode

I have thought about doing something like this in the past, but I couldn't think of an elegant way to save the tooltip state and reference it in the preview window.

kelleyma49 avatar Nov 22 '25 23:11 kelleyma49

How do you feel about my JSON temp file idea? Or a temp file format that's more friendly to being parsed by a simple sh-compatible shell?

cspotcode avatar Nov 23 '25 00:11 cspotcode