-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Support 'textEdit.newText' in 'resolveSupport' of 'CompletionClientCapabilities' #183092
Comments
… additionalTextEdits #183092 (comment)
… additionalTextEdits (#183224) #183092 (comment)
Is there any reason to ban this capability? I know the behavior is not intended, but current VS Code supports it quite well. |
Hi @jrieken I'm writing to express my concern about #183224 to disable textedit resolve in resolveCompletionItem. This will break the code completion feature for Java users, as Java extension relies on textedit lazy resolve for performance reasons (it can be 2X faster in some cases with delay resolving text edit). Code completion is a very important and widely used feature for VS Code Java users, and losing it will greatly affect the user experience and productivity. I understand that you have your reasons to disable textedit lazy resolve, but I hope you can reconsider this decision on #183224 or provide an alternative solution for us. Thank you for your understanding and collaboration. |
@jdneo @testforstephen Sorry, but I cannot follow. Resolving the primary text edit async cannot work reliably. Accepting a completion item in the UI (via the keyboard or mouse) is a synchronous operation and we synchronously apply the (primary) text edit. This never did (and technically cannot) wait for the completion item to be resolved - in fact it can be that we only call resolve after making the edit. This means fast typing/accepting of completions will not get the resolved item and its acceptance behaviour is more or less random (depends on the workload of the EH process and user interaction speed) Note that I am only talking about that, e.g |
The
I agree that with a very fast typing speed, there will be a chance that the edit has not been resolved and get applied. To be honest, my own experience on that is, the possibility is very low. At least for myself, I haven't experienced that in my memory. I think this is kind of tradeoff between the perf and accuracy. What about introducing a setting to control the behavior (allow/disallow resolving edit) and leave the choice to users? I really hope VS Code team can reconsider it, if this capability is disabled, it will have a very huge impact on completion experience for Java language. |
Share more background: We will always return an We understand that VS Code cannot guarantee that the completion/resolve request is executed before applying the completion item, but we think that’s an acceptable tradeoff between the perf and accuracy. Java extension has used lazy resolving textEdit in completion feature for years and we haven’t received negative feedback from users. Before we find a better alternative solution for completion performance (e.g. support incremental completion request), can we maintain the behavior as before for now? @jrieken WDYT? |
…resolveCompletionItem behaviour re #183092
Understood, I have pushed #183426 to give us some breathing room here. However, this will need to change.
Sounds like "Works for me™️". I am your experience is going to be different when using a slower computer, having more extensions doing stuff in the EH process, working on codespaces with high latency etc pp. Doing things like this is an invitation for "randomness" and nothing great.
In a way the API already has these alternatives, e.g the |
@jrieken thanks for revisiting the issue. |
@jrieken Another restrictionof A usage example is that we can use
|
Likely no, esp. not when the main edit is already a snippet and not when additional edits come late. Snippet insertion always requires user interaction, e.g the cursor jumps to placeholder etc pp. This technically cannot be done for two snippets at the same time and UX-wise this cannot be done at a "random" point in time |
With #184994 we are collecting telemetry about how often items are inserted before resolve is done. We will also log how often asynchronous additional edits can successfully be applied. Once we have the data we can make informed decisions. |
Some data over the last two weeks. This is always about inserting a completion item before has been resolved. This means:
The columns mean the following
The gist remains that unresolved item insertion (with above consequences) happens rarely but to very many users.
|
Thanks for the numbers! This might be slightly off-topic for this issue, because for Dart we currently only compare about supporting
Am I right in thinking that VS Code doesn't know whether resolve is adding anything here (because we have no "requiresResolve" flag on a completion item)? So if on average only 10% of completions actually change edits/commands during resolve and this number is 4%, it's actually only (on average(!)) 0.4% of completions that would be affected? |
Let's keep this off-topic but yes we only know that the provider wants to resolve (otherwise it wouldn't have that capability) but we do not know what it actually does, only the provider knows |
Hi @jrieken, some question about the data.
|
It's over all completions, so 4.56% of all java completions are inserted before resolving is done (response not yet received) |
May I ask what's VS Code's perspective about the data? What kind of bar is considered acceptable for the 'unresolved' rate? |
@jrieken It seems to me that |
@jrieken is there a dashboard that we can use as a starting point to expand on the completion telemetry? |
Proposal
Today, VS Code declares the
resolveSupport
ofCompletionClientCapabilities
as:The
textEdit
is not included since therange
of thetextEdit
is a key information to let the client do filtering correctly.What if we limit the scope to
textEdit.newText
only? By doing this, the range is guaranteed to be available in the response oftextDocument/completion
. Only the content may have an update incompletionItem/resolve
.Example
For example, when completing the constructor
new String(byte[] bytes)
in Java. If we support lazy-resolve thenewText
ofTextEdit
, we can first returnin
textDocument/completion
. And then give a more accurate content incompletionItem/resolve
:Even if the item is committed before the resolve result comes, the completion result is still acceptable.
More background
The completion performance is always a key metric for a Language Server. Specific to Java Language Server, we found that the
textEdit
always takes a lot of time to calculate, mostly caused by the calculation ofnewText
part (Because it requires to append parameter names. When it comes to constructor completion, the situation becomes like a disaster because the server needs to fetch source code from different types to get the parameter names of different constructors). This is how this idea came about.The text was updated successfully, but these errors were encountered: