pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

block comments not adapt with python.

Open zzdywc opened this issue 2 years ago • 3 comments

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.84.0
  • OS Version: windows11 23H2

Steps to Reproduce:

  1. write down some python code.
  2. use block comments(alt+shfit+A) on some for or with block code or any indented code. and the ''' will on the top of line witch is not correct.

example figure. image

zzdywc avatar Nov 06 '23 05:11 zzdywc

Hey @zzdywc , Could you please provide a more detailed example that covers the range of codes you want to comment out, your expected behavior, etc That will help me reproduce this issue, thanks!

KacieKK avatar Dec 06 '23 02:12 KacieKK

code sample as shown:

x = []
for i in range(100):
    print(i)
    print(i/10)
    x.append(i)
    if(i == 10):
        print("yes")
print("end")

normal comments like:

x = []
for i in range(100):
    print(i)
    '''
    print(i/10)
    x.append(i)
    '''
    if(i == 10):
        print("yes")
print("end")

select code:

    print(i/10)
    x.append(i)

press shift+alt+A, and will add comment symbol like this:

x = []
for i in range(100):
    print(i)
"""     
    print(i/10)
    x.append(i)
     """
    if(i == 10):
        print("yes")
print("end")

This code make if work improperly.

It seems like comment will added one space before the starting position and The last space of the end position of which have been selected. though this logic work fine with orther language like c etc. but not work on language that relies on indentation. I don't know what logic is the best, but in my opinion, add new line at the bothstart position and end postion of which have been selected, and than add comment symbol ''' at the new line with properly indentation will fix this problem. image

zzdywc avatar Dec 06 '23 05:12 zzdywc

Thanks for the issue, I can repro it

KacieKK avatar Jul 11 '24 18:07 KacieKK