Skip to content

Function arguments within R6 classes misaligned #541

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

Closed
michaelquinn32 opened this issue Sep 10, 2019 · 5 comments · Fixed by #546
Closed

Function arguments within R6 classes misaligned #541

michaelquinn32 opened this issue Sep 10, 2019 · 5 comments · Fixed by #546

Comments

@michaelquinn32
Copy link
Contributor

Correctly formatted R6 classes have misaligned function arguments after applying styler.

styler::style_text('
  MyClass <- R6::R6Class(
    "MyClass",
    public = list(initialize = function(my_arg,
                                        my_named_arg = 1) {
        return(invisible())
      }
    ),
  )
')
#> MyClass <- R6::R6Class(
#>   "MyClass",
#>   public = list(initialize = function(my_arg,
#>                                         my_named_arg = 1) {
#>     return(invisible())
#>   }),
#> )

This seems related to #254 and #258, but it seems useful to explicitly track this separately.

@lorenzwalthert
Copy link
Collaborator

Thanks. I agree the other issues are (quite) different, so it's good to track this separately. I remember similar issues with function headers but can't find them now.

@lorenzwalthert
Copy link
Collaborator

One solution is to remove line breaks after = (EQ_FORMALS) in any case

# before
function(x = 
    3, 
  v) NULL

# after
function(x = 3, v) NULL

This would simplify things quite a bit, although it's not the nicest solution.

@lorenzwalthert
Copy link
Collaborator

@michaelquinn32 I think I found a way to fix the bug. Do you want to test and see if it works in general? You can install this branch here:

remotes::install_github("lorenzwalthert/styler@no-linebreak-with-eq-formals")

@michaelquinn32
Copy link
Contributor Author

That looks a lot better! Thank you!

@michaelquinn32
Copy link
Contributor Author

This has an effect that relates to another issue in function signatures. I opened #549 to address those.

Thank you for the responsiveness and patience will all of these issues!

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

Successfully merging a pull request may close this issue.

2 participants