DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.21k stars 23 forks source link

feature request: auto-indent after items inside brackets #435

Open beauxq opened 5 months ago

beauxq commented 5 months ago

This is a feature that both Pycharm and Pylance have, but it is missing from basedpyright in vscodium.

The editor can help follow PEP8 indentation standards when pressing enter inside brackets - () [] {}


(| represents the cursor)

def foo(a, b,|)

If I press enter from this cursor position, this should be the new state after pressing enter:

def foo(a, b,
        |)

current behavior:

def foo(a, b,
|)

The following scenario is currently working correctly. I'm just mentioning it to make sure it doesn't break when someone implements this. (a recommended regression test)

def foo(a, b, {|})

goes to:

def foo(a, b, {
    |
})

^ This behavior should not change. The difference is whether the line ends with an open bracket or not - ( [ { - The line def foo(a, b, does not end with an open bracket (but the line end is inside brackets).

Altonss commented 1 month ago

Just tried this out and the auto-indent issue seems fixed for me. Edit: no it doesn't work, it just worked because I had https://github.com/kbrose/vsc-python-indent installed :)

beauxq commented 1 month ago

it just worked because I had https://github.com/kbrose/vsc-python-indent installed :)

Thank you for this information. I didn't know about this extension. This helps lower the priority of this issue for basedpyright.

DetachHead commented 1 month ago

another workaround is to use a formatter like ruff and configure it to format on-save, which makes issues like this less annoying because they get automatically fixed