Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoClosingPairs are too aggressive #51047

Closed
kAlvaro opened this issue Jun 3, 2018 · 12 comments
Closed

autoClosingPairs are too aggressive #51047

kAlvaro opened this issue Jun 3, 2018 · 12 comments
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-autoclosing Editor automatic closing of parens / brackets / etc. feature-request Request for new features or functionality
Milestone

Comments

@kAlvaro
Copy link

kAlvaro commented Jun 3, 2018

Issue Type: Feature Request

No matter the context, as soon as you type /** you immediately get /**𝖨 */ (where 𝖨 is the cursor). If you didn't intend to start a docblock you need to remove the straneous */. Tested in JavaScript and PHP, with and without extensions.

I'd appreciate these two enhancements:

  • Expand to docblock only after /**<space> or /**<enter>.
  • Make the overall feature context sensitive (you probably don't want a docblock inside a string literal or a comment).

VS Code version: Code 1.23.1 (d0182c3, 2018-05-10T17:11:17.614Z)
OS version: Windows_NT x64 10.0.17134

@vscodebot vscodebot bot added editor editor-contrib Editor collection of extras labels Jun 3, 2018
@vscodebot
Copy link

vscodebot bot commented Jun 3, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@octref octref removed editor editor-contrib Editor collection of extras labels Jun 4, 2018
@octref octref added the feature-request Request for new features or functionality label Jun 4, 2018
@aeschli
Copy link
Contributor

aeschli commented Jun 4, 2018

Each language can configure its autoClosingPairs, so please file separate issues against each language.
IMO we want a way to configure this in the user settings and also have a way to quickly remove the closing brackets/tokens without removing the initially type characters

@aeschli aeschli changed the title Docblock auto-completion is too aggresive autoClosingPairs are too aggressive Jun 4, 2018
@aeschli aeschli assigned rebornix and unassigned aeschli Jun 4, 2018
@rebornix rebornix added this to the Backlog milestone Jun 4, 2018
@kAlvaro
Copy link
Author

kAlvaro commented Jun 5, 2018

I've filed issues for the individual languages. I've also realised that in certain contexts (such as flow control structures or string literals) you get a pop-up suggestion but it doesn't get expanded automatically (sorry for not being precise about that).

@roblourens
Copy link
Member

Make the overall feature context sensitive (you probably don't want a docblock inside a string literal or a comment).

That should already be the case for strings, not for comments apparently (maybe we should add that one)

@aeschli If I type ( and get (), then press backspace, the autoclosing ) is removed too. Maybe the same should happen for /** too?

IMO we want a way to configure this in the user settings

Sorry, configure what?

@aeschli
Copy link
Contributor

aeschli commented Jun 6, 2018

Maybe the same should happen for /** too?

Good idea, that would help!

Sorry, configure what?

Currently, only extensions can define the language configuratuon.
But any users want to custmize these or even turn off the autoClosingPairs.
It would be great if we would also allow somthing like that

"[html]": {
    "editor.autoClosingPairs": [
         { "open": "{", "close": "}"},
         { "open": "'", "close": "'" },
         { "open": "<!--", "close": "-->", "notIn": [ "comment", "string" ]}
     ]
}

That's also very interesting for the other language configurations such as folding: #36002

@roblourens
Copy link
Member

Oh got it. Yes that would be cool.

@roblourens
Copy link
Member

I realized that if I set /** to not autoclose in "comment", then it never autocloses at all. I guess because once you type /* you are in a comment scope, so /** won't autoclose.

Is it possible to support that? Should I file another feature request for it?

It was requested to use /** (with a space) but I'm not sure about that. I'd rather let users configure that with this setting if they prefer. So is there anything PHP specific that we can do right now?

@kAlvaro
Copy link
Author

kAlvaro commented Jun 7, 2018

It was requested to use /** (with a space) but I'm not sure about that.

… or Enter. That's how it works in JetBrains IDEs, Eclipse, NetBeans IDE and Komodo IDE (though the triggered feature in those tools is actually a full docblock creation, together with params and return).

@aeschli
Copy link
Contributor

aeschli commented Jun 29, 2018

The request to make autoClosingPairs configurable is #38352.
#50087 is similar request

@kAlvaro
Copy link
Author

kAlvaro commented Jul 12, 2018

As workaround, I've created a custom code snippet:

"/**/": {
    "prefix": "/**/",
    "body": "/**/",
    "description": "Workaround to be able to type /**/"
}

I only need to be careful and type / + Enter (or / and Tab) but once you get used to it it's actually a time saver.

@rebornix rebornix removed their assignment Sep 4, 2018
@kAlvaro
Copy link
Author

kAlvaro commented Jul 10, 2019

A better workaround (though it implies fiddling with application files and needs to be reapplied on each upgrade) can be found at Proposal: Ability not to auto-close comments.

@jrieken jrieken added the editor-autoclosing Editor automatic closing of parens / brackets / etc. label Oct 9, 2019
@alexdima
Copy link
Member

Let's track in #38352

@alexdima alexdima added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 16, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-autoclosing Editor automatic closing of parens / brackets / etc. feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

7 participants