microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.47k stars 28.1k forks source link

bracket not closing properly #78902

Closed aragami-xd closed 4 years ago

aragami-xd commented 4 years ago

Issue Type: Bug

Can't really reliably reproduce the bug since it happens pretty randomly When '(' is pressed, another ')' is automatically created. However, when press the ')' to exit, it create another ')'. e.g. expected: while() - get: while())

VS Code version: Code 1.37.0 (036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8, 2019-08-08T02:33:50.993Z) OS version: Windows_NT x64 10.0.17763

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (8 x 1800)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.78GB (8.60GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (5) Extension|Author (truncated)|Version ---|---|--- nand2tetris|lea|1.1.1 python|ms-|2019.8.29288 remote-wsl|ms-|0.39.2 material-icon-theme|PKi|3.8.1 ayu|tea|0.18.0 (1 theme extensions excluded)
gjsjohnmurray commented 4 years ago

https://github.com/microsoft/vscode/issues/37315#issuecomment-515200477 describes a change that I think just landed in 1.37. Does it explain what you are seeing?

usernamehw commented 4 years ago

Possible duplicate of #78833

alexdima commented 4 years ago

@rogueXD What programming language are you using? Starting with 1.37, the editor will overtype only those brackets that it introduced by itself. What steps are you taking, I wonder if you are running into a corner case?

aragami-xd commented 4 years ago

I'm writing in c++

I'm not really sure if that's the same as the overtyping thing you've mentioned though, for example: I usually type 'for' and '(', which will then automatically create a closing bracket ')': for() When i got to the end of the condition and type the close bracket ')' again, it used to overtype that close bracket and get a normal for loop: for(...) But now it creates another close bracket, so i get for(...))

Not sure if this is clear enough for not. It doesn't happen all the time though, but it's often enough for me to think that it can be an issue

alexdima commented 4 years ago

@rogueXD Thank you for following up. I am looking to find a specific repro. For me, the ) does get overtyped:

Kapture 2019-08-12 at 15 33 30

The ) will not be overtyped twice or if you move the cursor outside of the ( ... ) area or if you press Enter. e.g.

(overtyped already) Kapture 2019-08-12 at 15 35 12

(left the area) Kapture 2019-08-12 at 15 36 44

I would like to polish the way this works and I'm trying to find out from you when do you find that overtyping is not behaving...

aragami-xd commented 4 years ago

I guess that might have been the case since i couldn't reproduce it without moving the cursor around. I'll see if that the only behavior that i'm getting and i'll follow up with another comment, otherwise i'll close this issue

alexdima commented 4 years ago

Thanks!

haymez commented 4 years ago

@alexandrudima Is there an existing feature request for a setting that allows us to control the new behavior of closing tags? I've grown quite used to the previous experience where vscode always swallowed closing tags. I realize the new behavior was heavily requested but it seems like there was definitely a sizable group of people who preferred things the way they were.

kylebake commented 4 years ago

This has been driving me crazy all morning, glad to see it wasn't just me. In Java, typing my service name and letting the autocomplete fill in the method call will ensure that the closing paren is never jumped over, whereas before this would be the case.

I've had similar things happening in Typescript, but they seem to happen more intermittently. Not sure why, but Typescript used to also be able to infer when I was calling a function/method and insert the parens on autocomplete, but it doesn't anymore. Not sure if it's related to this.

Can we at least get a setting for this?

gjsjohnmurray commented 4 years ago

78975 identifies an issue with parens that are supplied by autocomplete.

gjsjohnmurray commented 4 years ago

@alexandrudima Is there an existing feature request for a setting that allows us to control the new behavior of closing tags?

78833

alexdima commented 4 years ago

Let's continue tracking the option to provide the old behavior in #78833

In the meantime @rogueXD please reopen if you spot some kind of corner case.