Merge pull request #3690 from InspectorCaracal/patch-38
Avoid erroneous "direct match" targets when searching
This commit is contained in:
commit
bf94618e41
1 changed files with 11 additions and 6 deletions
|
|
@ -552,11 +552,13 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(searchdata, str):
|
if isinstance(searchdata, str):
|
||||||
|
candidates = kwargs.get("candidates") or []
|
||||||
|
global_search = kwargs.get("global_search", False)
|
||||||
match searchdata.lower():
|
match searchdata.lower():
|
||||||
case "me" | "self":
|
case "me" | "self":
|
||||||
return True, self
|
return global_search or self in candidates, self
|
||||||
case "here":
|
case "here":
|
||||||
return True, self.location
|
return global_search or self.location in candidates, self.location
|
||||||
return False, searchdata
|
return False, searchdata
|
||||||
|
|
||||||
def get_search_candidates(self, searchdata, **kwargs):
|
def get_search_candidates(self, searchdata, **kwargs):
|
||||||
|
|
@ -836,8 +838,14 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
# replace incoming searchdata string with a potentially modified version
|
# replace incoming searchdata string with a potentially modified version
|
||||||
searchdata = self.get_search_query_replacement(searchdata, **input_kwargs)
|
searchdata = self.get_search_query_replacement(searchdata, **input_kwargs)
|
||||||
|
|
||||||
|
# get candidates
|
||||||
|
candidates = self.get_search_candidates(searchdata, **input_kwargs)
|
||||||
|
|
||||||
# handle special input strings, like "me" or "here".
|
# handle special input strings, like "me" or "here".
|
||||||
should_return, searchdata = self.get_search_direct_match(searchdata, **input_kwargs)
|
# we also want to include the identified candidates here instead of input, to account for defaults
|
||||||
|
should_return, searchdata = self.get_search_direct_match(
|
||||||
|
searchdata, **(input_kwargs | {"candidates": candidates})
|
||||||
|
)
|
||||||
if should_return:
|
if should_return:
|
||||||
# we got an actual result, return it immediately
|
# we got an actual result, return it immediately
|
||||||
return [searchdata] if quiet else searchdata
|
return [searchdata] if quiet else searchdata
|
||||||
|
|
@ -857,9 +865,6 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
# always use exact match for dbref/global searches
|
# always use exact match for dbref/global searches
|
||||||
exact = True if global_search or dbref(searchdata) else exact
|
exact = True if global_search or dbref(searchdata) else exact
|
||||||
|
|
||||||
# get candidates
|
|
||||||
candidates = self.get_search_candidates(searchdata, **input_kwargs)
|
|
||||||
|
|
||||||
# do the actual search
|
# do the actual search
|
||||||
results = self.get_search_result(
|
results = self.get_search_result(
|
||||||
searchdata,
|
searchdata,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue