Skip to content

Option for auto closing comments#75053

Closed
sergeyvfx wants to merge 4 commits into
microsoft:mainfrom
sergeyvfx:wip_auto_closing_comments
Closed

Option for auto closing comments#75053
sergeyvfx wants to merge 4 commits into
microsoft:mainfrom
sergeyvfx:wip_auto_closing_comments

Conversation

@sergeyvfx

Copy link
Copy Markdown
Contributor

This is an implementation of feature requested in #1966.

The option itself was added in a complete inspiration of autoClosingBraces and autoClosingQuotes and it's in a separate commit to ease review of actual feature implementation.

Not entirely happy with the logic implementation, but there is already quite convoluted interaction between checks in _isAutoClosingOpenCharType and _typeInterceptorElectricChar.

Wend with a way which minimizes amount of changes between those two.

The biggest challenge fitting this new functionality into existing _isAutoClosing* functions is that they are currently designed to work with a single character pairs. While it's possible to make them aware of multi-character ones, it is still seems changes to _typeInterceptorElectricChar() are needed. And this is where some entanglement begins.

Really looking forward having feedback from a core developers to find solution which fits design in a best possible way.

Has same strategies as autoClosingBrackets and autoClosingQuotes.

This commit does not have any functional changes, just a preparation
for an actual logic.
@msftclas

msftclas commented Jun 7, 2019

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

The tricky part comparing to those existing flags is that their
behavior is defined by a single character, which is how
_isAutoClosingOpenCharType() works. The comments, on another hand,
can consists of multiple characters and they do not fit existing
auto-closing filtering.

To avoid duplication of tokenizing, the decision on whether to place
closing comment or not is based on the electric action which now stored
corresponding token which generated new text.

This allows to filter electric actions in cursor type operations.

Similar to opening/closing pairs the opening/closing comment blocks
are stores in a character map.

Could be a bit overkill, but could as well be more flexible in case
language configuration supports multiple opening/closing comment
blocks (not sure if it is already supported, but in Pascal it is
possible to use { and (* for block comments).

P.S. There might be a trick to fit this logic into existing
isAutoClosing functionality. It does perform tokenization at certain
conditions, but the early output checks and checks for auto-closing
pairs would need to be changed somehow. And is still needed to know
whether typing sequencer is a quote, comment or a brace.
Probably, can check if it's a quote or a brace and consider a
comment otherwise, but seems a bit weak.
@sergeyvfx
sergeyvfx force-pushed the wip_auto_closing_comments branch from 430bf79 to b8b402f Compare June 8, 2019 13:09
@rebornix rebornix added editor-autoclosing Editor automatic closing of parens / brackets / etc. feature-request Request for new features or functionality labels Oct 8, 2020
@joaomoreno
joaomoreno changed the base branch from master to main February 15, 2021 08:51
@alexdima alexdima assigned alexdima and unassigned rebornix Oct 15, 2021
@alexdima alexdima removed the feature-request Request for new features or functionality label Oct 27, 2021
@alexdima
alexdima self-requested a review November 16, 2022 13:36
@alexdima

alexdima commented Sep 6, 2023

Copy link
Copy Markdown
Member

Continued in #192335

@alexdima alexdima closed this Sep 6, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

editor-autoclosing Editor automatic closing of parens / brackets / etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants