Fix commands activating anywhere in the input (#156)
authorSamuel Dionne-Riel <samuel@dionne-riel.com>
Sun, 7 Nov 2021 04:32:50 +0000 (00:32 -0400)
committerGitHub <noreply@github.com>
Sun, 7 Nov 2021 04:32:50 +0000 (10:02 +0530)
* Fix commands activating anywhere in the input

Writing `The command to leave a channel is /leave` might have had "fun"
consequences for users.

Fixes #155

* Fix go-to commands activating anywhere in the input

While less obtrusive than `/` commands activating anywhere, it seems
logical to only activate completion of those when at the beginning of
the input.

src/app/organisms/room/RoomViewInput.jsx

index 6d4a22f684febd750a454dfb03179a56ab6f5050..e23b5c1a200b0df576beb70fbbd7eacaab2c2480 100644 (file)
@@ -29,7 +29,7 @@ import MarkdownIC from '../../../../public/res/ic/outlined/markdown.svg';
 import FileIC from '../../../../public/res/ic/outlined/file.svg';
 import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
 
-const CMD_REGEX = /(\/|>[#*@]|:|@)(\S*)$/;
+const CMD_REGEX = /(^\/|^>[#*@]|:|@)(\S*)$/;
 let isTyping = false;
 let isCmdActivated = false;
 let cmdCursorPos = null;