From e541a8c654e05365f41b127ff04e6aef2bdbbf9e Mon Sep 17 00:00:00 2001
From: Brecht Van Lommel <brecht@blender.org>
Date: Tue, 18 Apr 2023 19:25:11 +0200
Subject: [PATCH] Make mention autocomplete case insensitive in new markdown
 editor (#24190)

This matches EasyMDE, and makes it easier to find the right user without
having to remember the exact name.

---------

Co-authored-by: silverwind <me@silverwind.io>
---
 web_src/js/features/comp/ComboMarkdownEditor.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js
index 3eb8bf7076..eb73b0914d 100644
--- a/web_src/js/features/comp/ComboMarkdownEditor.js
+++ b/web_src/js/features/comp/ComboMarkdownEditor.js
@@ -107,8 +107,9 @@ class ComboMarkdownEditor {
     expander?.addEventListener('text-expander-change', ({detail: {key, provide, text}}) => {
       if (key === ':') {
         const matches = [];
+        const textLowerCase = text.toLowerCase();
         for (const name of emojiKeys) {
-          if (name.includes(text)) {
+          if (name.toLowerCase().includes(textLowerCase)) {
             matches.push(name);
             if (matches.length >= maxExpanderMatches) break;
           }
@@ -129,8 +130,9 @@ class ComboMarkdownEditor {
         provide({matched: true, fragment: ul});
       } else if (key === '@') {
         const matches = [];
+        const textLowerCase = text.toLowerCase();
         for (const obj of window.config.tributeValues) {
-          if (obj.key.includes(text)) {
+          if (obj.key.toLowerCase().includes(textLowerCase)) {
             matches.push(obj);
             if (matches.length >= maxExpanderMatches) break;
           }