microsoft / vscode

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

HTML server showing duplicate snippets #124268

Closed a11smiles closed 2 years ago

a11smiles commented 3 years ago

Issue Type: Bug

This appears to be a continuation of #388 where snippet suggestions are showing twice in HTML files.

Here's my .code-snippets:

{
    "_LocalSettings": {
        "prefix": "_LocalSettings",
        "body": [
            "\"LocalConfig\": {",
            "    \"FromWhere\": \"App Settings\",",
            "    \"ToWhom\": \"Local Developer\"",
            "  },",
            "\"Environment\": \"Local\","
        ],
        "description": "_LocalSettings"
    },
    "_Index": {
        "prefix": "_Index",
        "body": [
            "@page",
            "@using Microsoft.Extensions.Options",
            "@using AppConfigDemo.Core",
            "@model IndexModel",
            "@{",
            "    ViewData[\"Title\"] = \"Home page\";",
            "}",
            "@inject IOptions<AppSettings> AppSettings",
            "",
            "",
            "<div class=\"text-left\">",
            "    <h2 class=\"display-5 pt-5\">App Settings (Configuration)</h2>",
            "    <p>Hello <code>@AppSettings.Value.ToWhom</code> from <code>@AppSettings.Value.FromWhere</code></p>",
            "</div>",
        ],
        "description": "_Index"
    }
}

_LocalSettings and _Index are showing twice for HTML files. For other files, there's no issue.

VS Code version: Code 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-05-12T17:44:30.902Z) OS version: Darwin x64 20.3.0

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|8.00GB (0.04GB free)| |Process Argv|. --crash-reporter-id 788fec2d-7124-492e-95d6-ccdc04239216| |Screen Reader|no| |VM|0%|
Extensions (44) Extension|Author (truncated)|Version ---|---|--- ascii-tree-generator|apr|1.2.4 azurite|Azu|3.12.0 github-markdown-preview|bie|0.0.2 markdown-checkbox|bie|0.1.3 markdown-emoji|bie|0.1.0 markdown-preview-github-styles|bie|0.2.0 markdown-yaml-preamble|bie|0.0.4 LinkCheckMD|bla|0.3.1 gitlens|eam|11.4.1 prettier-vscode|esb|6.4.0 vscode-todo-plus|fab|4.18.3 dotnet-test-explorer|for|0.7.5 github-actions|for|0.0.1 terraform|has|2.11.0 vscode-guid|hea|1.4.20 rest-client|hum|0.24.5 wordcounter|kir|2.3.0 git-graph|mhu|1.30.0 azure-pipelines|ms-|1.183.0 vscode-apimanagement|ms-|1.0.2 vscode-azureappservice|ms-|0.21.2 vscode-azurefunctions|ms-|1.3.0 vscode-azureresourcegroups|ms-|0.4.0 vscode-bicep|ms-|0.3.539 vscode-cosmosdb|ms-|0.16.0 vscode-docker|ms-|1.12.1 vscode-logicapps|ms-|1.0.12 csharp|ms-|1.23.11 vscode-dotnet-runtime|ms-|1.1.0 mssql|ms-|1.10.1 python|ms-|2021.5.842923320 vscode-pylance|ms-|2021.5.3 jupyter|ms-|2021.6.832593372 remote-containers|ms-|0.177.2 azure-account|ms-|0.9.8 azurecli|ms-|0.5.0 powershell|ms-|2021.2.2 vscode-typescript-tslint-plugin|ms-|1.3.3 azurerm-vscode-tools|msa|0.15.1 vscode-coverage-gutters|rya|2.7.3 vscode-scss-formatter|sib|2.2.0 code-spell-checker|str|1.10.2 application-insights|Vis|0.4.2 vscode-icons|vsc|11.4.0
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspyt653:30270858 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 vspre833:30267464 pythonptprofiler:30281270 vshan820:30294714 vscorecescf:30290706 pythondataviewer:30285071 vscus158:30286553 vscgsv2:30301612 vscorehov:30302759 bridgeflightcf:30302070 vscod805:30301674 ```
a11smiles commented 3 years ago

After further troubleshooting, if I add the scope property and assign it html, then my respective snippets only show up once.

So, it appears that the duplication happens when scope is not added to the snippet definition.

jrieken commented 3 years ago

Here's my .code-snippets:

code-snippets for your project, from your extension, or your user snippets? Are you 100% sure that you have not defined them in repeated in these places?

a11smiles commented 3 years ago

they are for my project.

i simply created a new dotnet core web app: dotnet new webapp and added that code snippets file. then going into \Pages\Index.cshtml on the last line of the file, I press ^+[space].

On the Intellisense, you'll see both snippets showing twice each.

jrieken commented 2 years ago

Using the provided snippets file and an empty test.cshtml file I cannot reproduce. @a11smiles There is workspace snippets and user snippets which are both considered for snippet suggestions. Please select "F1 > Configure User Snippets" and check if you see have user snippet files with those snippets

Screen Shot 2021-10-12 at 12 38 37