microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.71k stars 29.45k forks source link

`InlineCompletionItemProvider.handleDidPartiallyAcceptCompletionItem` accepted length is dependent on the trigger #234330

Open hstaudacher opened 4 days ago

hstaudacher commented 4 days ago

Does this issue occur when all extensions are disabled?: No because the API needs to be implemented by an extension

The InlineCompletionItemProvider.handleDidPartiallyAcceptCompletionItem method has 2 problems:

  1. The acceptedLength depends on the trigger kind. Let's look at a scenario in the screenshot: Image Here we see that a partial acceptance should apply the word unction which has 7 characters. If I accept partially using the suggestion widget the method gets invoked with 7. If I accept the suggestion partially using cmd + -> the method gets invoked with 14. This makes computation very hard.
  2. The problem gets even harder because the acceptedLength and PartialAcceptInfo are not passed in a single method call. First the method with the length is invoked before you invoke the same method with the info object. Because of the first issue we need to know the trigger kind in order to compute the length correctly. I think PartialAcceptInfo should at least contain the acceptedLength to avoid implementors to cache the length across several method invocations.