pylance-release
pylance-release copied to clipboard
Indentation format is enforcing auto pep 8 even when the previous line is at a different indent
Not sure if this is related, but it used to be that if you wanted to use a literal multiline string as an argument, the autoindent would try to line up the cursor just after the open-paren, but only on the first line. Subsequent lines would simply maintain the previous line's indentation. Now, it autoindents every line until the string is closed.
For example, suppose the first argument is a literal code snippet:
cursor.execute("""|)
When I press Enter, I get
cursor.execute("""
|)
OK, fine, it's trying to align with the open-paren. But it used to be that I could just press Backspace to unindent as needed, and then go on typing, with each subsequent line only maintaining the previous line's indentation. For example, after I've unindented and gotten to this point:
cursor.execute("""
select * from mytable|)
it used to be that pressing Enter would get me to this:
cursor.execute("""
select * from mytable
|)
But now, I actually get this:
cursor.execute("""
select * from mytable
|)
Is there a way to go back to just maintaining the previous line's indentation in that situation, without turning off all the other autoindentation, which for the most part is pretty good?
Originally posted by @jkyeung in https://github.com/microsoft/pylance-release/discussions/4534#discussioncomment-6919756
Reading this it seems like this issue was there before, but to me it feels like it started last month, this honestly makes no sense given that not everything between """ is actually open game for ignoring whitespaces and can be indented at will. Also yes, if you backspace after the automatic indent it only deletes one level. This really looks... interesting when trying to space out some existing lines:
gr.Markdown("""
### Import multiple audio files
You can import multiple audio files by dragging them into the input box.
Due to UVR5 bug, only files without special characters can be imported, including spaces.
Example failure:
MyFile (3).mp3
Working example:
MyFile_3.mp3
""")
then, adding a newline and voila
gr.Markdown("""
### Import multiple audio files
You can import multiple audio files by dragging them into the input box.
Due to UVR5 bug, only files without special characters can be imported, including spaces.
Example failure:
MyFile (3).mp3
Working example:
MyFile_3.mp3
""")
The fix is:
{
"python.analysis.autoIndent": false
}
Though I can't tell yet if I'm not losing something big in return. It's been a while since it felt like my text editor is actively fighting me.
Oh, it's definitely been there since September of 2023, or perhaps even earlier. I noticed it right away because a lot of my code is SQL statements inside triple-quotes, and it suddenly went from not that annoying to incredibly annoying.
It's such a shame because (1) conceptually, the fix is both obvious and has virtually no impact whatsoever for people who find the current behavior not annoying, and (2) it's the only autoindentation error I've encountered. Other than this situation, it always seems to indent intuitively to me, and I hate having to lose that by turning it off.
Try turning it off, it seems to be granual, and the only change I noticed was this annoying bug going away. Newlines in code still indent correctly for me.
On Mon, Jun 24, 2024, 8:13 AM jkyeung @.***> wrote:
Oh, it's definitely been there since September of 2023, or perhaps even earlier. I noticed it right away because a lot of my code is SQL statements inside triple-quotes, and it suddenly went from not that annoying to incredibly annoying.
It's such a shame because (1) conceptually, the fix is both obvious and has virtually no impact whatsoever for people who find the current behavior not annoying, and (2) it's the only autoindentation error I've encountered. Other than this situation, it always seems to indent intuitively to me, and I hate having to lose that by turning it off.
— Reply to this email directly, view it on GitHub https://github.com/microsoft/pylance-release/issues/5415#issuecomment-2185620707, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTRXI2VVPXDRZASOYUSXVDZI6TGJAVCNFSM6AAAAABCP4JHCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBVGYZDANZQG4 . You are receiving this because you commented.Message ID: @.***>
If I turn off this setting, I lose some of the desirable automatic indenting and dedenting. Some remains, which in a way is worse than having no automatic indentation at all, because the behavior feels inconsistent and unintuitive. So turning it off is not a good option for me.
If I turn off this setting, I lose some of the desirable automatic indenting and dedenting. Some remains, which in a way is worse than having no automatic indentation at all, because the behavior feels inconsistent and unintuitive. So turning it off is not a good option for me.
Thanks for letting me know. I was wondering which cases are covered. So I guess the easiest solution would be to turn it off only while editing those strings.
I think many users never reach this far, I had to disable several extensions to realize what is even at fault for that. Hopefully this bug gets fixed.