typeahead: Rewrite query_matches_source_attrs to be obviously correct.
typeahead: Rewrite query_matches_source_attrs to be obviously correct.

This restructures this fairly complicated function to a much cleaner
implementation, with fewer unnecessary variables and a cleaner flow.
While we're at it, we document the function.

kou/zulip,punchagan/zulip,synicalsyntax/zulip,zulip/zulip,timabbott/zulip,shubhamdhama/zulip,brainwane/zulip,tommyip/zulip,andersk/zulip,timabbott/zulip,zulip/zulip,dhcrzf/zulip,eeshangarg/zulip,rishig/zulip,showell/zulip,jackrzhang/zulip,kou/zulip,synicalsyntax/zulip,dhcrzf/zulip,kou/zulip,zulip/zulip,rishig/zulip,tommyip/zulip,dhcrzf/zulip,rht/zulip,brainwane/zulip,kou/zulip,timabbott/zulip,rht/zulip,eeshangarg/zulip,rishig/zulip,kou/zulip,punchagan/zulip,shubhamdhama/zulip,tommyip/zulip,showell/zulip,rishig/zulip,dhcrzf/zulip,shubhamdhama/zulip,timabbott/zulip,jackrzhang/zulip,jackrzhang/zulip,timabbott/zulip,dhcrzf/zulip,andersk/zulip,timabbott/zulip,andersk/zulip,jackrzhang/zulip,showell/zulip,eeshangarg/zulip,brainwane/zulip,shubhamdhama/zulip,hackerkid/zulip,synicalsyntax/zulip,jackrzhang/zulip,jackrzhang/zulip,showell/zulip,andersk/zulip,rht/zulip,eeshangarg/zulip,synicalsyntax/zulip,rishig/zulip,dhcrzf/zulip,tommyip/zulip,hackerkid/zulip,punchagan/zulip,rht/zulip,hackerkid/zulip,rishig/zulip,hackerkid/zulip,rht/zulip,hackerkid/zulip,timabbott/zulip,synicalsyntax/zulip,kou/zulip,showell/zulip,punchagan/zulip,zulip/zulip,dhcrzf/zulip,brainwane/zulip,rishig/zulip,eeshangarg/zulip,showell/zulip,hackerkid/zulip,synicalsyntax/zulip,tommyip/zulip,rht/zulip,zulip/zulip,andersk/zulip,shubhamdhama/zulip,tommyip/zulip,jackrzhang/zulip,eeshangarg/zulip,hackerkid/zulip,rht/zulip,synicalsyntax/zulip,showell/zulip,punchagan/zulip,punchagan/zulip,zulip/zulip,andersk/zulip,shubhamdhama/zulip,andersk/zulip,zulip/zulip,brainwane/zulip,shubhamdhama/zulip,eeshangarg/zulip,brainwane/zulip,punchagan/zulip,brainwane/zulip,kou/zulip,tommyip/zulip