-
Notifications
You must be signed in to change notification settings - Fork 456
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
[Bug] The focus range of Pasted text is wrong #3155
Comments
I don't think it should select the whole |
sorry for bumping, but is anything happening here? It is really annoying, how it works at the moment. |
I think this is related to our paste event handling, because if I disable it, the problem goes away. As a workaround, there's the setting package org.example;
public class Test {
public void test() {
String multiLineEscape = "";
String notComment = "";
}
} I'm going to copy The resulting interaction is as follows : [Trace - 14:30:57] Sending request 'workspace/executeCommand - (2899)'.
Params: {
"command": "java.edit.handlePasteEvent",
"arguments": [
"{\"location\":{\"range\":{\"start\":{\"line\":4,\"character\":15},\"end\":{\"line\":4,\"character\":25}},\"uri\":\"file:///tmp/foo/org/example/Test.java\"},\"text\":\"multiLineEscape\",\"copiedDocumentUri\":\"file:///tmp/foo/org/example/Test.java\",\"formattingOptions\":{\"insertSpaces\":true,\"tabSize\":4}}"
]
}
[Info - 14:30:57] Jul. 25, 2023, 2:30:57 p.m. >> workspace/executeCommand java.edit.handlePasteEvent
[Trace - 14:30:57] Received response 'workspace/executeCommand - (2899)' in 8ms.
Result: {
"insertText": "multiLineEscape"
}
[Trace - 14:30:57] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///tmp/foo/org/example/Test.java",
"version": 378
},
"contentChanges": [
{
"range": {
"start": {
"line": 4,
"character": 23
},
"end": {
"line": 4,
"character": 25
}
},
"rangeLength": 2,
"text": ""
},
{
"range": {
"start": {
"line": 4,
"character": 16
},
"end": {
"line": 4,
"character": 22
}
},
"rangeLength": 6,
"text": "eEscap"
},
{
"range": {
"start": {
"line": 4,
"character": 15
},
"end": {
"line": 4,
"character": 15
}
},
"rangeLength": 0,
"text": "multiLi"
}
]
} The
From what I can tell, the problem also doesn't happen if the text being pasted shares no characters in common with the text being replaced (ie. fastest way is to replace every character) |
Same problem for:
As @HerrDerb mentioned, I would also expect the cursor being at the end of the pasted text without anything being selected as with all text editors, I am aware of. BTW pasting works this way for other language servers, I have tested. If you open a Java file in "language mode" text, copy&paste works as expected, so the problem must be caused by the Java LS. |
I just tried with VS Code 1.82.2 and Language Support for Java v1.26.0 (Jan 2024) and the problem has been gone since then. Here's what I see : [Trace - 12:04:47] Sending request 'workspace/executeCommand - (173)'.
Params: {
"command": "java.edit.handlePasteEvent",
"arguments": [
"{\"location\":{\"range\":{\"start\":{\"line\":4,\"character\":15},\"end\":{\"line\":4,\"character\":25}},\"uri\":\"file:///tmp/foo/org/example/Test.java\"},\"text\":\"multiLineEscape\",\"copiedDocumentUri\":\"file:///tmp/foo/org/example/Test.java\",\"formattingOptions\":{\"insertSpaces\":true,\"tabSize\":4}}"
]
}
[Trace - 12:04:47] Received response 'workspace/executeCommand - (173)' in 3ms.
No result returned.
[Trace - 12:04:47] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///tmp/foo/org/example/Test.java",
"version": 13
},
"contentChanges": [
{
"range": {
"start": {
"line": 4,
"character": 15
},
"end": {
"line": 4,
"character": 25
}
},
"rangeLength": 10,
"text": "multiLineEscape"
}
]
} Screencast.from.2024-06-18.12-07-22.webmThis is due to us fixing our paste event handling implementation to delegate back to VS Code (by returning an empty result) when no relevant changed are made (eg. text to be pasted remains unchanged). I'm marking this as closed, but feel free to mention if there's something I've missed here, or if someone is still running into this. |
[provide a description of the issue]
Environment
Version: 1.79.1 (user setup)
Commit: 4cb974a7aed77a74c7813bdccd99ee0d04901215
Date: 2023-06-12T16:14:05.102Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19045
Java extension version: 1.19.0
Steps To Reproduce
Current Result
The selected range is wrong.
Expected Result
Should select whole
logException
Additional Informations
The text was updated successfully, but these errors were encountered: