PTVS
PTVS copied to clipboard
Extract method only works on one line and rename doesn't work at all
Environment
Steps to Reproduce
- Create a Python Application project
- Input some code
- Move the cursor to a one line
- The Quick Action icon appears in front of this line.
Actual result
When select server line, the icon does not appear
And the extract method can not rename. I rename "new_func", does not work
PTVS uses an older version of Pylance which predates allowing extraction of more than a single line and a slew of bugfixes. We'll get it updated.
This is due to a limitation in LSP. We have to wait for a future version of LSP for this to be fixed. See https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1378352 for more information.
@AdamYoblick would there be additional work needed for us after LSP support ? Or do we just need LSP support?
This issue seems to be tracking two different bugs: extract method not working for multi-line selections, and rename not working.
For extract, it looks like that internal bug was closed with As Designed
. It looks like we're supposed to use _vs_selectionRange
instead of range
in pylance, so according to the comments by Oleg, the extract method issue seems like ours to fix in ptvs/pylance (if the comments are accurate).
For rename, I'm not sure. We'd have to follow up with the LSP team to see if that behavior is officially supported.
I can repro this issue on today's latest build:17.8.0 Preview 3.0 [34117.8.main]
When I select single line or more than single line, the icon does not appear
On today's latest build:17.8.0 Preview 3.0 [34117.8.main] There is a strange scene, if I create a method and I don't call it, the command 'Extract method' doesn't have any response, I must call it
def hello():
for i in range(5):
print(i)