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 #274

Merged
merged 2 commits into from Nov 13, 2018

Conversation

Projects
None yet
4 participants
@kylebarron
Copy link
Contributor

kylebarron commented Sep 11, 2018

Description of the Change

Add a value for foldEndPattern in the package settings. This improves the folding behavior for dictionaries, lists, and functions when not using the tree-sitter parser. 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 core 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.

Alternate Designs

The regex is ^\\s*\\}|^\\s*\\]|^\\s*\\) in order to fold the end of dictionaries, lists, and functions/tuples, respectively.

At first thought, it might be desirable to add ^\\s*""" to the regex in order to fold multi-line strings, but since the same characters are used to open a multiline string, this can create bugs. In fact, this used to be the value of foldEndPattern in this package, but was removed upon unintended effects used with Hydrogen.

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. A hacky solution to this was developed (nikitakit/hydrogen-python#10, code) in a Python-specific extension to Hydrogen, but the plugin's use is not widespread among all Hydrogen Python users.

Current Hydrogen behavior with ending character on separate line:
image

New Hydrogen behavior with ending character on separate line:

image

Possible Drawbacks

Those who prefer the current behavior could be disappointed? I can't think of any others.

Applicable Issues

@rgbkrk

rgbkrk approved these changes Sep 12, 2018

@rgbkrk

This comment has been minimized.

Copy link

rgbkrk commented Sep 12, 2018

This would be fantastic for us in nteract's hydrogen @maxbrunsfeld. 🙇 Thank you for all the Atoms.

@kylebarron

This comment has been minimized.

Copy link
Contributor Author

kylebarron commented Sep 21, 2018

Just pinging another maintainer @50Wliu. It would be great if this could be included in the next release of Atom.

@lee-dohm

This comment has been minimized.

Copy link
Member

lee-dohm commented Sep 25, 2018

Would you mind taking a look at this when you get the chance @50Wliu ?

@kylebarron

This comment has been minimized.

Copy link
Contributor Author

kylebarron commented Nov 13, 2018

Just pinging again.

@50Wliu
Copy link
Member

50Wliu left a comment

Just a minor syntactic change to shorten the regex, but otherwise this looks good.

Show resolved Hide resolved settings/language-python.cson Outdated
Update settings/language-python.cson
Co-Authored-By: kylebarron <kylebarron2@gmail.com>

@50Wliu 50Wliu merged commit 56e2f1c into atom:master Nov 13, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@50Wliu

This comment has been minimized.

Copy link
Member

50Wliu commented Nov 13, 2018

Sorry for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.