Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle spaces in feeds for mention plugin #11017

Merged
merged 6 commits into from
Dec 21, 2021

Conversation

CatStrategist
Copy link
Contributor

@CatStrategist CatStrategist commented Dec 16, 2021

Suggested merge commit message (convention)

Fix (mention): Mention plugin now allows searching mentions that include space character. Closes #9741.


Additional information

Mention plugin allowed user to search for feeds only using single words and as soon as it encountered a space it closed items list with results even if there were matches including a space e.g. 'Barry Thompson'. It happened because of regexp for matching mentions in currently edited text that only allowed visible characters to occur after a mention mark.
At first it seemed as an easy improvement of regexp to just allow a space but a scenario with multiple registered markes complicated it a lot.

Take this case:

aaa @fooo #bar

Regexp allowing space would match @foo as well as #bar. After playing a little bit with regexp to handle that case it quickly got overcomplicated and still had some other edge cases so I had to withdraw from this approach.

Previously regexp to match mention tested entire text node till caret but what we really needed to test is just a text since last valid marker in text. But yet again, case with multiple markers complicated it a little bit. Previously there was a TextWatcher for each marker that tried to match a mention for it's own marker. It run outside of state of mention plugin and executed matched or umatched events without knowledge of matches for other markers. It could find a match for one marker and tried to show UI, but the other marker fired unmatched event and immediately hid UI. Before going with solution for spaces it had to be fixed. When initializing plugin I've merged watchers to a single one who knows about each marker and runs only one on each text change. Having that in place, I could pass a test function to TextWatcher and find last valid marker in text, trim text since last marker (+1 a character behind to test if marker is in correct place) till caret. Having only that part the rest of the code could stay as usual with just a little change to regexp that now allows any character after marker character instead of just visible characters.

@CatStrategist CatStrategist changed the title Finalize handling space in mention plugin Handle spaces in feeds for mention plugin Dec 16, 2021
@CatStrategist CatStrategist marked this pull request as ready for review December 17, 2021 08:49
@niegowski niegowski merged commit d95bc68 into master Dec 21, 2021
@niegowski niegowski deleted the ck/9741-handle-space-in-mention-plugin branch December 21, 2021 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mention plugin should allow autocomplete with space
2 participants