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

Enable the folding of binary operations #613

Merged
merged 7 commits into from
Apr 23, 2023

Conversation

Yunuuuu
Copy link
Contributor

@Yunuuuu Yunuuuu commented Apr 20, 2023

Sorry for my bad coding style which may prevent the understanding, In this commit I also tried to add more notes comment.

But the main purpose is to fix REditorSupport/vscode-R#1076

image

Binary operations are collapsed
image

@renkun-ken
Copy link
Member

Thanks for working on this! Would you like to add some test cases to tests/testthat/test-folding.R to reflect the changes?

@Yunuuuu
Copy link
Contributor Author

Yunuuuu commented Apr 23, 2023

This is okay.
image

One uncertain thing: Do you think it's necessary to fold ? opts? I was just want to omit this.
image

@renkun-ken
Copy link
Member

Thanks for the test cases.

As for ?, I think it is ok.

"\\?"
)
binary_opts_regex <- paste0(binary_opts, collapse = "|")
binary_opts_ending_regex <- paste0("^[^#]*(", binary_opts_regex, ")\\s*(#.*)?$")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a small refactoring here to put the regex pre-computed. It is also useful to fix #607 in on-type-formatting. I'll probably put these into utils.R in a later PR so that both folding and on-type-formatting could share this.

Copy link
Member

@renkun-ken renkun-ken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Yunuuuu
Copy link
Contributor Author

Yunuuuu commented Apr 23, 2023

Everything is fine, thanks for the code reviewing

@renkun-ken renkun-ken merged commit 75de9bf into REditorSupport:master Apr 23, 2023
7 checks passed
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 this pull request may close these issues.

[Feature request] Add %>% and + to code fold rules
2 participants