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

Open
#6,880 2 comments 0 reactions 1 assignee View on GitHub

@AdamYoblick is already working on this.

Since Dec 12, 2023.

Assessment

This issue has not been assessed yet.

Description

P2

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.

Dominant language
C#
Stars
2.6k
Forks
680
Avg merge
39m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/PTVS

All issues in microsoft/PTVS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.