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

Addins not working if the cursor is inside a function #2

Open
PMassicotte opened this issue Jan 23, 2021 · 2 comments
Open

Addins not working if the cursor is inside a function #2

PMassicotte opened this issue Jan 23, 2021 · 2 comments

Comments

@PMassicotte
Copy link

First, thank you for this. It is really useful!

I was wondering if it would be difficult to make it work when the cursor is within a function. For example, using your example, I can place the cursor after mass = mean(mass, na.rm = TRUE) and press ALT-ENTER and all the code within the chain will be executed. However, it will fail if I try to run the brakerofchains addins.

Peek 2021-01-23 10-29

@PMassicotte PMassicotte changed the title Addins not working if inside a function Addins not working if the cursor is inside a function Jan 23, 2021
@MilesMcBain
Copy link
Owner

Yeah this doesn't work right now because it literally does what it says: Break chain, and run from start down. So when it sends your example to the console it's missing the closing bracket needed for summarise. To get this to work you'd need to drop your cursor down one line to include the bracket: ) %>%

It would be possible to do what you want but a little more involved. I'd have to search downward for the end of the enclosing scope and then upward for the start of the chain.

I am not sure if this behaviour would be expected or end up being kind of weird in practice. For example say you move your cursor up one line. Do you expect it to run the summarise with just height and no mass? Or do you expect it to include all columns until the end of the summarise call?

@PMassicotte
Copy link
Author

Hi @MilesMcBain, thank you for the reply.

I would expect the second option. In this example, no matter if the cursor is on height or mass, everything within the summarise() would be executed. That is just an idea, no problem if you think it should not be the default behaviour.

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