Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Custom filters for suggestions #635

Closed
rm-code opened this issue Dec 6, 2015 · 2 comments
Closed

Custom filters for suggestions #635

rm-code opened this issue Dec 6, 2015 · 2 comments

Comments

@rm-code
Copy link

rm-code commented Dec 6, 2015

The issue

I am currently writing my own provider, which should provide snippets and autocomplete functionality for functions of the LÖVE framework. The problem is, that autocomplete-plus uses the snippet field for filtering when filterSuggestions is set to true (at least as far as I can tell).

For example it wouldn't work for a suggestion like this:

  {
    "displayText": "love.directorydropped",
    "type": "function",
    "description": "Callback function triggered when a directory is dragged and dropped onto the window.",
    "descriptionMoreURL": "https://love2d.org/wiki/love.directorydropped",
    "snippet": "function love.directorydropped(${1:path (string)})\n    ${2:body (lua)}\nend\n"
  }

I'd like to type ldir and have the suggestion for love.directorydropped at the top of the autocomplete list, but since autocomplete-plus tries to match ldir to the snippet (which starts with function ... nothing is suggested at all.

This also means you can't use snippets which start with a variable:
${0:Source}:isPaused()

Suggestion

Of course this might just be a special case which rarely comes up, but maybe it might make sense to allow creators of new providers to specify a filter field which is matched against the prefix.

  {
    "displayText": "love.directorydropped",
    "type": "function",
    "description": "Callback function triggered when a directory is dragged and dropped onto the window.",
    "descriptionMoreURL": "https://love2d.org/wiki/love.directorydropped",
    "filter": "love.directorydropped",
    "snippet": "function love.directorydropped(${1:path (string)})\n    ${2:body (lua)}\nend\n"
  }

autocomplete-plus could still fall back to the default behaviour, if the filter field isn't provided.

@lee-dohm lee-dohm changed the title [Question] Filtering the suggestions Filtering the suggestions Dec 6, 2015
rm-code added a commit to rm-code/love-atom that referenced this issue Dec 9, 2015
This is needed to make the provider work correctly with the fuzzy filter
of autocomplete-plus.

See: atom/autocomplete-plus#635
@rm-code
Copy link
Author

rm-code commented Jan 22, 2016

Updated the description with another case where this behavior causes troubles.

@rm-code rm-code changed the title Filtering the suggestions Custom filters for suggestions Jan 22, 2016
@rm-code
Copy link
Author

rm-code commented Mar 26, 2017

This seems to have been added / fixed by now.

@rm-code rm-code closed this as completed Mar 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants