Elffuss BraidHub

kikocis/continue public

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

Related to #7747
Changeset8daf96c029f5e119d16b888e552f75a2239a0d4ebc9993ee5c0ea77875dbdbdd
AuthorJakub Błach <jakubblach@gmail.com> · 2025-09-18 21:30 +02:00
CommitterGitHub <noreply@github.com> · 2025-09-18 12:30 -07:00
Parents1bb8efeda114

Browse the files at this changeset

2 files changed

modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +15 −17
@@ -61,26 +61,13 @@
6161
6262 class FocusContinueInputWithoutClearAction : ContinueToolbarAction() {
6363 override fun toolbarActionPerformed(project: Project) {
64- project.getBrowser()?.sendToWebview("focusContinueInputWithoutClear")
65- project.getBrowser()?.focusOnInput()
64+ FocusActionUtil.sendHighlightedCodeWithMessageToWebview(project, "focusContinueInputWithoutClear")
6665 }
6766 }
6867
6968 class FocusContinueInputAction : ContinueToolbarAction() {
70- override fun toolbarActionPerformed(project: Project) =
71- focusContinueInput(project)
72-
73- companion object {
74- fun focusContinueInput(project: Project?) {
75- val browser = project?.getBrowser()
76- ?: return
77- browser.sendToWebview("focusContinueInputWithNewSession")
78- browser.focusOnInput()
79- val rif = EditorUtils.getEditor(project)?.getHighlightedRIF()
80- ?: return
81- val code = HighlightedCodePayload(RangeInFileWithContents(rif.filepath, rif.range, rif.contents))
82- browser.sendToWebview("highlightedCode", code)
83- }
69+ override fun toolbarActionPerformed(project: Project) {
70+ FocusActionUtil.sendHighlightedCodeWithMessageToWebview(project, "focusContinueInputWithNewSession")
8471 }
8572 }
8673
@@ -115,5 +102,16 @@
115102 }
116103 }
117104
118-
105+object FocusActionUtil {
106+ fun sendHighlightedCodeWithMessageToWebview(project: Project?, messageType: String) {
107+ val browser = project?.getBrowser()
108+ ?: return
109+ browser.sendToWebview(messageType)
110+ browser.focusOnInput()
111+ val rif = EditorUtils.getEditor(project)?.getHighlightedRIF()
112+ ?: return
113+ val code = HighlightedCodePayload(RangeInFileWithContents(rif.filepath, rif.range, rif.contents))
114+ browser.sendToWebview("highlightedCode", code)
115+ }
116+}
119117
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/ToolTipComponent.kt +2 −2
@@ -1,4 +1,4 @@
1-import com.github.continuedev.continueintellijextension.actions.FocusContinueInputAction
1+import com.github.continuedev.continueintellijextension.actions.FocusActionUtil
22 import com.github.continuedev.continueintellijextension.editor.openInlineEdit
33 import com.intellij.openapi.editor.Editor
44 import com.intellij.openapi.editor.colors.EditorColorsManager
@@ -92,7 +92,7 @@
9292 editButton = StyledButton("Edit (${cmdCtrlChar}+I)")
9393
9494 addToChatButton.addActionListener { e: ActionEvent? ->
95- FocusContinueInputAction.focusContinueInput(editor.project)
95+ FocusActionUtil.sendHighlightedCodeWithMessageToWebview(editor.project, "focusContinueInputWithNewSession")
9696 editor.contentComponent.remove(this)
9797 }
9898 editButton.addActionListener { e: ActionEvent? ->