Skip to content

Commit 6e77df2

Browse files
committed
feat: allow to mention directory
1 parent 7fb5935 commit 6e77df2

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

core/protocol/ideWebview.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,8 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
7878
exitEditMode: [undefined, void];
7979
focusEdit: [undefined, void];
8080
generateRule: [undefined, void];
81-
mentionFile: [{ fullFilePath: string; shortFilePath: string }, void];
81+
mentionFileOrDirectory: [
82+
{ type: "file" | "folder"; fullPath: string; name: string },
83+
void,
84+
];
8285
};
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,26 @@ import com.intellij.openapi.actionSystem.AnActionEvent
77
import com.intellij.openapi.actionSystem.CommonDataKeys
88
import com.intellij.openapi.vfs.VirtualFile
99

10-
class MentionFileInChatAction : AnAction() {
10+
class MentionFileOrFolderInChatAction : AnAction() {
1111
override fun actionPerformed(e: AnActionEvent) {
1212
val continuePluginService = getContinuePluginService(e.project) ?: return
1313
val virtualFile = e.getFile() ?: return
1414

15+
val type = if (virtualFile.isDirectory) "folder" else "file"
1516
val params = mapOf(
16-
"fullFilePath" to virtualFile.url,
17-
"shortFilePath" to virtualFile.name,
17+
"type" to type,
18+
"fullPath" to virtualFile.url,
19+
"name" to virtualFile.name,
1820
)
1921

20-
continuePluginService.sendToWebview("mentionFile", params)
22+
continuePluginService.sendToWebview("mentionFileOrDirectory", params)
2123
}
2224

2325
override fun update(e: AnActionEvent) {
2426
val file = e.getFile()
2527
val files = e.getFiles()
2628

27-
val isAvailable = file != null && !file.isDirectory && files.size == 1
29+
val isAvailable = file != null && files.size == 1
2830

2931
e.presentation.isVisible = isAvailable
3032
}

extensions/intellij/src/main/resources/META-INF/plugin.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@
182182
<override-text place="GoToAction" text="Continue: Add Highlighted Code to Context and Clear Chat"/>
183183
</action>
184184
<group id="ContinueProjectViewPopUpMenuGroup" popup="true" text="Continue">
185-
<action id="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileInChatAction"
186-
class="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileInChatAction"
187-
text="Mention File in the Chat">
185+
<action id="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileOrFolderInChatAction"
186+
class="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileOrFolderInChatAction"
187+
text="Mention in the Chat">
188188
</action>
189189

190190
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>

gui/src/components/mainInput/TipTapEditor/useMainEditorWebviewListeners.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,18 @@ export function useMainEditorWebviewListeners({
200200
);
201201

202202
useWebviewListener(
203-
"mentionFile",
203+
"mentionFileOrDirectory",
204204
async (data) => {
205205
if (!editor) return;
206206
editor
207207
.chain()
208208
.insertContent({
209209
type: "mention",
210210
attrs: {
211-
id: data.fullFilePath,
212-
query: data.fullFilePath,
213-
itemType: "file",
214-
label: data.shortFilePath,
211+
id: data.fullPath,
212+
query: data.fullPath,
213+
itemType: data.type,
214+
label: data.name,
215215
},
216216
})
217217
.insertContent(" ")

0 commit comments

Comments
 (0)