I was trying to mention someone that is in the room (of 11 members) and the autocomplete presented me very different users (from other rooms).


Can confirm. This behaviour shouldn't be there as it is a possible privacy risk.
@lennartgrunau I dont think its a privacy risk, we have some permissions about that (mention users outside the room)
The autocomplete searches in the name AND nick, so mentioning is sometimes a little bit annoying, especially because it is slow and laggy.
So here is a example which is annoying every day what I think could/should be improvised:
There are two different users with the names "Max Mustermann" (@mm) and "Fred Famming" (@ff).
When I want to mention Max with @m... Rocket.Chat autocompletes it to @ff because "Famming" contains "mm", but "f" is higher in alphabetical order (his mentioning nick).
It's nice, that the full name gets searched for autocomplete, but when typing fast I want to match first the nicknames, because there are short and more often the correct identities I want to match, further matches like in names are benefits.
+1 this feels like a regression but I can't confirm that easily. The matching is done on any substring vs it should only match on the prefix. ie what @Eichi said above
If my username is @ninja and my name is Tim Bartlett then searching for @tt should NEVER match at all. The only things that should match are prefix matches on the username such as @n or @nin or word prefix matches on the name @ti or @bar. It should never match on a substr of the user name or the proper name, ie none of these should match: @nja, @im, @art, @let (but all currently do)
Because we have a large number of users in random unrelated channels, this bug means that for me that autocompletion is completely broken now. It almost never suggests the user I want, which means it doesn't save any typing nor reduce the incidence of mistypes, which is the entire reason for autocomplete to exist.
I see the issue in general but would not like to have the real names excluded. We have users who can't guess the (sometimes weird) usernames but rely on the real names. That easily creates an issue as no spaces are allowed (no surnames) and there are only 5 results so it's easy to miss the right person for common names. I have no good suggestion how to do it differently but to not use substrings by default may be a start.
Hi @rsimai , I think I gave a possible solution: Sort the suggestions first for direct match with usernames and than for matches in real names. So we can use it in the most effective way, but we can also pick suggestions from real names if needed.
Additionally, as @brendanheywood said, broken suggestions with substrings could be sorted to the end of suggestions.
For example: First direct matches with usernames, than matches with realnames (from beginning of string) and last matches with substrings.
I'd like to add (coming back to the original issue) that users that are actually members of the channel should be prioritized, whether by usernames and/or real names.
This is especially true in private channels - in most use cases, there's not much point in mentioning someone who can't even see the message.