Vscode: Tags,Braces,Brackets not auto-closing when inside of quotes.

Created on 25 Apr 2017  Â·  16Comments  Â·  Source: microsoft/vscode

  • VSCode Version: Code 1.11.2 (6eaebe3b9c70406d67c97779468c324a7a95db0e, 2017-04-13T08:03:11.395Z)
  • OS Version: Windows_NT ia32 6.1.7601
  • CPUs: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz (4 x 3092)
  • Memory (System): 15.89GB (4.37GB free)
  • Memory (Process): 123.36MB working set (123.36MB peak, 98.86MB private, 36.91MB shared)
  • Load (avg): 0, 0, 0
  • VM: 0%
  • Initial Startup: no
  • Screen Reader: no
  • Empty Workspace: no
  • Timings:

|Component|Task|Time (ms)|
|---|---|---|
|renderer|window.loadUrl() => begin to require(workbench.main.js)|199|
|renderer|require(workbench.main.js)|787|
|renderer|create extension host => extensions onReady()|818|
|renderer|restore viewlet|1285|
|renderer|restore editor view state|847|
|renderer|overall workbench load|1526|
|main + renderer|start => extensions ready|1860|
|main + renderer|start => workbench ready|2532|


Additional Steps to Reproduce (if any):

  1. Create a pair of quotes single or double, i.e. an attribute.
  2. Attempt to write a pair of brackets or braces, most commonly handlebars, or mustache templates.
  3. When inside the quotes the matching end does not auto complete.

Example :

<div data-some-value='{ "someKey" : "{{ someValue }}" } '>

This part does not autocomplete when I type the opening {{ }} I have to manually type }} and sometimes this can be misleading as other {{ }} pairs are auto closed, so one of two things happen.

  1. I either end up typing an extra }}}} anticipating it not closing or if I depend on vscode to autocomplete it I end up missing the }}
editor-autoclosing feature-request

Most helpful comment

This is happens with ES6 string template literals as well.

All 16 comments

@rwatts3 are you editing .html files? i.e. what language are you using?

The auto-closing brackets use a heuristic where they will auto-close when followed by a space or another auto-closing bracket:

This is just a (programming language agnostic) heuristic and it surely can have some cases where it works unexpectedly. Do you perhaps have a better suggestion for a heuristic?

25314

Typically the file types are handlebars html or swig. At the moment I do not have a suggestion but I can take a close look.

Also I noticed here is the particular use case.

='{ "someKey" : { "foo" : "double braces here" } }'
='{ "someKey" : { "foo" : "{{" } }' // does not autoclose
='{ "someKey" : { "foo" : "{{}}" } }' // expected behavior, autoclose the second pair

This example is relative to handlebars as double braces are used to define the key.
I'm not sure if it's a flaw, but I noticed that the atom text editor autocloses the braces no matter if it's in a string or not. It may not be possible to do this in core, or this may be by design not necessarily a bug, but if there was a way to get around this possibly via some config that would be acceptable as well.

Just checking to see if any ideas have come up regarding this issue.

Also I'm not sure if this would be a feature request, I would think it is a bug.
Seeing as though anywhere in the code the user is expecting the tags to autocomplete, the same behavior is expected in attributes as well. It seems to me that this would be a scoping issue rather than a feature request.

Just checking in to see if this issue is addressed or of there is a plan to address this issue.
I'm using the insiders build and do not see a fix for this problem.

@alexandrudima following the examples you gave above, I would suggest also autoclosing on the " quote character for cases such as a user using template variables within a JSON format. as well as the ' single quote character.

If you could point me into the right direction where this takes place in the code, i'm happy to contribute and submit a PR.

-V/R

Ryan

Is there anyway you can provide me with a general directory to suggest a fix.

@alexandrudima

@rwatts3

That would be:
_isAutoClosingCloseCharType, _runAutoClosingCloseCharType
_isAutoClosingOpenCharType, _runAutoClosingOpenCharType
_isSurroundSelectionType, _runSurroundSelectionType
All invoked from https://github.com/Microsoft/vscode/blob/de99997ab5715de51a1a9903acf46e487e73f7fa/src/vs/editor/common/controller/cursorTypeOperations.ts#L683

Thank you.
On Fri, Sep 22, 2017 at 2:50 AM Alexandru Dima notifications@github.com
wrote:

@rwatts3 https://github.com/rwatts3

That would be:
_isAutoClosingCloseCharType, _runAutoClosingCloseCharType
_isAutoClosingOpenCharType, _runAutoClosingOpenCharType
_isSurroundSelectionType, _runSurroundSelectionType
All invoked from
https://github.com/Microsoft/vscode/blob/de99997ab5715de51a1a9903acf46e487e73f7fa/src/vs/editor/common/controller/cursorTypeOperations.ts#L683

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/25314#issuecomment-331403091,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFFsSX2f1gpneYTPFs-CUQvRuP0F66kkks5sk4LSgaJpZM4NH0mM
.

>

-V/R

Ryan Watts

This is happens with ES6 string template literals as well.

This also happens within Terraform configs, where variable extrapolation is done via

keyword = "${resource_name.instance_name.value}"

It's annoying since the auto complete of resource, instance, and value doesn't happen unless the closing curly bracket is there.

I am running into this as well when working with PHP Template files that are written in FLUID. These are .html files and the code looks like this:

<f:for each="{menuFooter}" as="menuFooter__item" iteration="i">
   <li>
        <a href="{menuFooter__item.link}">{menuFooter__item.title}</a>
    </li>
</f:for>

Everytime the curly brackets are inside " ", I don't get the closing brackets.

It's finally working on release 1.27.1 with a new setting Auto Closing Brackets set to always.

Thank you !

Greatly appreciated.

For those of you that just experienced what I did. If you are just discovering this setting. You have to toggle it to never or any one of the other settings, then toggle it back to always.

After a reload, it should work there after.

Close as fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  Â·  3Comments

villiv picture villiv  Â·  3Comments

philipgiuliani picture philipgiuliani  Â·  3Comments

NikosEfthias picture NikosEfthias  Â·  3Comments

trstringer picture trstringer  Â·  3Comments