Repository navigation
CompletionItem of completions response always have start = 0 and text prefix inclusion is mixed #524
Description
Activity
- added 2 commits that reference this issue
on Dec 8, 2023 testforstephen commented
on Mar 21, 2024 ContributorMore actionsLines 348 to 358 in 736dcac
public static class CompletionItem { public String label; public String text; public String type; /** * A string that should be used when comparing this item with other items. */ public String sortText; public int start; public int number; start = 0should be a bug. We don't assign a value tostartattribute of CompletionItem intentionally, and it's the Java compiler that gives it a default value0during json serialization. Our purpose is to always insert, I think we should removestartandnumberfields from our protocol data structure.Hi Mathias Fußenegger (@mfussenegger), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
– According to the DAP spec, you can avoid these prefix-duplication issues by using a TextEdit rather than raw
text+start:
• Fill intextEdit.rangeto cover exactly the existing prefix (e.g. from the dot back to after the identifier) and settextEdit.newTextto the remainder of the completion.
• See https://microsoft.github.io/debug-adapter-protocol/specification#Types_TextEdit– If you prefer
start+text, computestartas the prefix length in UTF-16 code units (respectingcolumnsStartAt1). For example, for “com.” (prefixLen = 4), sendstart: 4,text: "sun.tools.example". Omittingstartalso defaults to inserting at the request’scolumn.Other references with low confidence:
Use textEdit instead of insertText to avoid ambiguous (eclipse-jdt.ls#2679)
• Discusses switching from
insertText+additionalTextEditsto a singletextEditto avoid overlapping prefixes.
• URL: eclipse-jdtls/eclipse.jdt.ls#2679 (comment)The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
I noticed recently that in nvim-dap, if you complete
com.and select an entry you getcom.com...inserted, so today I took a closer look and noticed that the responses from java-debug are somewhat odd - and I think incorrect.With a client that specified
columnsStartAt1 = true, and acompletionspayload like:The responses include:
The specification says:
The expected result for the user is to have
List.of()if the completion candidate is selected. Now,start=0is already odd given thecolumnsStartAt1, so a possible interpretation in the client is that it's absent, and that the client should just append.of()This is kinda what I did in nvim-dap so far, and it works for the
List.ofcase, and also for variables, but with a payload like:I get responses like:
Opposed to the
List.result, heretextincludes the prefixcom.and it's againstart=0. This led tocom.com.sun.tools.exampleI suspect vscode does some kind of prefix matching on the client side again, so this isn't noticable there?
As far as I can tell, based on the specification the current behavior is wrong.
I used JDK 21 in my tests - in case it matters.
I can also provide some sample project if needed - but I tried to use examples that should behave similar with only the JDK as dependency