vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Autocomplete sometimes overwrites/deletes characters

Open Palidino opened this issue 6 years ago • 36 comments

I'm not really sure how to reproduce, because it seems to happen at complete random.

if (getKilled(NpcID.MONSTER_1)) { if (getKilled(NpcID.MONSTER_2 {

Take that code for example: I replaced a previous value with MONSTER_1 using autocomplete, and it worked fine. A few lines down, I go to replace text by selecting it and start typing MONSTER_2 and autocomplete to finish typing it, and it deletes )). Sometimes it will even delete the opening bracket at the end too.

Palidino avatar May 23 '19 20:05 Palidino

Can't reproduce. Please enable verbose logging and attach the vscode-java logs from the output view here, when that happens.

fbricon avatar May 24 '19 20:05 fbricon

You can see down below, SUPER_MYSTERY_BOX_32286uperBox()

The line I was editing when I used autocomplete: ItemId.supermystery, new SuperBox()

Overall my text being replaced happens quite frequently. Sometimes undoing the autocomplete and doing it again resolves the issue, or sometimes it replaces my characters all over again. I'm on a macbook air 2018 which isn't the fastest laptop, but I would expect autocomplete to be slow and not actually delete characters.

EDIT: Code tags didn't work https://pastebin.com/Mfwxd1iX https://paste.ee/p/Vn29n

`[Trace - 4:28:53 PM] Sending notification 'textDocument/didChange'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java", "version": 430 }, "contentChanges": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 127 } }, "rangeLength": 19, "text": "SUPER_MYSTERY_BOX_32286" } ] }

[Trace - 4:28:54 PM] Sending request 'textDocument/foldingRange - (803)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" } }

[Trace - 4:28:54 PM] Sending request 'workspace/executeCommand - (804)'. Params: { "command": "vscode.java.test.search.codelens", "arguments": [ "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" ] }

[Trace - 4:28:54 PM] Sending request 'workspace/executeCommand - (805)'. Params: { "command": "vscode.java.resolveMainMethod", "arguments": [ "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" ] }

[Trace - 4:28:54 PM] Sending request 'textDocument/codeAction - (806)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [] } }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "99355795-a457-499d-b417-6a17f6d38148", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 50%", "totalWork": 1000, "workDone": 500, "complete": false }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "99355795-a457-499d-b417-6a17f6d38148", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 50%", "totalWork": 1000, "workDone": 500, "complete": true }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "8cc9c7af-f0d8-4e92-95d8-f2fcc18d1a7d", "task": "Validate documents", "status": "Validate documents - 0%", "totalWork": 1000, "workDone": 0, "complete": false }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "8cc9c7af-f0d8-4e92-95d8-f2fcc18d1a7d", "task": "Validate documents", "status": "Validate documents - 25%", "totalWork": 1000, "workDone": 250, "complete": false }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "8cc9c7af-f0d8-4e92-95d8-f2fcc18d1a7d", "task": "Validate documents", "status": "Validate documents - 50%", "totalWork": 1000, "workDone": 500, "complete": true }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "22e1a9b7-9ce2-45b4-ae4d-6fddb9e02c3c", "task": "Building workspace", "status": "Building workspace - 0%", "totalWork": 1000, "workDone": 0, "complete": false }

[Trace - 4:28:54 PM] Received notification 'language/progressReport'. Params: { "id": "22e1a9b7-9ce2-45b4-ae4d-6fddb9e02c3c", "task": "Building workspace", "status": "Building workspace - 0%", "totalWork": 1000, "workDone": 0, "complete": true }

[Trace - 4:28:54 PM] Received response 'workspace/executeCommand - (805)' in 640ms. Result: []

[Trace - 4:28:54 PM] Received response 'workspace/executeCommand - (804)' in 643ms. Result: []

[Trace - 4:28:54 PM] Received response 'textDocument/foldingRange - (803)' in 693ms. Result: [ { "startLine": 0, "endLine": 2, "kind": "comment" }, { "startLine": 5, "endLine": 9, "kind": "imports" }, { "startLine": 11, "endLine": 328 }, { "startLine": 244, "endLine": 257 }, { "startLine": 245, "endLine": 246 }, { "startLine": 247, "endLine": 248 }, { "startLine": 249, "endLine": 250 }, { "startLine": 251, "endLine": 252 }, { "startLine": 253, "endLine": 255 }, { "startLine": 259, "endLine": 270 }, { "startLine": 260, "endLine": 261 }, { "startLine": 262, "endLine": 263 }, { "startLine": 264, "endLine": 265 }, { "startLine": 266, "endLine": 268 }, { "startLine": 272, "endLine": 274 }, { "startLine": 276, "endLine": 286 }, { "startLine": 288, "endLine": 297 }, { "startLine": 299, "endLine": 301 }, { "startLine": 303, "endLine": 305 }, { "startLine": 307, "endLine": 311 }, { "startLine": 313, "endLine": 315 }, { "startLine": 317, "endLine": 319 }, { "startLine": 321, "endLine": 321 }, { "startLine": 323, "endLine": 323 }, { "startLine": 331, "endLine": 360 }, { "startLine": 333, "endLine": 346 }, { "startLine": 336, "endLine": 337 }, { "startLine": 338, "endLine": 339 }, { "startLine": 340, "endLine": 341 }, { "startLine": 342, "endLine": 344 }, { "startLine": 334, "endLine": 335 }, { "startLine": 349, "endLine": 359 }, { "startLine": 362, "endLine": 388 }, { "startLine": 364, "endLine": 375 }, { "startLine": 367, "endLine": 368 }, { "startLine": 369, "endLine": 370 }, { "startLine": 371, "endLine": 373 }, { "startLine": 365, "endLine": 366 }, { "startLine": 378, "endLine": 387 } ]

[Trace - 4:28:55 PM] Received response 'textDocument/codeAction - (806)' in 978ms. Result: [ { "title": "Organize imports", "kind": "source.organizeImports", "diagnostics": [], "command": { "title": "Organize imports", "command": "java.action.organizeImports", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [] } } ] } }, { "title": "Override/Implement Methods...", "kind": "source.overrideMethods", "diagnostics": [], "command": { "title": "Override/Implement Methods...", "command": "java.action.overrideMethodsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [] } } ] } }, { "title": "Generate Getters and Setters...", "kind": "source.generate.accessors", "diagnostics": [], "command": { "title": "Generate Getters and Setters...", "command": "java.action.generateAccessorsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [] } } ] } }, { "title": "Generate toString()...", "kind": "source.generate.toString", "diagnostics": [], "command": { "title": "Generate toString()...", "command": "java.apply.workspaceEdit", "arguments": [ { "changes": { "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java": [ { "range": { "start": { "line": 327, "character": 5 }, "end": { "line": 327, "character": 5 } }, "newText": "\n\n @Override\n public String toString() {\n return "MysteryBox []";\n }" } ] } } ] } } ]

[Trace - 4:28:55 PM] Received notification 'language/progressReport'. Params: { "id": "e7896a67-3ac4-4bc6-877f-90fbb78acb2d", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 0%", "totalWork": 1000, "workDone": 0, "complete": false }

[Trace - 4:28:55 PM] Received notification 'language/progressReport'. Params: { "id": "e7896a67-3ac4-4bc6-877f-90fbb78acb2d", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 25%", "totalWork": 1000, "workDone": 250, "complete": false }

[Trace - 4:28:55 PM] Received notification 'language/progressReport'. Params: { "id": "e7896a67-3ac4-4bc6-877f-90fbb78acb2d", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 50%", "totalWork": 1000, "workDone": 500, "complete": false }

[Trace - 4:28:55 PM] Received notification 'textDocument/publishDiagnostics'. Params: { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java", "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] }

[Trace - 4:28:55 PM] Received notification 'language/progressReport'. Params: { "id": "e7896a67-3ac4-4bc6-877f-90fbb78acb2d", "task": "Publish Diagnostics", "status": "Publish Diagnostics - 50%", "totalWork": 1000, "workDone": 500, "complete": true }

[Trace - 4:28:56 PM] Received notification 'language/progressReport'. Params: { "id": "7e560ab8-f2bc-48ba-9191-935f7018c303", "task": "Building workspace", "status": "Building workspace - 0%", "totalWork": 1000, "workDone": 0, "complete": false }

[Trace - 4:28:56 PM] Received notification 'language/progressReport'. Params: { "id": "7e560ab8-f2bc-48ba-9191-935f7018c303", "task": "Building workspace", "status": "Building workspace - 0%", "totalWork": 1000, "workDone": 0, "complete": true }

[Trace - 4:28:56 PM] Sending request 'textDocument/codeAction - (807)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId", "severity": 1, "code": "67108964", "source": "Java" } ] } }

[Trace - 4:28:59 PM] Received response 'textDocument/codeAction - (807)' in 3010ms. Result: [ { "title": "Create method 'SUPER_MYSTERY_BOX_32286uperBox()' in type 'ItemId'", "kind": "quickfix", "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ], "command": { "title": "Create method 'SUPER_MYSTERY_BOX_32286uperBox()' in type 'ItemId'", "command": "java.apply.workspaceEdit", "arguments": [ { "changes": { "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/io/cache/ItemId.java": [ { "range": { "start": { "line": 14699, "character": 5 }, "end": { "line": 14699, "character": 5 } }, "newText": "\n\n public static Object SUPER_MYSTERY_BOX_32286uperBox() {\n return null;\n }" } ] } } ] } }, { "title": "Organize imports", "kind": "source.organizeImports", "diagnostics": [], "command": { "title": "Organize imports", "command": "java.action.organizeImports", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Override/Implement Methods...", "kind": "source.overrideMethods", "diagnostics": [], "command": { "title": "Override/Implement Methods...", "command": "java.action.overrideMethodsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Generate Getters and Setters...", "kind": "source.generate.accessors", "diagnostics": [], "command": { "title": "Generate Getters and Setters...", "command": "java.action.generateAccessorsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Generate toString()...", "kind": "source.generate.toString", "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ], "command": { "title": "Generate toString()...", "command": "java.apply.workspaceEdit", "arguments": [ { "changes": { "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java": [ { "range": { "start": { "line": 327, "character": 5 }, "end": { "line": 327, "character": 5 } }, "newText": "\n\n @Override\n public String toString() {\n return "MysteryBox []";\n }" } ] } } ] } } ]

[Trace - 4:29:02 PM] Sending request 'workspace/executeCommand - (808)'. Params: { "command": "java.resolvePath", "arguments": [ "file:///Users/palidino/Library/Application%20Support/Code/User/workspaceStorage/394b7fe18b65801d39247814f8d0e577/redhat.java/jdt_ws/.metadata/.log" ] }

[Trace - 4:29:02 PM] Received response 'workspace/executeCommand - (808)' in 24ms. Result: []

[Trace - 4:29:10 PM] Sending request 'textDocument/codeAction - (809)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 0 } }, "context": { "diagnostics": [] } }

[Trace - 4:29:10 PM] Sending request 'workspace/executeCommand - (810)'. Params: { "command": "java.resolvePath", "arguments": [ "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" ] }

[Trace - 4:29:10 PM] Received response 'workspace/executeCommand - (810)' in 7ms. Result: [ { "name": "Server", "path": "/Server", "uri": "file:/Users/palidino/Home/OSRS/B-Palidino/Server", "kind": 2 }, { "entryKind": 1, "name": "data/core/src", "path": "/Server/data/core/src", "kind": 4 }, { "name": "com.palidino.osrs.model.item", "path": "/Server/data/core/src/com/palidino/osrs/model/item", "kind": 5 }, { "entryKind": 1, "name": "MysteryBox.java", "path": "/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java", "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java", "kind": 6 } ]

[Trace - 4:29:10 PM] Sending request 'textDocument/foldingRange - (811)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" } }

[Trace - 4:29:10 PM] Received response 'textDocument/foldingRange - (811)' in 4ms. Result: [ { "startLine": 0, "endLine": 2, "kind": "comment" }, { "startLine": 5, "endLine": 9, "kind": "imports" }, { "startLine": 11, "endLine": 328 }, { "startLine": 244, "endLine": 257 }, { "startLine": 245, "endLine": 246 }, { "startLine": 247, "endLine": 248 }, { "startLine": 249, "endLine": 250 }, { "startLine": 251, "endLine": 252 }, { "startLine": 253, "endLine": 255 }, { "startLine": 259, "endLine": 270 }, { "startLine": 260, "endLine": 261 }, { "startLine": 262, "endLine": 263 }, { "startLine": 264, "endLine": 265 }, { "startLine": 266, "endLine": 268 }, { "startLine": 272, "endLine": 274 }, { "startLine": 276, "endLine": 286 }, { "startLine": 288, "endLine": 297 }, { "startLine": 299, "endLine": 301 }, { "startLine": 303, "endLine": 305 }, { "startLine": 307, "endLine": 311 }, { "startLine": 313, "endLine": 315 }, { "startLine": 317, "endLine": 319 }, { "startLine": 321, "endLine": 321 }, { "startLine": 323, "endLine": 323 }, { "startLine": 331, "endLine": 360 }, { "startLine": 333, "endLine": 346 }, { "startLine": 336, "endLine": 337 }, { "startLine": 338, "endLine": 339 }, { "startLine": 340, "endLine": 341 }, { "startLine": 342, "endLine": 344 }, { "startLine": 334, "endLine": 335 }, { "startLine": 349, "endLine": 359 }, { "startLine": 362, "endLine": 388 }, { "startLine": 364, "endLine": 375 }, { "startLine": 367, "endLine": 368 }, { "startLine": 369, "endLine": 370 }, { "startLine": 371, "endLine": 373 }, { "startLine": 365, "endLine": 366 }, { "startLine": 378, "endLine": 387 } ]

[Trace - 4:29:10 PM] Sending request 'workspace/executeCommand - (812)'. Params: { "command": "vscode.java.test.search.codelens", "arguments": [ "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" ] }

[Trace - 4:29:10 PM] Sending request 'workspace/executeCommand - (813)'. Params: { "command": "vscode.java.resolveMainMethod", "arguments": [ "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" ] }

[Trace - 4:29:10 PM] Received response 'workspace/executeCommand - (812)' in 3ms. Result: []

[Trace - 4:29:10 PM] Received response 'workspace/executeCommand - (813)' in 4ms. Result: []

[Trace - 4:29:10 PM] Sending request 'textDocument/codeAction - (814)'. Params: { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId", "severity": 1, "code": "67108964", "source": "Java" } ] } }

[Trace - 4:29:10 PM] Sending notification '$/cancelRequest'. Params: { "id": 809 }

[Trace - 4:29:10 PM] Received response 'textDocument/codeAction - (809)' in 198ms. Request failed: The request (id: 809, method: 'textDocument/codeAction') has been cancelled (-32800). [Trace - 4:29:14 PM] Received response 'textDocument/codeAction - (814)' in 3164ms. Result: [ { "title": "Create method 'SUPER_MYSTERY_BOX_32286uperBox()' in type 'ItemId'", "kind": "quickfix", "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ], "command": { "title": "Create method 'SUPER_MYSTERY_BOX_32286uperBox()' in type 'ItemId'", "command": "java.apply.workspaceEdit", "arguments": [ { "changes": { "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/io/cache/ItemId.java": [ { "range": { "start": { "line": 14699, "character": 5 }, "end": { "line": 14699, "character": 5 } }, "newText": "\n\n public static Object SUPER_MYSTERY_BOX_32286uperBox() {\n return null;\n }" } ] } } ] } }, { "title": "Organize imports", "kind": "source.organizeImports", "diagnostics": [], "command": { "title": "Organize imports", "command": "java.action.organizeImports", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Override/Implement Methods...", "kind": "source.overrideMethods", "diagnostics": [], "command": { "title": "Override/Implement Methods...", "command": "java.action.overrideMethodsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Generate Getters and Setters...", "kind": "source.generate.accessors", "diagnostics": [], "command": { "title": "Generate Getters and Setters...", "command": "java.action.generateAccessorsPrompt", "arguments": [ { "textDocument": { "uri": "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java" }, "range": { "start": { "line": 13, "character": 131 }, "end": { "line": 13, "character": 131 } }, "context": { "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ] } } ] } }, { "title": "Generate toString()...", "kind": "source.generate.toString", "diagnostics": [ { "range": { "start": { "line": 13, "character": 108 }, "end": { "line": 13, "character": 138 } }, "severity": 1, "code": "67108964", "source": "Java", "message": "The method SUPER_MYSTERY_BOX_32286uperBox() is undefined for the type ItemId" } ], "command": { "title": "Generate toString()...", "command": "java.apply.workspaceEdit", "arguments": [ { "changes": { "file:///Users/palidino/Home/OSRS/B-Palidino/Server/data/core/src/com/palidino/osrs/model/item/MysteryBox.java": [ { "range": { "start": { "line": 327, "character": 5 }, "end": { "line": 327, "character": 5 } }, "newText": "\n\n @Override\n public String toString() {\n return "MysteryBox []";\n }" } ] } } ] } } ]`

Palidino avatar May 31 '19 20:05 Palidino

@Palidino Can you reproduce the issue when starting the server with -Djava.lsp.joinOnCompletion=true? See https://github.com/eclipse/eclipse.jdt.ls/pull/512#issuecomment-357968601 (comment)

snjeza avatar May 31 '19 22:05 snjeza

Added using java.jdt.ls.vmargs, the issue still happens.

Palidino avatar Jun 01 '19 00:06 Palidino

@Palidino Could you, please, try the following:

"java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true -noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication",

snjeza avatar Jun 01 '19 00:06 snjeza

I have lombok installed so those settings were already there/kept them there when I tried -Djava.lsp.joinOnCompletion=true EDIT: I should mention removing lombok does not fix the issue from happening

Palidino avatar Jun 01 '19 00:06 Palidino

Could you send your java.jdt.ls.vmargs or try the following?

"java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true <your_vmargs>",

snjeza avatar Jun 01 '19 01:06 snjeza

My current: "java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"./data/lib/lombok.jar\" -Xbootclasspath/a:\"./data/lib/lombok.jar\""

What I've tried: "java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true -noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"./data/lib/lombok.jar\" -Xbootclasspath/a:\"./data/lib/lombok.jar\" "java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true -noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication" "java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true"

All of these settings still cause my autocompletion to frequently replace characters ahead of where the autocompletion is inserting text (restarted vscode each time to make sure the changes to vmargs applied)

Palidino avatar Jun 01 '19 01:06 Palidino

Could you provide a project example?

snjeza avatar Jun 01 '19 01:06 snjeza

Not really but I talked to someone who also works on my project and it seems one of the biggest causes is from an ItemId file which contains about 15k static final integers https://paste.ee/p/vdPJf

While the issue has happened to me while using autocompletion on code that is only a few hundred lines, autocompletion from that particular class causes the issue quite a lot (can also be slow to give suggestions but I expected as much).

Palidino avatar Jun 01 '19 02:06 Palidino

Any update on this or am I just out of luck? This problem still happens all the time while autocompleting all sorts of different things, and updating to the latest vscode didn't solve the issue.

Palidino avatar Jun 07 '19 21:06 Palidino

Even I am facing this issue.

Prasad-Chaudhari avatar Oct 15 '19 05:10 Prasad-Chaudhari

I can almost always reproduce the issue when I do the following:

  • create a random variable: int whatever = 0;
  • write the print statement System.out.println();
  • write something random in the paranthesis System.out.println(random);
  • make sure to have no spaces, then go at the beginning of the random word you wrote and put in the variable you created using "this" System.out.println(this.random);
  • at this point you get the autocomplete options, and selecting the this.whatever will remove the word 'random' that was written there System.out.println(this.whatever); This sometimes removes more than just that... apparently it depends on the size of the word, if it is a method or other things which I didn't figure out.

Mihai-MCW avatar Feb 17 '20 19:02 Mihai-MCW

You can set "java.completion.overwrite": false in your settings

fbricon avatar Feb 17 '20 19:02 fbricon

I have the same issue, and I can reproduce it the way @Mihai-MCW described.

A simpler way to reproduce it for me:

  1. Create the following class:
public class test {
    int variable = 0;
    int x = this//comment
}
  1. Now try to type . after this and before //comment. If the suggestions show up instantly, remove it and try again. Sometimes (for me after only a few tries) the suggestion box appears only after a few seconds. Type var before the suggestions appear, then accept the suggestion to extend to this.variable. The result looks like this:
public class test {
    int variable = 0;
    int x = this.variableomment
}

As you can see, it overwrote three characters after the completion (it depends on how many characters you entered before the suggestion appeared).

I think it is related to some kind of lag in the language server. I searched for times >1000ms in the log, and they occur exactly when the suggestion box lags. They seem to be caused by the vscode.java.resolveMainMethod command.

// ...

[Trace - 15:29:46] Sending request 'workspace/executeCommand - (1661)'.
Params: {
    "command": "vscode.java.resolveMainMethod",
    "arguments": [
        "file://omitted_path/test.java"
    ]
}

// ...

[Trace - 15:29:48] Received response 'workspace/executeCommand - (1661)' in 1803ms.
Result: []

//...

timgott avatar Jul 13 '20 13:07 timgott

@timgott could you try to set the following:

"java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m"

or

"java.jdt.ls.vmargs": "-Djava.lsp.joinOnCompletion=true <your_vmargs>"

snjeza avatar Jul 13 '20 13:07 snjeza

With the first option, the suggestion box always occurs instantly and never lags, so the issue doesn't appear anymore.

Using only "-Djava.lsp.joinOnCompletion=true" doesn't change anything.

timgott avatar Jul 13 '20 14:07 timgott

Going to try your first option @snjeza as I still very frequently have this issue a year later. The language server lagging behind a second or two definitely makes sense considering I'm on a MacBook air. EDIT: Still overwrote characters ahead of the autocompletion within a minute of testing.

Palidino avatar Jul 30 '20 21:07 Palidino

@Palidino could you show your user and workspace settings.json?

snjeza avatar Jul 30 '20 22:07 snjeza

user: https://paste.ee/p/sTcLP workspace: https://paste.ee/p/Q1C2B folder/project: https://paste.ee/p/dFjmG

I've already tried all the variations of vmarms suggested in this issue.

Going back to the language server just not keeping up, if I remove a few letters off of something, then type 1 letter and wait for autocomplete and select it, it fills in correctly. If I start typing everything I deleted, and then select the autocomplete once it pops up, the issue happens and characters get removed.

Palidino avatar Jul 31 '20 01:07 Palidino

@Palidino Do you have the Visual Studio IntelliCode extension installed? If so, try to add:

"vsintellicode.java.completionsEnabled": false,

snjeza avatar Jul 31 '20 02:07 snjeza

@snjeza I do have it installed but that setting didn't help, I'm still losing multiple characters if I'm typing too fast and then select an autocompletion option. It could just be a coincidence but it does feel like turning off IntelliCode completions improves it a little bit. EDIT: I was too quick to judge, this is like night and day difference.

Palidino avatar Jul 31 '20 04:07 Palidino

Any luck or a fix to this? I have this issue , and a character or two gets overwritten for me too.

deekshithanand avatar Dec 14 '20 18:12 deekshithanand

This issue is frustrating and affects my productivity and flow. Is there a workaround?

kaciula avatar Jul 14 '21 13:07 kaciula

Just adding +1. Keeps happening all the time for me. No Visual Studio IntelliCode installed as far as I know.

JanZelenka avatar Jul 27 '21 18:07 JanZelenka

Happening with me too. Disabling IntelliCode and overwrite doesn't fix it

Pankaj-Talesara avatar Aug 17 '21 13:08 Pankaj-Talesara

+1 bump. Same here. A bit annoying sadly.

WiedemannD avatar Sep 08 '21 14:09 WiedemannD

I'm looking into completion issues in JDT language server recently. I tried above steps (provided by @Palidino @timgott @Mihai-MCW ), but failed to reproduce. See below:

https://user-images.githubusercontent.com/2351748/132548663-829fd5f3-d3f9-4614-a230-f17e2a137694.mp4

(I notice serveral thumbups on the "java.completion.overwrite": false solution, but I'm not sure if it's related. If anyone who completely fix this by change this setting to false, please let me know.)

I guess it would be easier to reproduce on less powerful machines. I tried add Thread.sleep(1000) on top of completion / resolve handlers, but still failed to reproduce it. I feel it can be related to wrong internal status of current document,when there are various requests coming.

Please let me know if anyone find out stable way to reproduce it. And you can set java.trace to "verbose" to enable logging in output channel, and focus more on responses related to "completion".

Eskibear avatar Sep 08 '21 16:09 Eskibear

This bug is quite annoying and it happens a lot (maybe all the time even). It affects my flow and productivity. And it's not because of performance issues as I have a Mac M1.

kaciula avatar Sep 24 '21 08:09 kaciula

This bug is hard to fix because we can't reproduce it. Things you can try:

  • execute the Java: Clean Java Language Server Workspace command
  • disable all other vscode extensions

fbricon avatar Sep 24 '21 08:09 fbricon