Skip to content

Commit

Permalink
Merge pull request #2700 from nextcloud/fix/talk_app/search-mentions-…
Browse files Browse the repository at this point in the history
…invalid-text-selection

fix(talk_app): Ignore invalid text selection when searching mentions
  • Loading branch information
provokateurin authored Dec 16, 2024
2 parents 9dbdd02 + 34cb22f commit c2a0e52
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,18 @@ class _TalkMessageInputState extends State<TalkMessageInput> {
controller: controller,
focusNode: focusNode,
suggestionsCallback: (_) async {
final cursor = controller.selection.start;
if (controller.text.isEmpty || cursor != controller.selection.end) {
final selection = controller.selection;
if (!selection.isValid) {
return [];
}

var matchingPart = controller.text.substring(0, cursor);
final cursor = selection.start;
final text = controller.text;
if (text.isEmpty || cursor != selection.end) {
return [];
}

var matchingPart = text.substring(0, cursor);
final index = matchingPart.lastIndexOf(' ') + 1;
matchingPart = matchingPart.substring(index);
if (!matchingPart.startsWith('@') || matchingPart.isEmpty) {
Expand Down

0 comments on commit c2a0e52

Please sign in to comment.