Skip to content

Adopt insert&replace range for snippet completions #83834

Closed

Description

For #10266 we are adding insert and replace ranges to completion items. Provider that currently provide a range only need to be adopted and snippets is one of them.

Activity

  1. added
    feature-request
    help wanted
    suggest
    on Nov 1, 2019
  2. added a commit that references this issue on Nov 15, 2019
    8e91d73
  3. TylerLeonhardt commented on Nov 19, 2019

    @TylerLeonhardt
    Member

    Nice! How do I use this? Since snippets are static I'm curious how I specify the range in the json file

  4. jrieken commented on Nov 19, 2019

    @jrieken
    ContributorAuthor

    The snippet prefix decides:

    const provider = new SnippetCompletionProvider(modeService, snippetService);

  5. TylerLeonhardt commented on Nov 19, 2019

    @TylerLeonhardt
    Member

    So if the prefix is exactly the same as the start of the snippet, it will do a replace? Am I interpreting that correctly?

    And if they're not exact, no replace happens?

  6. jrieken commented on Nov 20, 2019

    @jrieken
    ContributorAuthor

    yes

  7. added
    verification-needed
    on Dec 2, 2019
  8. jrieken commented on Dec 3, 2019

    @jrieken
    ContributorAuthor

    To verify: have a snippet with prefix "foo" and insert it at '|foo', 'f|oo', and 'foo|'. Insert via tab and shift+tab to toggle between insert and replace mode

  9. added
    verified
    verification-found
    and removed
    verified
    on Dec 4, 2019
  10. rebornix commented on Dec 4, 2019

    @rebornix
    Contributor

    Tested all three cases for foo, f|oo and foo| work as expected but |foo doesn't.

    Snippet

    {
    	 "Print to console": {
    		"prefix": "foo",
    		"body": [
    			"console.log('$1');"
    		],
    		"description": "Log foo to console"
    	}
    
    }
    
    • Put cursor before foo
    • Trigger suggest
    • Move focus to foo snippet in suggest widget
    • Shift+Tab and Tab behave the same
  11. TylerLeonhardt commented on Dec 4, 2019

    @TylerLeonhardt
    Member

    This is working! (minus the scenario Peng Lyu (@rebornix) mentioned) I'll update our snippets to have a prefix that lines up with the body. Thanks!

  12. jrieken commented on Dec 5, 2019

    @jrieken
    ContributorAuthor

    I have extracted #86386

  13. locked and limited conversation to collaborators on Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesthelp wantedsnippetssuggestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions