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

Add support for as-you-type autocomplete #12

Open
lexicalunit opened this issue Jul 30, 2017 · 1 comment
Open

Add support for as-you-type autocomplete #12

lexicalunit opened this issue Jul 30, 2017 · 1 comment

Comments

@lexicalunit
Copy link

lexicalunit commented Jul 30, 2017

As it's currently implemented, there's no evident event hook that could be used to support an autocomplete feature. Initially I tried to use didChangeQuery(). I got the TextEditor model out of the SelectList via selectList.refs.queryEditor, then I intended to do something like:

item = whatever() // the item we want to autocomplete to
editor.setText(item.title)
editor.selectLeft(item.title.length - query.length)

But of course using editor.setText() here triggers didChangeQuery() and causes an infinite loop. More than that though, it also triggers a filter process for the autocompleted item's text :(

I tried to work around it by using some state to make the next didChangeQuery() and filter() calls into no-ops after doing an autocompletion but it was really janky and slow and I just couldn't get it to work right. This seems like it would be better implemented within atom-select-list somehow.

@lexicalunit
Copy link
Author

Note that using the setQuery() function from #13 , like the example code above, also triggers didChangeQuery() and only supports automatically selecting the entire query. Whereas in typical autocompletion schemes it is only autocompleted text that is selected. For example:

auto

lexicalunit added a commit to lexicalunit/atom-select-list that referenced this issue May 6, 2018
If and only if this option is set to false, the didChangeQuery()
callback will NOT trigger after updating the query. This is useful for
things like autocompletion or when you'd want to update the query text
while bypassing code that recomputes and filters the list items.

This is the only change I needed to make to `SelectListView` to fully
implement autocompletion (see atom#12) on top of `atom-select-list`.
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