close dropdown after making new prompt file

This commit is contained in:
Nate 2024-11-08 18:41:34 -08:00
parent bd612261f0
commit 6888753b20

View file

@ -216,6 +216,15 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
type: "action",
action: () => {
ideMessenger.request("config/newPromptFile", undefined);
const { tr } = props.editor.view.state;
const text = tr.doc.textBetween(0, tr.selection.from);
const start = text.lastIndexOf("@");
if (start !== -1) {
props.editor.view.dispatch(
tr.delete(start, tr.selection.from).scrollIntoView(),
);
}
props.onClose(); // Escape the mention list after creating a new prompt file
},
description: "Create a new .prompt file",
});