Elffuss BraidHub

kikocis/continue public

skip current file addition when there is content in editor
Changesetafb534f77e37312546ee8985592e606f106c2f63882d967f0d8f4bcbe7ccd525
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-11 10:20 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-07-11 10:20 +05:30
Parentsd6d753418588

Browse the files at this changeset

1 file changed

modified gui/src/components/mainInput/TipTapEditor/utils/insertCurrentFileContextMention.ts +24 −0
@@ -2,15 +2,39 @@
22 import { ContextProviderDescription } from "core";
33 import { Mention } from "../extensions";
44
5+function isEditorContentEmpty(editor: Editor): boolean {
6+ const editorContent = editor.getJSON();
7+
8+ if (!editorContent.content || editorContent.content.length === 0) {
9+ return true;
10+ }
11+
12+ const firstNode = editorContent.content[0];
13+ if (
14+ firstNode.type === "paragraph" &&
15+ (firstNode.content || []).length === 0
16+ ) {
17+ return true;
18+ }
19+
20+ return false;
21+}
22+
523 /**
624 * inserts the current file context as a removable mention in the editor area
725 *
26+ * skips if there is any other content in the editor
27+ *
828 * uses tiptap's `create` method to create a new node under the hood
929 */
1030 export function insertCurrentFileContextMention(
1131 editor: Editor,
1232 contextProviders: ContextProviderDescription[],
1333 ) {
34+ if (!isEditorContentEmpty(editor)) {
35+ return;
36+ }
37+
1438 const foundCurrentFileProvider = contextProviders.find(
1539 (provider) => provider.title === "currentFile",
1640 );