PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Extract method only works on one line and rename doesn't work at all

Open linette-zyy opened this issue 3 years ago • 6 comments

Environment image

Steps to Reproduce

  1. Create a Python Application project
  2. Input some code
  3. Move the cursor to a one line
  4. The Quick Action icon appears in front of this line. image

Actual result When select server line, the icon does not appear image

And the extract method can not rename. I rename "new_func", does not work image

linette-zyy avatar Aug 18 '21 08:08 linette-zyy

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.

jakebailey avatar Aug 19 '21 17:08 jakebailey

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 avatar Apr 27 '22 19:04 AdamYoblick

@AdamYoblick would there be additional work needed for us after LSP support ? Or do we just need LSP support?

judej avatar Jan 06 '23 19:01 judej

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.

AdamYoblick avatar Jan 06 '23 20:01 AdamYoblick

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 extract_method1

linette-zyy avatar Sep 18 '23 07:09 linette-zyy

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)

extract_method2

linette-zyy avatar Sep 18 '23 07:09 linette-zyy