Does anyone know how to detect when an auto completion entry is clicked on?
One can tell when an auto completion is accepted via the keyboard by using an on_post_text_command
to listen for commit_completion
and/or insert_best_completion
commands, but there seems to be no event when an auto complete entry is clicked on using the mouse.
I have the following scenario:
- auto completion is shown via the
auto_complete
command (whether invoked by a keypress/trigger or via plugin code) - the user selects an entry (either by pressing Tab on their keyboard etc. or clicking their desired entry with the mouse)
- if the auto completion that was selected ends in a character that is an auto completion trigger according to the view settings and the scope (i.e. check the character immediately before the new cursor position)
- execute the
auto_complete
command again to show the new completions list - and the process repeats
As no specific event is raised when the user clicks on an auto complete entry, I had the idea of:
- using
on_post_text_command
, detect whencommand_name
==auto_complete
to know when the auto complete popup is shown - using
on_post_text_command
, detect whencommand_name
==hide_auto_complete
to know when the auto complete was cancelled - use
on_modified
oron_selection_modified
to detect when an auto complete entry was accepted (i.e. if the previous command wasauto_complete
, and it is the firston_modified
oron_selection_modified
event fired since then)
but it doesn’t seem to work… Does anyone have any other ideas of how I could accomplish this?