I want to show some additional info while user navigate through the auto-complete suggestions. There is something about select event in the documentaion, but I am not able to find how to subscribe to it if it is possible.
Can someone please suggest how to subscribe to that event? or any other method to detect which one is currently selected and detect when this changes?
There are several questions about this, but I could not find any solution.
These events are not fired on internal completion object which is generally not available outside the hint provider, hence cannot be directly subscribed to.
Anyway, if you really want to subscribe to these events, you have to overwrite the hint provider. For example,
// Some other code defined CodeMirror.hint.foo
var fooHint = CodeMirror.hint.foo;
CodeMirror.hint.foo = function(cm, options) {
var result = fooHint(cm, options);
if (result) CodeMirror.on(result, "pick", function() { /* ... */ });
return result;
};
See https://github.com/codemirror/CodeMirror/issues/3092. Thanks to marijnh for the solution.