mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-18 23:42:49 +00:00
Critical edit field bug fix
- Fixed issue when attached files were over 1 line, no more text input were accessible - Adjusted edit lines to 2 instead of 1 for better view
This commit is contained in:
parent
e7208b5e79
commit
a30fd8ea25
5 changed files with 34 additions and 6 deletions
|
|
@ -291,6 +291,7 @@ class PromptTextField(
|
|||
editorEx.settings.isUseSoftWraps = true
|
||||
editorEx.backgroundColor = service<EditorColorsManager>().globalScheme.defaultBackground
|
||||
setupDocumentListener(editorEx)
|
||||
adjustHeight(editorEx)
|
||||
return editorEx
|
||||
}
|
||||
|
||||
|
|
@ -660,6 +661,7 @@ class PromptTextField(
|
|||
private fun adjustHeight(editor: EditorEx) {
|
||||
val contentHeight =
|
||||
editor.contentComponent.preferredSize.height + PromptTextFieldConstants.HEIGHT_PADDING
|
||||
val minimumHeight = calculateMinimumHeight(editor)
|
||||
|
||||
val toolWindow = project.service<ToolWindowManager>().getToolWindow("ProxyAI")
|
||||
val maxHeight = if (toolWindow == null || !toolWindow.component.isAncestorOf(this)) {
|
||||
|
|
@ -667,7 +669,7 @@ class PromptTextField(
|
|||
} else {
|
||||
JBUI.scale(getToolWindowHeight(toolWindow) / 2)
|
||||
}
|
||||
val newHeight = minOf(contentHeight, maxHeight)
|
||||
val newHeight = minOf(maxOf(contentHeight, minimumHeight), maxHeight)
|
||||
|
||||
runInEdt {
|
||||
preferredSize = Dimension(width, newHeight)
|
||||
|
|
@ -676,6 +678,13 @@ class PromptTextField(
|
|||
}
|
||||
}
|
||||
|
||||
private fun calculateMinimumHeight(editor: EditorEx): Int {
|
||||
val verticalPadding = JBUI.scale(
|
||||
PromptTextFieldConstants.HEIGHT_PADDING + PromptTextFieldConstants.BORDER_PADDING * 2
|
||||
)
|
||||
return editor.lineHeight * PromptTextFieldConstants.MIN_VISIBLE_LINES + verticalPadding
|
||||
}
|
||||
|
||||
private fun getToolWindowHeight(toolWindow: ToolWindow): Int {
|
||||
val h = toolWindow.component.visibleRect.height
|
||||
return if (h > 0) h else PromptTextFieldConstants.DEFAULT_TOOL_WINDOW_HEIGHT
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ object PromptTextFieldConstants {
|
|||
const val SEARCH_DELAY_MS = 200L
|
||||
const val MIN_DYNAMIC_SEARCH_LENGTH = 2
|
||||
const val MAX_SEARCH_RESULTS = 100
|
||||
const val MIN_VISIBLE_LINES = 2
|
||||
const val DEFAULT_TOOL_WINDOW_HEIGHT = 400
|
||||
const val BORDER_PADDING = 4
|
||||
const val BORDER_SIDE_PADDING = 8
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ class UserInputPanel @JvmOverloads constructor(
|
|||
withRemovableSelectedEditorTag,
|
||||
onApply,
|
||||
getMarkdownContent,
|
||||
featureType
|
||||
featureType,
|
||||
::schedulePreferredSizeUpdate
|
||||
)
|
||||
|
||||
private var footerPanelRef: JPanel? = null
|
||||
|
|
@ -272,9 +273,11 @@ class UserInputPanel @JvmOverloads constructor(
|
|||
addToBottom(createFooterPanel(featureType).also { footerPanelRef = it })
|
||||
|
||||
promptTextField.addPropertyChangeListener("preferredSize") { _ ->
|
||||
runInEdt { updatePreferredSizeFromChildren() }
|
||||
schedulePreferredSizeUpdate()
|
||||
}
|
||||
|
||||
schedulePreferredSizeUpdate()
|
||||
|
||||
if (featureType == FeatureType.INLINE_EDIT) {
|
||||
invokeLater { updatePreferredSizeFromChildren() }
|
||||
minimumSize = Dimension(JBUI.scale(600), JBUI.scale(80))
|
||||
|
|
@ -289,10 +292,18 @@ class UserInputPanel @JvmOverloads constructor(
|
|||
|
||||
private fun setupTextChangeListener() {
|
||||
userInputHeaderPanel.addPropertyChangeListener("preferredSize") { _ ->
|
||||
runInEdt { updatePreferredSizeFromChildren() }
|
||||
schedulePreferredSizeUpdate()
|
||||
}
|
||||
footerPanelRef?.addPropertyChangeListener("preferredSize") { _ ->
|
||||
runInEdt { updatePreferredSizeFromChildren() }
|
||||
schedulePreferredSizeUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun schedulePreferredSizeUpdate() {
|
||||
invokeLater {
|
||||
if (!Disposer.isDisposed(parentDisposable)) {
|
||||
updatePreferredSizeFromChildren()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -651,6 +662,7 @@ class UserInputPanel @JvmOverloads constructor(
|
|||
inlineEditControls.forEach { it.isVisible = visible }
|
||||
revalidate()
|
||||
repaint()
|
||||
schedulePreferredSizeUpdate()
|
||||
}
|
||||
|
||||
fun setThinkingVisible(visible: Boolean, text: String = CodeGPTBundle.get("shared.thinking")) {
|
||||
|
|
@ -660,6 +672,7 @@ class UserInputPanel @JvmOverloads constructor(
|
|||
thinkingPanel.isVisible = visible
|
||||
revalidate()
|
||||
repaint()
|
||||
schedulePreferredSizeUpdate()
|
||||
}
|
||||
|
||||
private fun isImageActionSupported(): Boolean {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ class UserInputHeaderPanel(
|
|||
private val withRemovableSelectedEditorTag: Boolean,
|
||||
private val onApply: (() -> Unit)? = null,
|
||||
private val getMarkdownContent: (() -> String)? = null,
|
||||
private val featureType: FeatureType? = null
|
||||
private val featureType: FeatureType? = null,
|
||||
private val onLayoutChanged: () -> Unit = {}
|
||||
) : JPanel(WrapLayout(FlowLayout.LEFT, 4, 4)), TagManagerListener, McpTagUpdateListener {
|
||||
|
||||
companion object {
|
||||
|
|
@ -162,6 +163,7 @@ class UserInputHeaderPanel(
|
|||
invalidate()
|
||||
revalidate()
|
||||
repaint()
|
||||
onLayoutChanged()
|
||||
|
||||
parent?.let {
|
||||
it.invalidate()
|
||||
|
|
@ -276,6 +278,7 @@ class UserInputHeaderPanel(
|
|||
|
||||
revalidate()
|
||||
repaint()
|
||||
onLayoutChanged()
|
||||
}
|
||||
|
||||
private fun createTagPanel(tagDetails: TagDetails) =
|
||||
|
|
@ -332,12 +335,14 @@ class UserInputHeaderPanel(
|
|||
applyChip?.isVisible = visible
|
||||
revalidate()
|
||||
repaint()
|
||||
onLayoutChanged()
|
||||
}
|
||||
|
||||
fun setApplyEnabled(enabled: Boolean) {
|
||||
applyChip?.isEnabled = enabled
|
||||
revalidate()
|
||||
repaint()
|
||||
onLayoutChanged()
|
||||
}
|
||||
|
||||
private fun addInitialTags() {
|
||||
|
|
|
|||
BIN
src/main/resources/icons/qwen.png
Normal file
BIN
src/main/resources/icons/qwen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 713 B |
Loading…
Add table
Add a link
Reference in a new issue