* suppress autocomplete when navigating through history
* only search for slashcommands if in the first block of the editor
* handle suffix returns from providers correctly
* fix SelectionRange typing in the providers
* fix bugs when pressing ctrl-a, typing and then tab to complete a replacement by collapsing selection to anchor when inserting a completion in the editor
* fix https://github.com/vector-im/riot-web/issues/4762
Loading the users into the autocomplete provider is quite a large
chunk of work for a large room. Try lazy loading it the first time
a completion is done rather than up front when the room is loaded,
given that a lot of the time you switch to a room you won't say
anything.
Because we need to support tab completing `"@some_user"` if `@some_user` has a display name that is totally different and will therefore not match what the user typed in.
This does have the disadvantage of a display name appearing (the pill) that isn't at all what the user typed in, but the autocomplete box and the tooltip should give enough information to let the user know what's going on. (e.g. typing `@kyr*tab*` and getting `Remmy`).
This _does_ run contrary to vector-im/riot-web#4495
related to vector-im/riot-web#4794
cc @lampholder
to make sure that the length of text in the decoration (See <Pill>) is equal to the length of text in the completion (underlying text range that the Entity covers).
by index of the query in displayedAlias and then length of displayedAlias. (So that aliases where the query appears earlier in the string appear first and if the query is in the same index for two aliases, the shorter one appears first).
These will appear decorated because they are inserted as entities. It was necessary to modify pills to have an explicit linkText that is derived from the `href` being pillified (and is thus no longer the inserted completion but rather the display name (or user ID) or room alias.
For example, searching for `:tong` will now match `:stuck_out_tongue` because the query `:tong` has all non-word characters removed, becoming `tong` and is then matched against the (long) names of emojis such as `smiling face with open mouth and tightly-closed eyes`.
_sortedUniq claims to be like _uniq but optimised for sorted arrays - https://lodash.com/docs/4.17.4#sortedUniqBy. But in practice this isn't quite true, so stick with the unoptimised version.
This modifies the composer completion such that completing a room or user will insert an IMMUTABLE matrix.to LINK Entity for the range that was replaced. Display names will not have a colon after their name anymore as it seemed strange that we would insert one after a pill.
Use bluebird instead of the now removed "q" library.
Also, make sure we timeout and then `reflect` to effectively do an `allSettled` that waits for all promises to either be resolved or rejected. Then we filter for those that are fulfilled and return the completions.
Otherwise by default it appears first, pushing "people" further down the list
Also, remove "unicode9" category ordering, as this category does not exist as part of emojione
`Array.prototype.splice` will return the array of removed items, not a new array. The array operated on is actually modified in-place.
This was causing a few weird things to happen: https://github.com/vector-im/riot-web/issues/4511 and https://github.com/vector-im/riot-web/issues/4533. This should fix both of them but it is concerning that doing the tab completion is required to reproduce. Let's just see how this goes before closing the issues.
Thanks @turt2live for reproducing both bugs, giving enough information for a fix :)
Accepting an invite would cause a room to arrive via /sync only for it to throw an error in the auto complete code and cause the client to go wibbly (infinite spinner or preview bar).
The logs that lead to the debugging of this are https://github.com/matrix-org/riot-web-rageshakes/issues/239
Hopefully the error being throw isn't totally unrelated but looking at the sync handling for inviteRooms in sync.js, new rooms are stored and _then_ the Room event is emitted. The Room event could trigger setUserListFromRoom, which is where the bug was. So the room should have been stored regardless of this bug and the client should have been recoverable by swapping away and viewing the room again.
Which are:
- the emoji to complete is at the start of the query
- there is a whitespace character before the emoji
- there is an emoji before the emoji (so that several emoji can be input in-a-row)
Fixes https://github.com/vector-im/riot-web/issues/4498 (although it seems to be fixed through some other fix)
QueryMatcher: sort results based on the position of the query within the matching value. The closer to the beginning of the word, the higher the result apears.
UserProvider: perf improvement (slice early) and refactor onUserSpoke
Plaintext emojis that start with ":" will also match against the shorthand regex but the match won't include the important part of the plaintext emoji. This means some emoji like ":)" won't be matched.
To fix this, put the ascii emoji regex first so that the match will be plaintext or otherwise it will fall through to the shorthand match (if there is one).
Fixes https://github.com/vector-im/riot-web/issues/4467
When a fully plaintext, ascii emoji is typed like ";-)", pressing tab will suggest emojione to replace it with based off of the meta data provided by emojione.
e.g. the aliases_ascii for `😃` are [":D",":-D","=D"] so typing ":D *tab*" will insert a real 😃
As of v2.7.2, fuse.js introduces a regression where the second argument to the constructor `Fuse` is assumed to be an object. There was one instance where we were not passing any argument. This fixes that.