I have two different use case for the hints I want to show to user. When they use the CTRL-Space shortcut, they should get the result from the hint function that I registered when I create my code mirror instance. When the editor gets focus, I want to give them (in some case) a smaller list.
The function that I registered works well, but the one on focus does not. It shows, but the selection is ignored. Furthermore, when a selection is made in the primary hints (the one showing with CTRL-Space), the editor gets focus again and the second hint pop up shows.
Here is the code for the on focus one:
codeMirror.on("focus", function() {
if (!codeMirror.isReadOnly() && codeMirror.getValue() === "") {
var options = {
hint: function() {
return {
from: codeMirror.getDoc().getCursor(),
to: codeMirror.getDoc().getCursor(),
list: ['foo','bar']
};
}
};
codeMirror.showHint(options);
}
});
How should I handle this use case properly?