kbrose / vsc-python-indent

Correctly indent python code on the fly, in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=KevinRose.vsc-python-indent
MIT License
82 stars 19 forks source link

Enter when in a if-line #85

Open PsywolfTheEnder opened 3 years ago

PsywolfTheEnder commented 3 years ago

Let's us enter in a code line like Pycharm IDE It's should be looks like the right side of the image

Capture

kbrose commented 3 years ago

Hello @PsywolfTheEnder, thank you for opening the issue. I think this is also related to https://github.com/kbrose/vsc-python-indent/issues/65.

I'd probably accept an MR that accomplishes this, but I'm sorry to say I likely won't be putting in the effort to accomplish this. Here's my understanding of what would have to change, for what it's worth:

  1. The handling of backslash continuations (which is missing from the left-hand image by the way) currently blindly indents the next line. See backlash detection and handling of partial indentations. This would have to be updated to know that it's the continuation of a specific kind of line (an if, def, else, etc. line) -- some sort of double-indent line?
  2. The handling of if/def/else/etc. keywords also relies on the detection of a colon, and then indents the next line accordingly with special handling to know that if a colon occurs after a closing bracket, then the indentation level should be relative to wherever the bracket was opened.