feat: allow to mention directory
This commit is contained in:
parent
7fb5935e37
commit
6e77df2ea7
4 changed files with 19 additions and 14 deletions
|
|
@ -78,5 +78,8 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
exitEditMode: [undefined, void];
|
||||
focusEdit: [undefined, void];
|
||||
generateRule: [undefined, void];
|
||||
mentionFile: [{ fullFilePath: string; shortFilePath: string }, void];
|
||||
mentionFileOrDirectory: [
|
||||
{ type: "file" | "folder"; fullPath: string; name: string },
|
||||
void,
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,24 +7,26 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
|||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
class MentionFileInChatAction : AnAction() {
|
||||
class MentionFileOrFolderInChatAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
val virtualFile = e.getFile() ?: return
|
||||
|
||||
val type = if (virtualFile.isDirectory) "folder" else "file"
|
||||
val params = mapOf(
|
||||
"fullFilePath" to virtualFile.url,
|
||||
"shortFilePath" to virtualFile.name,
|
||||
"type" to type,
|
||||
"fullPath" to virtualFile.url,
|
||||
"name" to virtualFile.name,
|
||||
)
|
||||
|
||||
continuePluginService.sendToWebview("mentionFile", params)
|
||||
continuePluginService.sendToWebview("mentionFileOrDirectory", params)
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val file = e.getFile()
|
||||
val files = e.getFiles()
|
||||
|
||||
val isAvailable = file != null && !file.isDirectory && files.size == 1
|
||||
val isAvailable = file != null && files.size == 1
|
||||
|
||||
e.presentation.isVisible = isAvailable
|
||||
}
|
||||
|
|
@ -182,9 +182,9 @@
|
|||
<override-text place="GoToAction" text="Continue: Add Highlighted Code to Context and Clear Chat"/>
|
||||
</action>
|
||||
<group id="ContinueProjectViewPopUpMenuGroup" popup="true" text="Continue">
|
||||
<action id="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileInChatAction"
|
||||
class="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileInChatAction"
|
||||
text="Mention File in the Chat">
|
||||
<action id="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileOrFolderInChatAction"
|
||||
class="com.github.continuedev.continueintellijextension.actions.menu.file.MentionFileOrFolderInChatAction"
|
||||
text="Mention in the Chat">
|
||||
</action>
|
||||
|
||||
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export function useMainEditorWebviewListeners({
|
|||
);
|
||||
|
||||
useWebviewListener(
|
||||
"mentionFile",
|
||||
"mentionFileOrDirectory",
|
||||
async (data) => {
|
||||
if (!editor) return;
|
||||
editor
|
||||
|
|
@ -208,10 +208,10 @@ export function useMainEditorWebviewListeners({
|
|||
.insertContent({
|
||||
type: "mention",
|
||||
attrs: {
|
||||
id: data.fullFilePath,
|
||||
query: data.fullFilePath,
|
||||
itemType: "file",
|
||||
label: data.shortFilePath,
|
||||
id: data.fullPath,
|
||||
query: data.fullPath,
|
||||
itemType: data.type,
|
||||
label: data.name,
|
||||
},
|
||||
})
|
||||
.insertContent(" ")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue