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

Add foldEndPattern to settings to improve folding and Hydrogen selections #163

Merged
merged 1 commit into from
Sep 13, 2018

Conversation

kylebarron
Copy link
Contributor

(I sent similar PRs to the language-python atom/language-python#274, and MagicPython MagicStack/MagicPython#161 syntax highlighters)

Note: I don't understand Julia's syntax too well, so the exact regular expression used in foldEndPattern is subject to debate. Regardless, this addition would serve Hydrogen+IJulia users.

Description of the Change

Add a value for foldEndPattern in the package settings. The regex used is ^\\s*\\]|^\\s*\\) in order to fold the end of arrays and functions. It folds the entire logical syntax item instead of leaving the ending character on a separate line. It also improves the use of Hydrogen when the ending ), or ] is on a separate line and not indented.

Many other Atom language grammars have a foldEndPattern; the regex used in this PR is taken from language-javascript because of the similarity in syntax used for data structures.

Benefits

  1. Improve fold behavior by including the ending character (see screenshots below)

Expanded:
image

Current fold behavior:
image

New fold behavior:
image

  1. This would also improve behavior with the Hydrogen package, as that uses Atom's fold regions to decide what block of code to send to the Jupyter kernel. (Currently you have to manually select the entire block in these cases).

Current Hydrogen behavior with ending character on separate line:
peek 2018-09-12 16-31

New Hydrogen behavior with ending character on separate line:
peek 2018-09-12 16-32

Applicable Issues

These issues refer to Python, but the same behavior exists when using IJulia.

@kylebarron
Copy link
Contributor Author

Since Julia uses end to delimit the end of function definitions, it might be helpful to add ^\\s*end to the regex as well.

@pfitzseb
Copy link
Collaborator

Huh, interesting, I didn't even know this setting existed. Thanks for the PR!

I'll go ahead with merging this and will iterate on it in a future PR.

@pfitzseb pfitzseb merged commit 4798a68 into JuliaEditorSupport:master Sep 13, 2018
@kylebarron
Copy link
Contributor Author

Yeah, I only discovered it when I was trying to debug why JavaScript in hydrogen ran blocks more accurately than Python. And I discovered it was because of this setting.

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.

2 participants