-
Notifications
You must be signed in to change notification settings - Fork 30.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
Multicursor autocomplete with LS does not respect additionalTextEdits
option
#113551
Comments
The "root" issue is that our C/C++ extension receives a single textDocument/completion request via the LSP, and we respond with a CompletionItem that is only valid on one of the cursor locations, but VS Code is replicating the insertText to all cursor locations, i.e. in other cases the variable to the left of the cursor may be a different type and have different valid completion results, so I think correct fix would be to send a completion request for every cursor, although the UI experience might be odd with multiple popups per cursor. The additonalTextEdits we send to replace the '.' with '-' is only valid for the first cursor, since it's an edit of a specific line/character, so it seems unlikely that VS Code would want to try to do something to try to replicate the additionalTextEdits for the other cursor locations like it's doing for the insertText. |
additionalEdit
optionadditionalTextEdits
option
I also tried using a range (and a inserting/replacing range) that is before the dot, but VS Code won't allow the range to go before the invocation position (the "."). |
I am pretty sure it does. |
Since additional text edits are "precise", e.g. naming a range and text, we cannot multiply them with each cursor location. However, the main edit of a completion will be applied for each cursor. So, ideally the c++ extension doesn't need additional text edits for this. |
@jrieken Here are the details:
and send back
but VS Code shows "no results" -- changing textEdit.start.character from 5 to 6 gives results (but that ends up giving |
@jrieken We're not using InsertReplaceEdit with LSP 3.16, but LSP 3.14.1 (vscode-languageclient 5.2.1.). Let us know if you think upgrading to a new version is expected to fix this issue. |
When the range of the text edit select the |
@jrieken Cool, thanks a lot for the help -- I got it to work via changing filterText to We were never using "filterText" and didn't understand what the docs meant by "A string that should be used when filtering a set of completion items. " (adding an example might help others understand its effect). @nmay231 Our next release should have a fix. |
Awesome! Thank you both 👍 |
@sean-mcmanus 👏 very cool. Yeah, the filterText is really under-documented and something that's hard to grasp. I'll make sure our extension samples and/or docs get better |
Info
For language extensions that provide completions with the
additionalTextEdits
option, multicursor mode only applies the edit to the first selection and not subsequent ones. To give an example, the cpp extension allows autocompleting indirect struct attributes using periods. Ifmy_struct
is a pointer to a struct, you can typemy_struct.at
and then tab-complete to getmy_struct->attribute
. However, using multicursor autocomplete, gives unexpected results:Pressing
tab
will autocomplete to the following.Also, see attached screenshot.
Copied/moved from microsoft/vscode-cpptools#6720
The text was updated successfully, but these errors were encountered: