[doc]: How to manually retrigger f-s-h from within a user's ZLE widget function?
AndydeCleyre opened this issue · comments
Documentation Link
No response
Problem
If there is a simple way to achieve this, it would be great to include that in the README.
The use case I have here is a custom zle widget that puts a filepath on the line being edited.
Afterward, I need to move the cursor before f-s-h will rescan the line (and colorize an existing filepath).
I thought maybe I could check for a certain f-s-h zle function and run it at the end of my zle function.
Suggested improvement
To manually trigger a rescan of the current line from your own ZLE widgets, use
if (( $+functions[fast-highlight-rescan] )) fast-highlight-rescan
I thought this might work, but it doesn't:
for 1 ( preexec $preexec_functions ) {
if (( $+functions[$1] )) $1 &>/dev/null
}
zle -R
Oh looks like maybe f-s-h rewrites all defined ZLE widgets when loaded, so I'll need to rearrange things to define my widget before that.
EDIT: still no luck
Ah, this seems to do the trick, dropped at the end of any custom ZLE widgets:
if (( $+functions[_zsh_highlight] )) _zsh_highlight