Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close parens on indented line #66

Closed
tclose opened this issue Aug 13, 2020 · 6 comments · Fixed by #68
Closed

Close parens on indented line #66

tclose opened this issue Aug 13, 2020 · 6 comments · Fixed by #68

Comments

@tclose
Copy link

tclose commented Aug 13, 2020

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
Copy link
Owner

kbrose commented Aug 25, 2020

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
Copy link
Owner

kbrose commented Aug 25, 2020

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
Copy link
Author

tclose commented Aug 25, 2020

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
Copy link
Owner

kbrose commented Aug 26, 2020

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
Copy link
Author

tclose commented Aug 26, 2020 via email

@jkyeung
Copy link

jkyeung commented Sep 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants