Skip to content

Snippet suggestion triggered incorrectly #6320

Closed

Description

@23min
  • VSCode Version: Version 1.1.0 (1.1.0)
  • OS Version: Mac OS X Yosemite 10.10.5 (14F27)

Steps to Reproduce:

  1. Create a user snippet with a prefix "sup"
    (I created mine in ~/Library/Application Support/Code/User/snippets/elixir.json)
  2. In a file matching the language, type S or s, intellisense correctly suggests snippet "sup"
  3. When proceeding to type non-matching characters, e.g. erv intellisense still suggests snippet "sup"

screenshot 2016-05-12 13 26 23

Expected behavior:

When the typed characters no longer match the start of a snippet prefix, the snippet suggestion should not be shown.

Activity

  1. added
    bug
    on May 12, 2016
  2. jrieken commented on May 12, 2016

    @jrieken
    Contributor

    Peter Bruinsma (@23min) Can you share your snippet with us? Trying this with the class snippet in JavaScript doesn't allow me to repo

    may-12-2016 17-57-13

  3. added
    info-needed
    on May 12, 2016
  4. 23min commented on May 13, 2016

    @23min
    Author
    {
    
        // Place your snippets for Elixir here. Each snippet is defined under a snippet name and has a prefix, body and 
        // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
        // $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
        // Example:
        "Print to console": {
            "prefix": "log",
            "body": [
                "console.log('$1');",
                "$2"
            ],
            "description": "Log output to console"
        },
    
            "Print to Somethjing": {
            "prefix": "Lassa",
            "body": [
                "console.log('$1');",
                "$2"
            ],
            "description": "Log output to console"
        },
    
        "Supervisor Template": {
            "prefix": "sup",
            "body": [
                "defmodule $1.Supervisor do",
                    "\tuse Supervisor",
                    "",
                    "\tdef start_link do",
                        "\t\tSupervisor.start_link(__MODULE__, [])",
                    "\tend",
                    "",
                    "\tdef init(_) do",
                        "\t\tchildren = [",
                            "\t\t\tworker($1.Server, [])",
                        "\t\t]",
                        "",
                        "\t\tsupervise(children, strategy: :one_for_one)",
                    "\tend",
                    "",
                "end",
                "$2"
            ],
            "description": "Creates a skeleton supervisor"
        },
    
        "GenServer Template": {
            "prefix": "gens",
            "body": [
                "defmodule $1 do",
                    "\tuse GenServer",
                    "", 
                    "\tdef start_link do",
                        "\t\tGenServer.start_link(__MODULE__, :ok, [name: __MODULE__])",
                    "\tend",
                "",  
                "end",
                "$2"
            ],
            "description": "Creates a minimal skeleton genserver"
        }   
    }
    
  5. removed
    info-needed
    on May 17, 2016
  6. jrieken commented on May 17, 2016

    @jrieken
    Contributor

    Understood. It is like this because we compare suggestions against their label, codeSnippet, and filterText. The first and last are clear to me but I don't remember why we filter against the codeSnippet...

  7. added a commit that references this issue on May 19, 2016
    7f8bf3c
  8. jrieken commented on May 23, 2016

    @jrieken
    Contributor

    Reopening and reverting this due to #6620

  9. 5 remaining items

  10. jrieken commented on Jul 4, 2016

    @jrieken
    Contributor

    Sorry, need to revert again due to #8531. There is still something wrong with the json language which doesn't allow me to make this change

  11. added
    important
    on Jul 4, 2016
  12. aeschli commented on Jul 4, 2016

    @aeschli
    Contributor
  13. fluffynuts commented on Jul 25, 2016

    @fluffynuts

    This also affects "inbuilt" snippets: when working in Typescript, typing "c" shows the completion for the "class" snippet -- however, finishing out to "const" leaves the "class" snippet still selected, so an keypress to move to the next line for a bunch of consts gets me a class snippet.
    So this isn't so much a case of "the wrong snippet selected" as "no snippet actually matches the word, but last last matching snippet is still selected".

    I stumbled across this report from searching GitHub issues for vscode and snippets -- if this addition should be put somewhere else, please advise.

  14. locked and limited conversation to collaborators on Nov 18, 2017
  15. added 3 commits that reference this issue on Sep 6, 2026
    ddcbfb2
    e37457f
    74d035d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugimportantverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions