This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Add foldEndPattern to settings #274
Merged
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:

Current fold behavior:

New fold behavior:

Current Hydrogen behavior with ending character on separate line:

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