Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show-hint.js generates completion on each key typed #1852

Closed
as3boyan opened this issue Sep 30, 2013 · 6 comments
Closed

Show-hint.js generates completion on each key typed #1852

as3boyan opened this issue Sep 30, 2013 · 6 comments

Comments

@as3boyan
Copy link
Contributor

I tried to make demo, based on this:
http://ternjs.net/doc/demo.html

But with latest CodeMirror(3.18) show-hint.js generates completion too often, it does it on each key typed(it hides completion dialog and shows on each key typed, which causes blinkage). Seems like you have old CodeMirror on Tern website. Which works fine.

Diffs:

old show-hint.js

   changeActive: function(i) {
  i = Math.max(0, Math.min(i, this.data.list.length - 1));
  if (this.selectedHint == i) return;
  var node = this.hints.childNodes[this.selectedHint];
  node.className = node.className.replace(" CodeMirror-hint-active", "");
  node = this.hints.childNodes[this.selectedHint = i];
  node.className += " CodeMirror-hint-active";
  if (node.offsetTop < this.hints.scrollTop)
    this.hints.scrollTop = node.offsetTop - 3;
  else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
    this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
  CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
},

new show-hint.js(CodeMirror 3.18):

    changeActive: function(i, avoidWrap) {
  if (i >= this.data.list.length)
    i = avoidWrap ? this.data.list.length - 1 : 0;
  else if (i < 0)
    i = avoidWrap ? 0  : this.data.list.length - 1;
  if (this.selectedHint == i) return;
  var node = this.hints.childNodes[this.selectedHint];
  node.className = node.className.replace(" CodeMirror-hint-active", "");
  node = this.hints.childNodes[this.selectedHint = i];
  node.className += " CodeMirror-hint-active";
  if (node.offsetTop < this.hints.scrollTop)
    this.hints.scrollTop = node.offsetTop - 3;
  else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
    this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
  CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
},

Old version works fine.

@marijnh
Copy link
Member

marijnh commented Oct 1, 2013

What do you mean by "generates completion too often"? The fact that the completion popup is now hidden during typing, and only re-shown when the user stops typing for a moment, is intentional.

@as3boyan
Copy link
Contributor Author

as3boyan commented Oct 1, 2013

I mean that when popup is shown, completion generated once, and each time it shows it call generation again. Maybe there is a way to change that delay? Because when I type it blinks all time.

@marijnh
Copy link
Member

marijnh commented Oct 7, 2013

I don't really see the problem. It has to refresh as you type. Why is it bad that it blinks?

@as3boyan
Copy link
Contributor Author

as3boyan commented Oct 7, 2013

I don't like it, and I need to get completion list from Haxe completion(Just list of completion in XML format) only once. Even if I use some completion like anyword-completion - it will generate completion list every time I type something - that is the waste of CPU resources - I could use it in another way. But maybe for such things CPU impact is very small, I haven't tested performance.

About blinking - I just don't like it, you know any blinks kinda distracts me, I want to see it smooth. Most IDEs show it without blinking.

I don't know why, but this thing annoys me pretty well. Anyway - I included show-hint.js from old version of CodeMirror to index.html page, instead of using latest show-hint.js.
https://github.com/misterpah/hide/tree/master/bin/includes/js/codemirror/addon/hint

@as3boyan
Copy link
Contributor Author

as3boyan commented Mar 8, 2014

@marijnh I tried latest CodeMirror on it's website, it seems like completion is not blinking anymore, right? It's great!

It's great so I can finally use latest show-hint.

@marijnh
Copy link
Member

marijnh commented Mar 9, 2014

I think you have @NV to thank for that (see 462ca4c).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants