Skip to content

Commit 96fcca5

Browse files
committed
fix markdown case of #7563 -- @mentions are too aggressive
1 parent 0be87bb commit 96fcca5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/packages/frontend/editors/markdown-input/component.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,16 @@ export function MarkdownInput(props: Props) {
365365
e.setAttribute("style", s);
366366

367367
if (enableMentions) {
368-
cm.current.on("change", (_cm, changeObj) => {
368+
cm.current.on("change", (cm, changeObj) => {
369369
if (changeObj.text[0] == "@") {
370-
show_mentions();
370+
const before = cm
371+
.getLine(changeObj.to.line)
372+
.slice(changeObj.to.ch - 1, changeObj.to.ch)
373+
?.trim();
374+
// If previous character is whitespace or nothing, then activate mentions:
375+
if (!before || before == "(" || before == "[") {
376+
show_mentions();
377+
}
371378
}
372379
});
373380
}
@@ -803,7 +810,6 @@ export function MarkdownInput(props: Props) {
803810

804811
// make sure that mentions is closed if we switch to another tab.
805812
useEffect(() => {
806-
console.log("")
807813
if (mentions && !isVisible) {
808814
close_mentions();
809815
}

0 commit comments

Comments
 (0)