mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(jetbrains): hide focused prompt separator
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@kilocode/kilo-jetbrains": patch
|
||||
---
|
||||
|
||||
Hide the JetBrains prompt separator while the prompt is focused.
|
||||
+23
-3
@@ -133,6 +133,7 @@ class PromptPanel(
|
||||
var onAutoApproveToggle: (Boolean) -> Unit = {}
|
||||
var onFileDrag: (Boolean) -> Unit = {}
|
||||
private var style = SessionEditorStyle.current()
|
||||
private var focused = false
|
||||
private val shell = BorderLayoutPanel().apply {
|
||||
isOpaque = true
|
||||
border = JBUI.Borders.empty(
|
||||
@@ -198,11 +199,11 @@ class PromptPanel(
|
||||
})
|
||||
ed.contentComponent.addFocusListener(object : FocusAdapter() {
|
||||
override fun focusGained(e: FocusEvent) {
|
||||
repaint()
|
||||
syncFocus(true)
|
||||
}
|
||||
|
||||
override fun focusLost(e: FocusEvent) {
|
||||
repaint()
|
||||
syncFocus(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -301,8 +302,27 @@ class PromptPanel(
|
||||
|
||||
override fun updateUI() {
|
||||
super.updateUI()
|
||||
syncBorder()
|
||||
}
|
||||
|
||||
private fun syncFocus(value: Boolean) {
|
||||
if (focused == value) {
|
||||
repaint()
|
||||
return
|
||||
}
|
||||
focused = value
|
||||
syncBorder()
|
||||
revalidate()
|
||||
repaint()
|
||||
}
|
||||
|
||||
private fun syncBorder() {
|
||||
border = JBUI.Borders.compound(
|
||||
JBUI.Borders.customLineTop(SessionUiStyle.View.Prompt.separator()),
|
||||
if (focused) {
|
||||
JBUI.Borders.emptyTop(JBUI.scale(1))
|
||||
} else {
|
||||
JBUI.Borders.customLineTop(SessionUiStyle.View.Prompt.separator())
|
||||
},
|
||||
JBUI.Borders.empty(),
|
||||
)
|
||||
}
|
||||
|
||||
+6
@@ -80,6 +80,7 @@ import java.awt.KeyboardFocusManager
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.awt.datatransfer.StringSelection
|
||||
import java.awt.datatransfer.Transferable
|
||||
import java.awt.event.FocusEvent
|
||||
import java.awt.event.MouseEvent
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayOutputStream
|
||||
@@ -161,10 +162,15 @@ class PromptPanelTest : BasePlatformTestCase() {
|
||||
val focus = TestFocusManager()
|
||||
KeyboardFocusManager.setCurrentKeyboardFocusManager(focus)
|
||||
try {
|
||||
assertEquals(SessionUiStyle.View.Prompt.separator().rgb, paint(panel, panel.width / 2, 0).rgb)
|
||||
assertTrue(JBUI.CurrentTheme.Focus.focusColor().rgb != paint(panel, panel.width / 2, 1).rgb)
|
||||
|
||||
focus.focus(editor.contentComponent)
|
||||
editor.contentComponent.focusListeners.forEach {
|
||||
it.focusGained(FocusEvent(editor.contentComponent, FocusEvent.FOCUS_GAINED))
|
||||
}
|
||||
|
||||
assertTrue(SessionUiStyle.View.Prompt.separator().rgb != paint(panel, panel.width / 2, 0).rgb)
|
||||
assertEquals(JBUI.CurrentTheme.Focus.focusColor().rgb, paint(panel, panel.width / 2, 1).rgb)
|
||||
} finally {
|
||||
KeyboardFocusManager.setCurrentKeyboardFocusManager(current)
|
||||
|
||||
Reference in New Issue
Block a user