Fix closing completion hint#3089
Fix closing completion hint#3089mloginov wants to merge 2 commits intocodemirror:masterfrom mloginov:tern_close_completion_hint
Conversation
|
I can not reproduce this issue. Does it happen in http://codemirror.net/demo/complete.html ? |
|
No. It happens if completions update on each key press. |
|
Also fixed lagging if hints changes very often. Looks like this bugs appears on complex layouts. |
|
You still didn't show me your code, but I assume you are starting new completions when the old one is still open. Don't do that. See this demo code for an example of how to do it properly. |
|
No. I open only one completions like in your example. But I found where problem can be. on cursor activity -> update -> throw update signal -> getHints(async) -> finishUptate and throw select signal on new widget creation. But if getHints gets a lot of time(for example if 100 docs was added to tern) you can get 2 update events in tern addon and then 2 select events for different positions. Now, because tooltip stored in local scope it wouldn't be removed. I added it to ts.completionHint just to be sure that tooltip would be removed in any case. |
|
Okay, you are using an asynchronous hinter. That might have been good to include in the report. You are right that there is a race condition when using asynchronous hinting. I'll take a look. |
|
Well, I still can't reproduce this. Please create a minimal test case that shows the issue. Here's my code: <!doctype html>
<meta charset="utf-8">
<script src="lib/codemirror.js"></script>
<link rel=stylesheet href="lib/codemirror.css">
<link rel=stylesheet href="addon/hint/show-hint.css">
<script src="mode/javascript/javascript.js"></script>
<script src="addon/hint/show-hint.js"></script>
<script src="addon/hint/javascript-hint.js"></script>
<body>
<script>
CodeMirror.registerHelper("hint", "foo", function(cm, f, options) {
setTimeout(function() {
f(CodeMirror.hint.javascript(cm, options));
}, 400);
});
CodeMirror.hint.foo.async = true;
var cm = CodeMirror(document.body, {mode: "javascript", lineNumbers: true});
cm.on("inputRead", function() {
if (!cm.state.completionActive)
cm.showHint({globalScope: {abcd: {}, abef: {}, abcdef: {}}, hint: CodeMirror.hint.foo});
});
</script>
</body> |
|
You should use tern addon to reproduce it. Problem in tern tooltip that appears in 'hint' method. Just use example from http://codemirror.net/demo/tern.html
this.getHint = function(cm, c) {
setTimeout(function () {
return hint(self, cm, c);
}, 400);
};
Then to reproduce.
Test case http://jsfiddle.net/09aao7f9/8/ |
|
Thanks, that allowed me to reproduce it. The underlying problem is that |
Sometimes hints don't disappear
It happens in FF often.
This PR fixes this problem.