Skip to content

Commit 081fdc4

Browse files
committed
previous fix for mentions actually broke searching; this does it properly
1 parent 060f992 commit 081fdc4

File tree

1 file changed

+6
-5
lines changed
  • src/packages/frontend/editors/slate/slate-mentions

1 file changed

+6
-5
lines changed

src/packages/frontend/editors/slate/slate-mentions/hook.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ export const useMentions: (Options) => MentionsControl = ({
9494
}
9595
if (Text.isText(current)) {
9696
const charBeforeCursor = current.text[focus.offset - 1];
97+
// keep use of this consistent with before stuff in frontend/editors/markdown-input/component.tsx
9798
const charBeforeBefore = current.text[focus.offset - 2]?.trim();
9899
let afterMatch, beforeMatch, beforeRange, search;
99-
// try to keep this consistent with before stuff in frontend/editors/markdown-input/component.tsx
100100
if (charBeforeCursor == "@") {
101101
beforeRange = {
102102
focus: editor.selection.focus,
@@ -121,10 +121,11 @@ export const useMentions: (Options) => MentionsControl = ({
121121
afterMatch = afterText.match(/^(\s|$)/);
122122
}
123123
if (
124-
(charBeforeCursor == "@" || (beforeMatch && afterMatch)) &&
125-
(!charBeforeBefore ||
126-
charBeforeBefore == "(" ||
127-
charBeforeBefore == "[")
124+
(charBeforeCursor == "@" &&
125+
(!charBeforeBefore ||
126+
charBeforeBefore == "(" ||
127+
charBeforeBefore == "[")) ||
128+
(beforeMatch && afterMatch)
128129
) {
129130
setTarget(beforeRange);
130131
setSearch(search);

0 commit comments

Comments
 (0)