Skip to content

comments and line-breaks #89

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
lorenzwalthert opened this issue Jul 25, 2017 · 2 comments
Closed

comments and line-breaks #89

lorenzwalthert opened this issue Jul 25, 2017 · 2 comments

Comments

@lorenzwalthert
Copy link
Collaborator

lorenzwalthert commented Jul 25, 2017

Comments will currently not be moved to the end of a line if we change line breaks.

a <- function(x) # 
{
  x + 1
}

becomes

a <- function(x) # {
  x + 1
}

Which is really not what we want 😩. I think we talked about this case @krlmlr, but I just forgot about it.

@lorenzwalthert
Copy link
Collaborator Author

Any ideas how to solve that? Maybe we can use the pre_visitor to move the comment into the next child (top position) if there is no line break after the comment and then deal with it once we get to the child?

@krlmlr
Copy link
Member

krlmlr commented Jul 25, 2017

I'm fine with just leaving the code as is, i.e. don't strip newlines if the preceding token is a comment.

lorenzwalthert added a commit to lorenzwalthert/styler that referenced this issue Jul 27, 2017
Don't remove line break if token before "'{'" is a comment. Closes r-lib#89
lorenzwalthert added a commit to lorenzwalthert/styler that referenced this issue Jul 27, 2017
Don't remove line break if token before "'{'" is a comment. Closes r-lib#89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants