Prevent widget override or other solution for integration with other plugins #160

Closed
psprint opened this Issue May 24, 2016 · 2 comments

2 participants

@psprint

Hello,
I've written a small plugin: https://github.com/psprint/history-search-multi-word. It's quite compact and should be harmless. Defines own keymap, binds cursor keys there, calls recursive-edit, that's pretty much all.

When autosuggestions plugin is loaded, it is doing the following during its operation (tracked by wrapping "zle" function):
zle -N history-search-multi-word _zsh_autosuggest_bound_history-search-multi-word
zle -N history-search-multi-word-backwards _zsh_autosuggest_bound_history-search-multi-word-backwards

This creates conflict. Using cursor keys clears my widget's output. Could this be because autosuggestions uses $POSTDISPLAY like my widget? I wonder what could be the solution, is such problem maybe recognized?

@psprint

I've managed to solve this. Thanks to the fact that I use zle recursive-edit (also switched to .recursive-edit), I stay inside my widget. It is then again called from say itself. So I was able to override myself with a "clean copy" of myself, free of autosuggestions interference:

+(( __hsmw_hcw_call_count ++ ))
+_zhcw_main
+
+_zhcw_simulate_widget() {
+    (( __hsmw_hcw_call_count ++ ))
+    _zhcw_main
+}
+

This override holds only after first call to my widget, when leaving I restore original autosuggestions-modified widget. And everything plays nice. The issue can be maybe closed. Contributed because widget creators might feel overwhelmed by what happens after each key press when using autosuggestions.

@ericfreese
zsh-users member

Thanks for following up. Glad you were able to get it working!

@ericfreese ericfreese closed this May 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment