This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
Enhance auto-closing pairs and auto-surrounding pairs #115
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.
This PR improves on the behaviour of auto-closing pairs and auto-surrounding pairs. These changes follow the rules I developed for my Liquid for Mechanic extension, which I've used extensively for my own work. I've found the enhancements to be quite useful.
Additions to current syntax:
-
whitespace control characters inside of liquid tags[
brackets,<
parentheses,{
braces, and<
angle brackets%
symbol (for wrapping a string into a new tag){{
double bracesCaveats:
{%
, resulting in{%‸%}
, when you hit backspace to delete the%
it will leave the closing%
in place (this is already the case for the current version of this extension). The same goes for the dashes and spaces I've added in this patch.-
whitespace control, and the%
symbol is to define these as single-character auto-closing pairs. However, spaces are far too common of a character, meaning you end up with extra spaces popping up willy-nilly.%
is less common, but it's still common enough that it's confusing if an isolated % symbol gets automatically duplicated. For these reasons, I decided the broken backspace behaviour is preferable.Additional Notes:
{{
and}}
as a pair results in 3 closing braces, due to conflict with the single brace auto-closing rule.%
symbol as an auto-surrounding pair. In my opinion (and experience with the above-mentioned extension), needing to select and replace any text with a%
is so rare that this possibly unintended wrapping behaviour is not disruptive.