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

Suggestion: execute to next pipe, not to current line (if the former is further down) #16

Open
jzadra opened this issue Feb 2, 2022 · 1 comment

Comments

@jzadra
Copy link

jzadra commented Feb 2, 2022

With the following code:

diamonds %>% 
  mutate(cut = str_to_lower(cut) %>% 
           str_replace_all(" ", "_")) %>% 
  mutate(xy = x + y)

Using the breaker at line two produces an error because there is a nested chain. It would be great if the function instead looked for the next top level pipe and executed to there (ie line 3).

Alternatively, and perhaps this is up for discussion, it could execute to line two but do so as if that was a complete statement, ie close the parenthesis to get back to the top level and execute, giving the same result as this:

diamonds %>% 
  mutate(cut = str_to_lower(cut))
@MilesMcBain
Copy link
Owner

For part 2, I don't think closing expressions is a good idea. Might be hard to do reliably and would give weird errors on edge cases.

Part 1 is something I would like and have thought about a bit. At the moment the search only looks upward. Last time I thought about this, the feature seemed kind of antagonistic against working with nested chains. Nested chains do work, but they often fail if there's a trailing comma, so the trade-off hasn't paid well.

I'll have a new look at it!

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

No branches or pull requests

2 participants