TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Visual Studio: Support "Automatic brace completion"

Open catvec opened this issue 11 years ago • 38 comments

In Visual Studio if you go into the options for TypeScript(Tools > Options > Text Editor > TypeScript > General) the "Automatic brace completion" option is grayed out.

Automatic brace completion options grayed out

I was wondering why this is and if there is any way to turn this on.

Visual Studio Version: Visual Studio Express 2013 for Web v12.0.31101.00 Update 4
OS: *Windows 8.1

catvec avatar Dec 15 '14 01:12 catvec

We don't currently support this feature in visual studio. It is on our backlog though.

CyrusNajmabadi avatar Dec 15 '14 01:12 CyrusNajmabadi

@CyrusNajmabadi May I ask why? At least with my limited knowledge it seams that the brace completion would be similar to JavaScript's brace completion.

However I imagine there is probably a very good reason why it is not enabled

catvec avatar Dec 15 '14 03:12 catvec

It was simply a matter of schedule and resources. Features are never really free, and this one simply hasn't made the cut so far. One issue is that this is a synchronous blocking feature that depends on needing to properly syntactically understand your code. Right now there are some limitations in our architecture that makes that hard. We could provide support for this, but its likely the performance would not be good enough and t the experience could feel chunky in large files.

Until we can provide the feature with great performance, I'm holding off on this.

Fortunately, we're making several architectural improvements that should make this more feasible in the next year.

CyrusNajmabadi avatar Dec 15 '14 04:12 CyrusNajmabadi

Any updates on this?

nheinbaugh avatar Jun 03 '15 03:06 nheinbaugh

This is still on our backlog at the moment.

mhegazy avatar Jun 03 '15 06:06 mhegazy

I need this feature wow.

yalexx avatar Jun 05 '15 23:06 yalexx

+1

DmitryEfimenko avatar Jul 27 '15 17:07 DmitryEfimenko

+1

gabguy avatar Sep 05 '15 08:09 gabguy

Tho resharper adds the feature, I would preffer using vanilla studio when using pure JS code. +1

ghost avatar Sep 23 '15 19:09 ghost

+1

IntermittentlyRupert avatar Sep 28 '15 23:09 IntermittentlyRupert

For those talking about resharper, could you let me know what they do with something like this:

var foo = 0;
var v = foo<

as well as

function foo<T>(t: T) { }
var v = foo<

In the first example, you should not get automatic completion as you are typing an arithmetic expression. in the latter, you should, because you're typing generic type arguments.

However, to do this properly, you need both your syntax tree up to date, and you need your semantics to be accurate as well (so you can tell what 'foo' means). Getting that correct is easy. Getting it correct and fast is very very hard. And this feature needs to be fast as it interacts with typing in a blocking fashion.

Of course, we could just not have auto-completion on <. However, even for the other cases, i.e.:

  1. /
  2. "
  3. '
  4. (
  5. {
  6. [

We'd still need fairly accurate syntactic understanding of your file to ensure that we didn't, for example, autocomplete these guys inside a comment or a string.

@mhegazy If you did this, i'd actually recommend a dedicated thread just for this feature. Because it needs to be synchronous, but is also involved with typing it really needs to be uninterrupted when it runs. If you avoid completion on < then you don't need semantics and you can just have another syntactic thread.

CyrusNajmabadi avatar Sep 29 '15 14:09 CyrusNajmabadi

@mhegazy If you did this, i'd actually recommend a dedicated thread just for this feature. Because it needs to be synchronous, but is also involved with typing it really needs to be uninterrupted when it runs. If you avoid completion on < then you don't need semantics and you can just have another syntactic thread.

how about using the formatting thread? all these trigger characters are not formatting trigger characters, so we know the thread will be likely idle.

mhegazy avatar Sep 29 '15 16:09 mhegazy

@mhegazy Ah, I think you're right. None of the characters should overlap. And because they're all synchronous, we'll essentially only ever have one in the queue at a time, so we don't have to worry about bottlenecks. So that thread should be a good choice here.

CyrusNajmabadi avatar Sep 29 '15 19:09 CyrusNajmabadi

Many requests for this feature are coming from folks who use text editors that have nowhere near enough understanding of the code to be 100% correct in their completion behavior. Let's not let the perfect be the enemy of the good.

In Sublime < is not completed. Most of the others characters are completed in any non-string context. The closing element is skipped over when you type the closing element. It's immensely useful and the kind of feature that seems like a 'nice to have' for those who aren't used to it but an actual adoption blocker for people who are used to it. bracecompletion

danquirk avatar Sep 29 '15 21:09 danquirk

See https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/95

Let's not let the perfect be the enemy of the good.

Agreed. I think we can just forget about < for now.

DanielRosenwasser avatar Sep 29 '15 21:09 DanielRosenwasser

This is really a great feature, nice to have it. It could improvement productivity.

jimior2 avatar Oct 14 '15 04:10 jimior2

As I install visual studio code, and vs code have typescript auto brace, why didn't VS2015 didin't have...

image

jimior2 avatar Oct 27 '15 01:10 jimior2

+1 Any update on this issue? it's a little annoying having to close every brace manually

jonathansotoan avatar Mar 02 '16 03:03 jonathansotoan

+1 But guys please don't shout like "I pay money give me what I want". Still a young product, many features are requested...

CBuntrock avatar Mar 05 '16 00:03 CBuntrock

+1

arangil avatar Mar 10 '16 16:03 arangil