microsoft / vscode

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

Formating does not work in snippets #195448

Closed salos1982 closed 11 months ago

salos1982 commented 1 year ago

Type: Bug

1) Add following snippet

"test": {
  "prefix": "// test",
  "body": [
      $1 ${1/(.*)/${1:/upcase}/}"
  ]
}

2) try to apply this snippet to code and type asdf

Expected: should be added line asdf ASDF

Result: asdf asdf

VS Code version: Code 1.83.1 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 2023-10-10T23:48:05.904Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-13700H (20 x 2918)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.71GB (11.67GB free)| |Process Argv|--crash-reporter-id 2d4b3ddd-934e-410e-9bad-4e7718ad7c7a| |Screen Reader|no| |VM|0%|
Extensions (19) Extension|Author (truncated)|Version ---|---|--- tsl-problem-matcher|amo|0.6.2 npm-intellisense|chr|1.4.5 vscode-eslint|dba|2.4.2 gitlens|eam|14.3.0 vscode-jest-runner|fir|0.4.67 remotehub|Git|0.62.0 vscode-github-actions|git|0.26.2 vscode-pull-request-github|Git|0.74.0 gc-excelviewer|Gra|4.2.58 vscode-graphql|Gra|0.8.19 vscode-graphql-syntax|Gra|1.2.2 vscode-docker|ms-|1.26.1 remote-containers|ms-|0.318.0 remote-wsl|ms-|0.81.8 remote-repositories|ms-|0.40.0 postman-for-vscode|Pos|0.11.0 vscode-yaml|red|1.14.0 modulegenerator|Ser|1.1.4 markdown-all-in-one|yzh|3.5.1
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 py29gd2263cf:30856253 vscaat:30438848 vsclangdc:30486549 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 f6dab269:30613381 vscrpc:30673769 a9j8j154:30646983 showlangstatbar:30737416 03d35959:30757346 24365598:30736109 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 copilotsettingc:30839828 dsvsc013:30795093 dsvsc014:30804076 diffeditorv1:30821571 dsvsc015:30845448 ```
jrieken commented 1 year ago

Transform will only happen when you navigate to the tab stop, it's not live as you type. @salos1982 is that what you are missing?

salos1982 commented 1 year ago

Yes, I understand. It makes snippets less functional. It is not convenient to add some common snippets e.g.

async createMyObject(myObject: MyObjectData): Promise<string> {
  return this.repository.createMyObject(myObject);
}

where myObject is placeholder

vscodenpa commented 11 months ago

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!