Handle conflicting multi-char auto closing pairs#110094
Merged
alexdima merged 3 commits intomicrosoft:masterfrom Nov 13, 2020
Merged
Handle conflicting multi-char auto closing pairs#110094alexdima merged 3 commits intomicrosoft:masterfrom
alexdima merged 3 commits intomicrosoft:masterfrom
Conversation
rheh
reviewed
Nov 10, 2020
47d4001 to
ea9be95
Compare
ea9be95 to
d310cba
Compare
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 fixes #72177
When autoclosing multi-character pairs, rather than just adding all of
pair.close, it now only adds the part that hasn't already been autoclosed.It does this by finding the longest pair that is contained in the current pair. It then checks if
subAutoClosingPair.closeis already present (it may not necessarily have just been autoclosed) for all selections, and if so only adds a substring ofpair.closeexcludingsubAutoClosingPair.close.In order to get auto close working when the sub-pair is multiple characters,
_isBeforeClosingBracehad to be updated to work with multi-character pairs.And example of where this is the case is the F# pairs
In the process of updating
_isBeforeClosingBrace, I changed it from excluding symmetric pairs to explicitely returning false for all potential starting braces.I believe the intended purpose of the symmetric pair check was to allow autoclosing before close braces but to not get mixed up when the close brace might actually be an open brace (see #20801).
However, the previous implementation also allowed autoclosing before starting braces if the autoclose brace was also symmetric. This seems contrary to the method name so I'm assuming it was unintentional (or otherwise it should probably be more explicit);
this change required a couple of minor changes to some unit tests.