PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

textDocument/codeAction does not send the correct selection range to the language server

Open AdamYoblick opened this issue 3 years ago • 2 comments

From https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1378352:

Affected Branch: 17 Preview 4 Affected Build: 8/19/2021 Affected Product Language:

Steps to reproduce:

See steps here for the extract method bug (ignore rename for now): Extract method only works on one line and rename doesn't work at all · Issue #1694 · microsoft/pylance-release (github.com)

The extract portion of that bug isn't working because the LSP client sends this:

LSPClient.Pylance Information: 8 : {"id":8,"method":"textDocument/codeAction"}
LSPClient.Pylance Verbose: 8 : Sent: {
"traceparent": "00-308f1eda378a3c418cd446668e76c98a-5ae985e6ede6264a-01",
"jsonrpc": "2.0",
"id": 8,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "file:///C:/Users/aku91/source/repos/PythonApplication6/PythonApplication6/PythonApplication6.py"
},
"range": {
"start": {
"line": 12,
"character": 0
},
"end": {
"line": 12, <-- This only includes a single line.
"character": 14
}
},
"context": {
"_vs_selectionRange": {
"start": {
"line": 12,
"character": 0
},
"end": {
"line": 14,   <-- This is the full range
"character": 17
}
},
"diagnostics": []
}

It looks like the _vs_selectionRange is correct, but the codeAction selection range isn't.

This same thing in VS code sends the full codeAction range.

AdamYoblick avatar Feb 08 '22 22:02 AdamYoblick

Sounds like this is a bug in the LSP client and not ours to fix. Waiting on confirmation before closing this out.

AdamYoblick avatar Feb 09 '22 23:02 AdamYoblick

The internal bug was closed as By Design, so I think this is ours to fix.

AdamYoblick avatar Feb 02 '23 22:02 AdamYoblick