fix: send highlighted code with Ctrl+Shift+J action (#7835)

Related to #7747
This commit is contained in:
Jakub Błach 2025-09-18 21:30:38 +02:00 • committed by GitHub
parent 16766fa76c
commit a64eb6dc42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 19 deletions

View file

@ -61,26 +61,13 @@ class RejectDiffAction : AnAction() {
class FocusContinueInputWithoutClearAction : ContinueToolbarAction() {
override fun toolbarActionPerformed(project: Project) {
project.getBrowser()?.sendToWebview("focusContinueInputWithoutClear")
project.getBrowser()?.focusOnInput()
FocusActionUtil.sendHighlightedCodeWithMessageToWebview(project, "focusContinueInputWithoutClear")
}
}
class FocusContinueInputAction : ContinueToolbarAction() {
override fun toolbarActionPerformed(project: Project) =
focusContinueInput(project)
companion object {
fun focusContinueInput(project: Project?) {
val browser = project?.getBrowser()
?: return
browser.sendToWebview("focusContinueInputWithNewSession")
browser.focusOnInput()
val rif = EditorUtils.getEditor(project)?.getHighlightedRIF()
?: return
val code = HighlightedCodePayload(RangeInFileWithContents(rif.filepath, rif.range, rif.contents))
browser.sendToWebview("highlightedCode", code)
}
override fun toolbarActionPerformed(project: Project) {
FocusActionUtil.sendHighlightedCodeWithMessageToWebview(project, "focusContinueInputWithNewSession")
}
}
@ -115,5 +102,16 @@ class OpenLogsAction : AnAction() {
}
}
object FocusActionUtil {
fun sendHighlightedCodeWithMessageToWebview(project: Project?, messageType: String) {
val browser = project?.getBrowser()
?: return
browser.sendToWebview(messageType)
browser.focusOnInput()
val rif = EditorUtils.getEditor(project)?.getHighlightedRIF()
?: return
val code = HighlightedCodePayload(RangeInFileWithContents(rif.filepath, rif.range, rif.contents))
browser.sendToWebview("highlightedCode", code)
}
}

View file

@ -1,4 +1,4 @@
import com.github.continuedev.continueintellijextension.actions.FocusContinueInputAction
import com.github.continuedev.continueintellijextension.actions.FocusActionUtil
import com.github.continuedev.continueintellijextension.editor.openInlineEdit
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.colors.EditorColorsManager
@ -92,7 +92,7 @@ class ToolTipComponent(editor: Editor, x: Int, y: Int) :
editButton = StyledButton("Edit (${cmdCtrlChar}+I)")
addToChatButton.addActionListener { e: ActionEvent? ->
FocusContinueInputAction.focusContinueInput(editor.project)
FocusActionUtil.sendHighlightedCodeWithMessageToWebview(editor.project, "focusContinueInputWithNewSession")
editor.contentComponent.remove(this)
}
editButton.addActionListener { e: ActionEvent? ->