Skip to content

Enable the folding of binary operations#613

Merged
renkun-ken merged 7 commits intoREditorSupport:masterfrom
Yunuuuu:binary_folding
Apr 23, 2023
Merged

Enable the folding of binary operations#613
renkun-ken merged 7 commits intoREditorSupport:masterfrom
Yunuuuu:binary_folding

Conversation

@Yunuuuu
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Thanks for the test cases.

As for ?, I think it is ok.

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

@renkun-ken renkun-ken Apr 23, 2023

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
Copy Markdown
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
Copy Markdown
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
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