This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 fromlanguage-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 offoldEndPattern
in this package, but was removed upon unintended effects used with Hydrogen.Benefits
Expanded:
![image](https://user-images.githubusercontent.com/15164633/45392246-71299b80-b5f4-11e8-9f23-364da0a26b8c.png)
Current fold behavior:
![image](https://user-images.githubusercontent.com/15164633/45392284-a8984800-b5f4-11e8-8484-f91897382c85.png)
New fold behavior:
![image](https://user-images.githubusercontent.com/15164633/45392258-81417b00-b5f4-11e8-996f-71efdf30a178.png)
Current Hydrogen behavior with ending character on separate line:
![image](https://user-images.githubusercontent.com/15164633/45392861-4260f480-b5f7-11e8-9120-ba292bcd707e.png)
New Hydrogen behavior with ending character on separate line:
Possible Drawbacks
Those who prefer the current behavior could be disappointed? I can't think of any others.
Applicable Issues