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

Close parens on indented line #66

Closed tclose closed 4 years ago

tclose commented 4 years ago

Just a matter of taste but I prefer to close parens at the end of the indented line instead of putting them on a new line, i.e.

variable = function(
    |)

instead of


variable = function(
    |
)

It seems like it should be fairly easy to add a config setting to specify this (I could have a crack at it myself although I am not familiar with TS). Would this be desirable?

kbrose commented 4 years ago

Hey @tclose, thanks for submitting an issue.

Right now the code makes no distinction between function calls and other kinds of brackets (()[]{} are all treated the same). Would you be ok with the setting also changing the following behavior?

variable = [|]
# goes to...
variable = [
    |]
kbrose commented 4 years ago

This is actually related to #65 I think. If such an option were added, then we'd have to do more parsing to figure out if we were in the middle of an indent-increasing section so that we could add an extra level of indentation per PEP8. Examples adapted from PEP8:

# Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest
# (the next set of lines will be at a higher level of indentation).
def long_function_name(
        var_one, var_two, var_three,
        var_four):
    print(var_one)

# Do NOT add 4 extra spaces
# (the next set of lines will be at the same level of indentation).
foo = long_function_name(
    var_one, var_two,
    var_three, var_four)

# Relatedly, I think we'd want to do similar behavior for things like "if"
if (
        x in my_first_list_maker(arg1, arg2)
        + my_second_list_maker(arg3, arg4)):
    print(x)
tclose commented 4 years ago

Re your first comment, yes, that would be my preference.

Re #65, I would consider them separate issues personally. Solving #65 would be nice, but isn't a big deal to my mind as you just need to enter another tab when starting to define the function arguments.

kbrose commented 4 years ago

Hi @tclose, there is a new option (keepHangingBracketOnLine) available in v1.11.0 of the extension for this behavior. Please note that I bumped the required version of VSCode to the most recent, so you'll have to be on an up-to-date VSCode to update the extension.

If you have problems, please submit a new issue.

tclose commented 4 years ago

Thanks!

On Wed, 26 Aug 2020 at 14:39, Kevin Rose notifications@github.com wrote:

Hi @tclose https://github.com/tclose, there is a new option ( keepHangingBracketOnLine) available in v1.11.0 of the extension for this behavior. Please note that I bumped the required version of VSCode to the most recent, so you'll have to be on an up-to-date VSCode to update the extension.

If you have problems, please submit a new issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kbrose/vsc-python-indent/issues/66#issuecomment-680600020, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIBRFTQ6MXD7MXDTQXBNB3SCSGXHANCNFSM4P5X77QA .

-- THOMAS G. CLOSE, PHD Imaging Informatics Officer

Monash Biomedical Imaging Monash University Room 139, 770 Blackburn Rd Clayton Campus, Clayton VIC 3800 Australia

T: +61 3 9902 9804 M: +61 491 141 390 E: tom.close@monash.edu mbi.monash.edu.au

jkyeung commented 1 year ago

I cannot believe I am just discovering this setting now (because I've been using the extension pretty much since inception). But thank you! It's a game-changer for me.