{"action":"opened","issue":{"url":"https://api.github.com/repos/atom-community/autocomplete-plus/issues/360","labels_url":"https://api.github.com/repos/atom-community/autocomplete-plus/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/atom-community/autocomplete-plus/issues/360/comments","events_url":"https://api.github.com/repos/atom-community/autocomplete-plus/issues/360/events","html_url":"https://github.com/atom-community/autocomplete-plus/issues/360","id":66718247,"number":360,"title":"Accept new provider param to perform fuzzy sorting / filtering logic in core autocomplete package","user":{"login":"benogle","id":69169,"avatar_url":"https://avatars.githubusercontent.com/u/69169?v=3","gravatar_id":"","url":"https://api.github.com/users/benogle","html_url":"https://github.com/benogle","followers_url":"https://api.github.com/users/benogle/followers","following_url":"https://api.github.com/users/benogle/following{/other_user}","gists_url":"https://api.github.com/users/benogle/gists{/gist_id}","starred_url":"https://api.github.com/users/benogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benogle/subscriptions","organizations_url":"https://api.github.com/users/benogle/orgs","repos_url":"https://api.github.com/users/benogle/repos","events_url":"https://api.github.com/users/benogle/events{/privacy}","received_events_url":"https://api.github.com/users/benogle/received_events","type":"User","site_admin":true},"labels":[{"url":"https://api.github.com/repos/atom-community/autocomplete-plus/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-06T22:16:40Z","updated_at":"2015-04-06T22:16:40Z","closed_at":null,"body":"Currently, each provider needs to come up with some fuzzy filtering / sorting scheme. It's pretty boilerplate in many cases, and can be error prone. It would be nice to provide a default sorting / filtering scheme providers can opt into for ease and consistency across providers.\r\n\r\n### New `filterSuggestions` param\r\n\r\nA new provider would set a new `filterSuggestions` param new param to true, then return all its suggestions every time.\r\n\r\n```coffee\r\nprovider =\r\n  filterSuggestions: true # new!\r\n  getSuggestions: (options) =>\r\n    [{text: 'ab'}, {text: 'abc'}, {text: 'abcd'}, {text: 'omg'}]\r\n```\r\n\r\nFiltering would happen in the core package. An algorithm that matches our current approach might look like the following:\r\n\r\n```coffee\r\nfilterSuggestions: (suggestions, {prefix}) ->\r\n  candidates = fuzzaldrin.filter(suggestions, prefix, key: 'text')\r\n\r\n  # Dont show matches that are the same as the prefix.\r\n  # And only show those that match the first char\r\n  results = []\r\n  lowercasePrefixChar = prefix[0].toLowerCase()\r\n  for candidate in candidates when word isnt prefix\r\n    continue unless lowercasePrefixChar is candidate.text[0].toLowerCase()\r\n    results.push candidate\r\n  results\r\n```\r\n"}}