include query item in search suggestions (#117)

but only if it does not end with ".", since items with "." are partial
names only used to drill down to the actual package/option name.

when there is one result in suggestions and is the same as query we don't show results
This commit is contained in:
Rok Garbas 2020-07-08 17:05:57 +02:00 committed by GitHub
parent af66eef748
commit 08c5d997dc
Failed to generate hash of commit

View file

@ -641,10 +641,30 @@ getSuggestions query querySuggest =
in
case querySuggest of
RemoteData.Success result ->
result.suggest
|> maybeList (\x -> x.query |> maybeList (List.map .options))
|> List.concat
|> List.filter (\x -> x.text /= query)
let
suggestions =
result.suggest
|> maybeList (\x -> x.query |> maybeList (List.map .options))
|> List.concat
|> List.filter
(\x ->
if String.endsWith "." (Maybe.withDefault "" query) then
x.text /= query
else
True
)
firstItemText items =
items
|> List.head
|> Maybe.andThen .text
in
if List.length suggestions == 1 && firstItemText suggestions == query then
[]
else
suggestions
_ ->
[]