title: widgets can only be called when ZLE is active
body: <p>I have been dealing with this problem for almost a month now, and I feel frustrated, Any help would be greatly appreciated.</p>
  
  <p>I am trying to write a widget for my <code>takenote</code> command. The purpose of the widget is to feed all the markdown files in <code>~/notes</code> folder into <code>fzf</code> so that the user can select one of them and starts editing it.
  After the user types <code>takenote</code> and presses <code>&lt;tab&gt;</code> I expect the widget to run.</p>
  
  <p>Here is the <code>_takenote.zsh</code> widget definition:</p>
  
  
  
  <pre class="lang-zsh prettyprint-override"><code>#compdef takenote
  local file=$( find -L "$HOME/notes/" -print 2&gt; /dev/null | fzf-tmux +m )
  zle reset-prompt
  compadd $file
  return 1
  </code></pre>
  
  <p>Unfortunately, the above code doesn't work because of <code>zle reset-prompt</code>, if I remove it then the result would be like this:</p>
  
  <p><a href="https://i.stack.imgur.com/316Sy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/316Sy.png" alt="before selection"></a></p>
  
  <p>And after selecting the file it would turn into:</p>
  
  <p><a href="https://i.stack.imgur.com/lKVA6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lKVA6.png" alt="After selecting the file"></a></p>
  
  <p>Which as you see will corrupt the prompt and the command itself.
  It appears to me that what I need to do is do a <code>zle reset-prompt</code>
  before calling <code>compadd</code> but this can only work when I bind the function to a key otherwise, I will get the following error:</p>
  
  <p>widgets can only be called when ZLE is active</p>