-
Notifications
You must be signed in to change notification settings - Fork 93
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
Faster completion #413
Faster completion #413
Conversation
@@ -499,10 +501,32 @@ completion_reply <- function(id, uri, workspace, document, point, capabilities) | |||
) | |||
} | |||
|
|||
init_count <- length(completions) | |||
nmax <- getOption("languageserver.max_completions", 200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this setting name should be more explicit, it gives users a feeling that this is the absolute maximum number of items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is indeed the max number of completion items to return to the client. The results will be truncated to this number if it is more than that. Am I misunderstanding your meaning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, you are correct. I was confused. Sorry for the noise.
Faster completion
Closes #412
This PR improves the performance of completion by limiting the max number of completions to return to the client and utilizing the
isIncomplete
feature.If the completion list contains more than
nmax
(by default, 200) items, then the list is sorted by whether it starts withtoken
and thesortText
of the item, and the topnmax
items are returned withisIncomplete = TRUE
so that subsequent keystrokes will still trigger completion requests until the completion list is narrowed down to no greater thannmax
.This largely avoids too much traffic from the response to the completion request triggered by the first keystroke, which could potentially match too many results.
Old behavior (on my machine working in languageserver project):
a
isIncomplete=FALSE
, and subsequent keystrokes do not trigger completion request.In this case, a notable delay could be observed on first keystroke of a token.
New behavior:
a
isIncomplete=TRUE
.s
isIncomplete=TRUE
.
isIncomplete=FALSE
, and subsequent keystrokes do not trigger completion request.In this case, the traffic between server and client is reduced and the delay on first keystroke is much reduced.