microsoft / vscode

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

snippet transformation doesn't capitalize variables #203507

Closed billgan1024 closed 9 months ago

billgan1024 commented 9 months ago

Type: Bug

Consider this HLSL snippet "var": { "prefix": "var", "body": "$1 $2 : ${2/(.*)/${2:/upcase}/}" }

it doesn't capitalize $2

https://github.com/microsoft/vscode/assets/17630457/cc0e6b7f-613e-4b90-b771-fce7a3bd43ec

However, switching the order of the numbers works

"var": {
    "prefix": "var",
    "body": "$2 $1 : ${1/(.*)/${1:/upcase}/}"
}

https://github.com/microsoft/vscode/assets/17630457/7f605147-07c7-453b-a429-cc64fcea66f8

VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|12th Gen Intel(R) Core(TM) i9-12900K (24 x 3187)| |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)|63.75GB (47.02GB free)| |Process Argv|--crash-reporter-id 39a0b04b-eb9b-40e9-be5a-df63ccc863bd| |Screen Reader|no| |VM|0%|
Extensions (32) Extension|Author (truncated)|Version ---|---|--- language-x86-64-assembly|13x|3.1.4 gitignore|cod|0.9.0 gitlens|eam|14.7.0 prettier-vscode|esb|10.1.0 html-preview-vscode|geo|0.2.5 copilot|Git|1.155.0 copilot-chat|Git|0.11.1 cmake-language-support-vscode|jos|0.0.9 google-search|kam|0.0.1 vscode-dotnet-runtime|ms-|2.0.1 autopep8|ms-|2023.8.0 python|ms-|2023.22.1 vscode-pylance|ms-|2023.12.1 cmake-tools|ms-|1.16.32 cpptools|ms-|1.18.5 hexeditor|ms-|1.9.12 powershell|ms-|2024.0.0 batch-runner|Nil|1.2.0 asmformat|not|1.0.0 typst-lsp|nva|0.12.1 material-icon-theme|PKi|4.33.0 vscode-xml|red|0.26.1 shader|sle|1.1.5 vscode-zipexplorer|sle|0.3.1 vscode-autohotkey2-lsp|thq|2.3.1 hlsltools|Tim|1.1.303 pdf|tom|1.2.2 cmake|twx|0.0.17 hlsl|und|0.0.1 keyoti-changeallendoflinesequence|vs-|0.0.3 vim|vsc|1.27.2 vscode-autohotkey-debug|zer|1.11.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30933248 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 pythontbext0:30879054 accentitlementsc:30887149 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 ```
vscodenpa commented 9 months ago

We closed this issue because it is a question about using VS Code rather than an issue or feature request. Please search for help on StackOverflow, where the community has already answered thousands of similar questions. You may find their guide on asking a new question helpful if your question has not already been asked. See also our issue reporting guidelines.

Happy Coding!

jrieken commented 9 months ago

owever, switching the order of the numbers works

The number that precedes that transform doesn't relate to snippet tabstop but to the matching groups of your regex. That why 1 works, and not 2