You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Only match users by matchgin displayname or user ID prefixes
Because tab completing "k" probably shouldn't give you "luke" Fixes https://github.com/vector-im/riot-web/issues/4495
This commit is contained in:
@@ -69,6 +69,12 @@ export default class QueryMatcher {
|
||||
if (this.options.shouldMatchWordsOnly === undefined) {
|
||||
this.options.shouldMatchWordsOnly = true;
|
||||
}
|
||||
|
||||
// By default, match anywhere in the string being searched. If enabled, only return
|
||||
// matches that are prefixed with the query.
|
||||
if (this.options.shouldMatchPrefix === undefined) {
|
||||
this.options.shouldMatchPrefix = false;
|
||||
}
|
||||
}
|
||||
|
||||
setObjects(objects: Array<Object>) {
|
||||
@@ -87,7 +93,7 @@ export default class QueryMatcher {
|
||||
resultKey = resultKey.replace(/[^\w]/g, '');
|
||||
}
|
||||
const index = resultKey.indexOf(query);
|
||||
if (index !== -1) {
|
||||
if (index !== -1 && (!this.options.shouldMatchPrefix || index === 0)) {
|
||||
results.push({key, index});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user