fix: search.py after PR #17828 (#18719)

* fix search.py

After the PR #17828 in some cases an "IndexError: list assignment index out of range" error is thrown. This should fix it.

* Update search.py

Yes, that should be even better

* style: formatting

[skip ci]
This commit is contained in:
DrZoidberg09 2022-11-02 08:41:20 +01:00 committed by GitHub
parent 7bbd36345a
commit 58cef6005a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,7 +284,8 @@ def build_for_autosuggest(res: list[tuple], doctype: str) -> list[dict]:
item = list(item)
label = item[1] # use title as label
item[1] = item[0] # show name in description instead of title
del item[2] # remove redundant title ("label") value
if len(item) >= 3:
del item[2] # remove redundant title ("label") value
results.append({"value": item[0], "label": label, "description": to_string(item[1:])})
else:
results.extend({"value": item[0], "description": to_string(item[1:])} for item in res)