-
Notifications
You must be signed in to change notification settings - Fork 406
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
class
snippet completion returns both insertText
and editText
#3341
Comments
Is this the latest release of JDT-LS ? If not, does the problem still exist when trying https://download.eclipse.org/jdtls/milestones/1.42.0/ ? When I tried using the Looking at Lines 554 to 558 in b1dcda4
textEditText and insertText .
|
Originally, no, I think I used 1.39.0 or 1.40.0, but I've just now tested with 1.42.0 and it seems to be the same: // Send:
{"jsonrpc":"2.0","id":38,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///Users/valentinebriese/Developer/SwerveDrive2025/src/main/java/frc/robot/subsystems/Test.java"},"position":{"line":0,"character":3},"context":{"triggerKind":1}}}
// Receive:
{"jsonrpc":"2.0","id":38,"result":{"isIncomplete":false,"items":[{"label":"class","kind":15,"documentation":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t\n}","sortText":"999999212","filterText":"class","insertText":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t${0}\n}","insertTextMode":2,"textEditText":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t${0}\n}"},{"label":"class","kind":14,"sortText":"999999213","filterText":"class","textEditText":"class","command":{"title":"","command":"java.completion.onDidSelect","arguments":["10","0"]},"data":{"pid":"0","rid":"10"}}],"itemDefaults":{"editRange":{"insert":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"replace":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}}},"insertTextFormat":2,"data":{"completionKinds":[3]}}}}
// Send:
{"jsonrpc":"2.0","id":39,"method":"completionItem/resolve","params":{"label":"class","kind":15,"documentation":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t\n}","sortText":"999999212","filterText":"class","insertText":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t${0}\n}","insertTextFormat":2,"insertTextMode":2,"textEdit":{"newText":"class","insert":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"replace":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}}},"data":{"completionKinds":[3]}}}
// Receive:
{"jsonrpc":"2.0","id":39,"result":{"label":"class","kind":15,"documentation":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t\n}","sortText":"999999212","filterText":"class","insertText":"package frc.robot.subsystems;\n\npublic class Test {\n\n\t${0}\n}","insertTextFormat":2,"insertTextMode":2,"textEdit":{"newText":"class","insert":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"replace":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}}}}} I'm noticing what I think is a discrepancy here though, between the 2nd message and the 3rd message. That's probably something to bring up with the devs of my editor, right? |
Yeah, I think something odd may be happening client-side. As an explanation : The first message is the completion request, and the language server responds by returning the list of completions (2nd message). The 3rd message is the client taking the a given item that was selected (eg. users selected it) (3rd message) and requesting it be resolved. The server sends the resolved item as the 4th message. This resolution process can be useful if computing the text/documentation/some property for each completion item is very expensive. The resolve only gets called when the item is selected so it allows the language server to be more responsive and defer certain computations. Back to your example :
|
The
class
snippet completion returns bothinsertText
andeditText
. The LSP spec says that ifeditText
is given,insertText
should be ignored, which I find unlikely to be the intentional behavior on behalf of JDTLS in this case.Here is an example RPC message I received:
The effect of this is that instead of inserting a new public class with the same name as the current file, you just get the word
class
and that’s it.The text was updated successfully, but these errors were encountered: