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

Provide an option to disable completion in comments #6

Closed
ville-h opened this issue Oct 7, 2015 · 10 comments
Closed

Provide an option to disable completion in comments #6

ville-h opened this issue Oct 7, 2015 · 10 comments
Labels

Comments

@ville-h
Copy link

ville-h commented Oct 7, 2015

Emacs stalls while writing in some comments such as the comment: "// writing in this comment is broken" below. Try extending the comment with writing words longer than company-minimum-prefix-length and company-idle-delay "low-enough". Simply start tapping the "a" key repeatedly for example and the letters should appear in chunks. Not sure if this is emacs-racer or racer problem and what repo the issue should have been filed to.

// company-idle-delay 0.1 is low-enough on my system
fn main() {
    // writing in this comment is fine
}


struct A {
}


impl A {
    fn f() {
        // writing in this comment is broken
        let x = 0;
    }


    fn g() {
        // writing in this comment is fine
    }
}
@ane
Copy link
Member

ane commented Oct 7, 2015

It seems racer will be called if we're inside a comment. That shouldn't be hard to fix.

@ville-h
Copy link
Author

ville-h commented Oct 7, 2015

If the only solution to fix the stalling is to turn off completions in comments then make it an on-off setting for those who haven't run into this? Some may find completions inside comments useful. I found it rather curious that the slowdown isn't constant in all comments. If you remove the "let x = 0" from above then the "// writing in this comment is broken" no longer stalls emacs.

@ane
Copy link
Member

ane commented Oct 8, 2015

Good point. It might be a racer issue that it stalls. Completion is currently disabled only inside strings.

@Wilfred
Copy link
Member

Wilfred commented Oct 9, 2015

Setting company-idle-delay to 0.1 is very aggressive. This assumes that all your company back ends together (plus GC, especially if backends are returning many candidates) take less than 0.1 seconds.

We could certainly look at improving performance, but we may not be able to reach 0.1 seconds in all cases.

We could disable completion in comments, but it is a useful feature so it'd have to be an option.

Can you confirm the issue still occurs when racer is the only back end in company-backends? I'm aware of other backends that behave similarly with an aggressive idle delay.

@ville-h
Copy link
Author

ville-h commented Oct 9, 2015

What exactly do you want company-backends to be set to?

@ane
Copy link
Member

ane commented Oct 9, 2015

I investigated it a bit further. I made sure completion-at-point-functions was only racer-complete-at-point and company-backends was company-capf.

Then, I used the following macro:

(defmacro with-timer (title &rest forms)
  "Run the given FORMS, counting the elapsed time.
A message including the given TITLE and the corresponding elapsed
time is displayed."
  (declare (indent 1))
  (let ((nowvar (make-symbol "now"))
        (body   `(progn ,@forms)))
    `(let ((,nowvar (current-time)))
       (message "%s..." ,title)
       (prog1 ,body
         (let ((elapsed
                (float-time (time-subtract (current-time) ,nowvar))))
           (message "%s... done (%.3fs)" ,title elapsed))))))

and wrapped it around the call to ->> in racer-complete. Using ville-h's snippet above, I placed the cursor at the start of the comment // | and hit company-complete. The timer reports in that location about ~0.3 seconds for execution. At the second location, it produces a result in 0.01 seconds! So clearly there's a performance issue here, and I suspect it's something in racer, not Emacs.

@Wilfred
Copy link
Member

Wilfred commented Oct 10, 2015

Thanks @ane! If the issue is in Racer, there's not much we can do here. @ville-h would you like to file a bug on Racer itself?

@ville-h
Copy link
Author

ville-h commented Oct 11, 2015

Ok opened issue under racer[0]. A slight annoyance with regards to what values of company-idle-delay are considered "too low". The idle time shouldn't be reset if the key used to invoke racer-complete-at-point is hit too early. Even 0.1s delay is long enough that i often manage to hit tab to try to complete the common part before the 0.1s has passed, thus cancelling the completion and I am left wondering why it doesn't show up. In other words bad usability.

[0] racer-rust/racer#413

@ane ane added the bug label Aug 3, 2016
@Wilfred Wilfred changed the title Emacs stalls while writing in some comments Provide an option to disable completion in comments Aug 27, 2016
Wilfred added a commit that referenced this issue Oct 18, 2016
It's rarely useful. I haven't managed to get completion out of Racer
inside a comment.

However, completing inside comments can really hurt performance. See #6.
Wilfred added a commit that referenced this issue Nov 4, 2016
It's rarely useful. I haven't managed to get completion out of Racer
inside a comment.

However, completing inside comments can really hurt performance. See #6.
@Wilfred
Copy link
Member

Wilfred commented Nov 4, 2016

Fixed in #60.

@Wilfred Wilfred closed this as completed Nov 4, 2016
@ane
Copy link
Member

ane commented Nov 4, 2016

Finally! 👍

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

No branches or pull requests

3 participants