Merge pull request #2492 from continuedev/pe/jb-actions-search
jb: add actions to search
This commit is contained in:
commit
6fbd06cb22
4 changed files with 43 additions and 210 deletions
|
|
@ -24,8 +24,8 @@ fun getPluginService(project: Project?): ContinuePluginService? {
|
|||
return null
|
||||
}
|
||||
return ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,8 @@ class AcceptDiffAction : AnAction() {
|
|||
|
||||
private fun acceptVerticalDiff(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val editor = e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val editor =
|
||||
e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val diffStreamService = project.service<DiffStreamService>()
|
||||
diffStreamService.accept(editor)
|
||||
}
|
||||
|
|
@ -61,120 +62,14 @@ class RejectDiffAction : AnAction() {
|
|||
|
||||
private fun rejectVerticalDiff(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val editor = e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val editor =
|
||||
e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val diffStreamService = project.service<DiffStreamService>()
|
||||
diffStreamService.reject(editor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickInputDialogWrapper : DialogWrapper(true) {
|
||||
private var panel: JPanel? = null
|
||||
private var textArea: JTextArea? = null
|
||||
init {
|
||||
init()
|
||||
title = "Continue Quick Input"
|
||||
}
|
||||
|
||||
override fun getPreferredFocusedComponent(): JComponent? {
|
||||
return textArea
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
panel = JPanel(BorderLayout())
|
||||
textArea = JTextArea(3, 60)
|
||||
textArea?.lineWrap = true
|
||||
textArea?.wrapStyleWord = true
|
||||
|
||||
// Add a DocumentListener to the JTextArea
|
||||
textArea?.document?.addDocumentListener(object : DocumentListener {
|
||||
override fun insertUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun removeUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun changedUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
private fun updateSize() {
|
||||
val text = textArea?.text ?: ""
|
||||
val lines = text.count { it == '\n' } + 1
|
||||
val metrics = textArea?.getFontMetrics(textArea?.font)
|
||||
val lineHeight = metrics?.height ?: 0
|
||||
textArea?.preferredSize = Dimension(textArea?.width ?: 0, lines * lineHeight)
|
||||
|
||||
// Revalidate the JPanel to reflect the changes
|
||||
panel?.revalidate()
|
||||
}
|
||||
})
|
||||
|
||||
val scrollPane = JBScrollPane(textArea)
|
||||
scrollPane.verticalScrollBarPolicy = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
|
||||
panel?.add(scrollPane, BorderLayout.CENTER)
|
||||
|
||||
return panel
|
||||
}
|
||||
|
||||
|
||||
fun showDialogAndGetText(): String? {
|
||||
show()
|
||||
return if (this.exitCode == OK_EXIT_CODE) {
|
||||
textArea!!.text
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickTextEntryAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
continuePluginService.ideProtocolClient?.sendHighlightedCode()
|
||||
|
||||
// Create and show the dialog
|
||||
val dialog = QuickInputDialogWrapper()
|
||||
val text: String? = dialog.showDialogAndGetText()
|
||||
|
||||
// Show the text entered by the user
|
||||
if (text != null) {
|
||||
val service = getPluginService(e.project)
|
||||
service?.ideProtocolClient?.sendMainUserInput(text)
|
||||
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInput", null)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewLogsAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
Messages.showMessageDialog(
|
||||
"This action is not yet implemented",
|
||||
"Continue Action not Implemented",
|
||||
Messages.getInformationIcon()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun focusContinueInput(project: Project?) {
|
||||
fun getContinuePluginService(project: Project?): ContinuePluginService? {
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
|
@ -186,7 +81,11 @@ fun focusContinueInput(project: Project?) {
|
|||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(project) ?: return
|
||||
return getPluginService(project)
|
||||
}
|
||||
|
||||
fun focusContinueInput(project: Project?) {
|
||||
val continuePluginService = getContinuePluginService(project) ?: return
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInputWithoutClear", null)
|
||||
|
||||
|
|
@ -202,19 +101,7 @@ class FocusContinueInputWithoutClearAction : AnAction() {
|
|||
|
||||
class FocusContinueInputAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInput", null)
|
||||
|
|
@ -225,20 +112,7 @@ class FocusContinueInputAction : AnAction() {
|
|||
|
||||
class NewContinueSessionAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInputWithNewSession", null)
|
||||
}
|
||||
|
|
@ -246,14 +120,7 @@ class NewContinueSessionAction : AnAction() {
|
|||
|
||||
class ViewHistoryAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
continuePluginService.sendToWebview("viewHistory", null)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.github.continuedev.continueintellijextension.editor
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
|
||||
class ToggleInlineEditAction : AnAction(), DumbAware {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.getData(PlatformDataKeys.PROJECT) ?: return
|
||||
val editor = e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val diffService = project.service<DiffStreamService>()
|
||||
val handler = diffService.getHandler(editor)
|
||||
if (handler == null) {
|
||||
val actionId = "continue.inlineEdit"
|
||||
val action = ActionManager.getInstance().getAction(actionId)
|
||||
if (action != null) {
|
||||
e.actionManager.tryToExecute(action, e.inputEvent, null, null, true)
|
||||
}
|
||||
} else {
|
||||
handler.toggleFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,11 +9,13 @@
|
|||
<idea-version since-build="223.7571.182"/>
|
||||
|
||||
<extensions defaultExtensionNs="JavaScript.JsonSchema">
|
||||
<ProviderFactory implementation="com.github.continuedev.continueintellijextension.continue.ConfigJsonSchemaProviderFactory"/>
|
||||
<ProviderFactory
|
||||
implementation="com.github.continuedev.continueintellijextension.continue.ConfigJsonSchemaProviderFactory"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<editorFactoryListener implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteEditorListener"/>
|
||||
<editorFactoryListener
|
||||
implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteEditorListener"/>
|
||||
<toolWindow id="Continue" anchor="right" icon="/tool-window-icon.svg"
|
||||
factoryClass="com.github.continuedev.continueintellijextension.toolWindow.ContinuePluginToolWindowFactory"/>
|
||||
<projectService id="ContinuePluginService"
|
||||
|
|
@ -24,8 +26,9 @@
|
|||
<projectService
|
||||
id="AutocompleteLookupListener"
|
||||
serviceImplementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteLookupListener"/>
|
||||
<statusBarWidgetFactory implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteSpinnerWidgetFactory"
|
||||
id="AutocompleteSpinnerWidget"/>
|
||||
<statusBarWidgetFactory
|
||||
implementation="com.github.continuedev.continueintellijextension.autocomplete.AutocompleteSpinnerWidgetFactory"
|
||||
id="AutocompleteSpinnerWidget"/>
|
||||
</extensions>
|
||||
|
||||
<resource-bundle>messages.MyBundle</resource-bundle>
|
||||
|
|
@ -45,56 +48,40 @@
|
|||
<actions>
|
||||
<action class="com.github.continuedev.continueintellijextension.editor.InlineEditAction"
|
||||
id="continue.inlineEdit"
|
||||
icon="/tool-window-icon.svg"
|
||||
description="Inline Edit"
|
||||
text="Inline Edit">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="ctrl I"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta I"/>
|
||||
</action>
|
||||
|
||||
<action class="com.github.continuedev.continueintellijextension.editor.ToggleInlineEditAction"
|
||||
id="continue.toggleInlineEdit"
|
||||
description="Toggle Inline Edit"
|
||||
text="Toggle Inline Edit">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="ctrl shift I"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta shift I"/>
|
||||
<override-text place="GoToAction" text="Continue: Edit Code"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.acceptDiff"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.AcceptDiffAction"
|
||||
text="Accept Diff" description="Accept Diff">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt shift Y"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt shift Y"/>
|
||||
<override-text place="GoToAction" text="Continue: Accept Diff"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.rejectDiff"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.RejectDiffAction"
|
||||
text="Reject Diff" description="Reject Diff">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt shift N"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt shift N"/>
|
||||
<override-text place="GoToAction" text="Continue: Reject Diff "/>
|
||||
</action>
|
||||
<action id="continue.quickTextEntry"
|
||||
class="com.github.continuedev.continueintellijextension.actions.QuickTextEntryAction"
|
||||
text="Quick Text Entry" description="Quick Text Entry">
|
||||
<keyboard-shortcut keymap="$default"
|
||||
first-keystroke="alt shift J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="alt shift J"/>
|
||||
</action>
|
||||
<action id="continue.viewLogs"
|
||||
class="com.github.continuedev.continueintellijextension.actions.ViewLogsAction"
|
||||
text="View Continue Server Logs"
|
||||
description="View Continue Server Logs">
|
||||
<!-- No shortcut defined -->
|
||||
</action>
|
||||
|
||||
|
||||
<action id="continue.focusContinueInputWithoutClear"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.FocusContinueInputWithoutClearAction"
|
||||
text="Add selected code to context"
|
||||
description="Focus Continue Input With Edit">
|
||||
|
|
@ -102,25 +89,28 @@
|
|||
first-keystroke="ctrl shift J"/>
|
||||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta shift J"/>
|
||||
<override-text place="GoToAction" text="Continue: Add Highlighted Code to Context"/>
|
||||
</action>
|
||||
|
||||
<!-- <action id="InsertLiveTemplate" class="com.intellij.openapi.actionSystem.EmptyAction" />-->
|
||||
<!-- <action id="SurroundWithLiveTemplate" class="com.intellij.openapi.actionSystem.EmptyAction"/>-->
|
||||
|
||||
<action id="continue.newContinueSession"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.NewContinueSessionAction"
|
||||
text="Start New Continue Session"
|
||||
icon="AllIcons.General.Add"
|
||||
description="Start New Continue Session">
|
||||
|
||||
<override-text place="GoToAction" text="Continue: New Session"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.viewHistory"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.ViewHistoryAction"
|
||||
text="View History"
|
||||
icon="AllIcons.Vcs.History"
|
||||
description="View History">
|
||||
<override-text place="GoToAction" text="Continue: View History"/>
|
||||
</action>
|
||||
|
||||
<action id="continue.focusContinueInput"
|
||||
icon="/tool-window-icon.svg"
|
||||
class="com.github.continuedev.continueintellijextension.actions.FocusContinueInputAction"
|
||||
text="Add selected code to context"
|
||||
description="Focus Continue Input">
|
||||
|
|
@ -129,6 +119,7 @@
|
|||
<keyboard-shortcut keymap="Mac OS X"
|
||||
first-keystroke="meta J"/>
|
||||
<add-to-group group-id="EditorPopupMenu"/>
|
||||
<override-text place="GoToAction" text="Continue: Add Highlighted Code to Context and Clear Chat"/>
|
||||
</action>
|
||||
|
||||
<group id="ContinueSidebarActionsGroup">
|
||||
|
|
@ -142,11 +133,13 @@
|
|||
<keyboard-shortcut keymap="$default" first-keystroke="TAB"/>
|
||||
<keyboard-shortcut keymap="Mac OS X" first-keystroke="TAB"/>
|
||||
</action>
|
||||
|
||||
<action id="com.github.continuedev.continueintellijextension.autocomplete.CancelAutocompleteAction"
|
||||
class="com.github.continuedev.continueintellijextension.autocomplete.CancelAutocompleteAction"
|
||||
text="Cancel Autocomplete Suggestion" description="Cancel Autocomplete Suggestion">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="ESCAPE"/>
|
||||
</action>
|
||||
|
||||
<action id="com.github.continuedev.continueintellijextension.autocomplete.PartialAcceptAutocompleteAction"
|
||||
class="com.github.continuedev.continueintellijextension.autocomplete.PartialAcceptAutocompleteAction"
|
||||
text="Partial Accept Autocomplete Suggestion"
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@
|
|||
{
|
||||
"command": "continue.focusContinueInput",
|
||||
"category": "Continue",
|
||||
"title": "Add Highlighted Code to Context",
|
||||
"title": "Add Highlighted Code to Context and Clear Chat",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue