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

Improve completion cache. #521

Closed
wants to merge 2 commits into from
Closed

Improve completion cache. #521

wants to merge 2 commits into from

Conversation

iensen
Copy link

@iensen iensen commented Nov 8, 2019

Unfortunately, this change 1a41d2d made auto-completion for my large projects completely unusable.

My scenario is as follows.

Suppose I have a class variable c, and I want to type c->some_method.
When I type c->, I wait 0.5-1 second until some_method appears. (my idle-delay is set to 0, but it doesn't really matter).

Then, when I type o (the next character), emacs freezes and for 0.5 -1 seconds before it generates new completions request. This happens because it no longer uses the cache and the completions are recomputed again.
This is super inconvenient! Previously, we used to reuse the cache for position c-> and filter it out when the new characters are added.

As far as I understand, my change should fix the bug which the original commit was supposed to fix, and will satisfy the important use case I desribed above (I verified the latter). But I may be misunderstanding the code, let me know.

@iensen iensen force-pushed the master branch 2 times, most recently from f4d03ae to f4e1843 Compare November 8, 2019 06:47
Copy link
Owner

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for narrowing down the issue. I didn't even perceive any difference!

I think we can just do:

-    return this->path == path && this->position == position;
+    return this->position == position && this->path == path &&
+           this->line.compare(0, position.character, line, 0,
+                              position.character) == 0;

Just amended that broken commit.

@@ -176,7 +176,7 @@ template <typename T> struct CompleteConsumerCache {
Position position) {
std::lock_guard lock(mutex);
return this->path == path && this->position == position &&
this->line == line;
line.substr(0,position.character) == this->line.substr(0, position.character);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after ,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks.

@MaskRay MaskRay closed this Nov 8, 2019
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 this pull request may close these issues.

2 participants