feat: display popup close help text

This commit is contained in:
Carl-Robert Linnupuu 2024-07-26 11:38:59 +03:00
parent e362eb3783
commit f85db97c40
3 changed files with 22 additions and 7 deletions

View file

@ -114,7 +114,7 @@ class EditCodePopover(private val editor: Editor) {
}
separator()
row {
text(CodeGPTBundle.get("editCodePopover.cancel.helpText"))
text(CodeGPTBundle.get("shared.escToCancel"))
.applyToComponent {
font = JBUI.Fonts.smallFont()
}

View file

@ -11,8 +11,11 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.VirtualFileVisitor
import com.intellij.ui.components.JBScrollPane
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.dsl.gridLayout.UnscaledGaps
import com.intellij.util.ui.JBUI
import com.intellij.vcsUtil.showAbove
import ee.carlrobert.codegpt.CodeGPTBundle
import ee.carlrobert.codegpt.settings.persona.PersonaDetails
import ee.carlrobert.codegpt.settings.persona.PersonaSettings
import ee.carlrobert.codegpt.settings.persona.PersonasConfigurable
@ -199,19 +202,30 @@ class SuggestionsPopupManager(
list.revalidate()
list.repaint()
popup?.size = list.preferredSize
popup?.size = Dimension(list.preferredSize.width, list.preferredSize.height + 32)
originalLocation?.let { original ->
val newY = original.y - list.preferredSize.height
val newY = original.y - list.preferredSize.height - 32
popup?.setLocation(Point(original.x, maxOf(newY, 0)))
}
}
private fun createPopup(
preferableFocusComponent: JComponent? = null,
): JBPopup =
service<JBPopupFactory>()
.createComponentPopupBuilder(scrollPane, preferableFocusComponent)
): JBPopup {
val popupPanel = panel {
row { cell(scrollPane).customize(UnscaledGaps.EMPTY) }
separator()
row {
text(CodeGPTBundle.get("shared.escToCancel"))
.customize(UnscaledGaps(left = 4))
.applyToComponent {
font = JBUI.Fonts.smallFont()
}
}
}
return service<JBPopupFactory>()
.createComponentPopupBuilder(popupPanel, preferableFocusComponent)
.setMovable(true)
.setCancelOnClickOutside(false)
.setCancelOnWindowDeactivation(false)
@ -224,4 +238,5 @@ class SuggestionsPopupManager(
}
.setResizable(true)
.createPopup()
}
}

View file

@ -216,6 +216,7 @@ statusBar.widget.tooltip=Status
shared.promptTemplate=Prompt template:
shared.infillPromptTemplate=Infill template:
shared.apiVersion=API version:
shared.escToCancel=Esc to cancel
shared.configuration=Configuration
shared.port=Port:
shared.discard=Discard
@ -240,7 +241,6 @@ editCodePopover.textField.comment=Provide instructions for the code modification
editCodePopover.submitButton.title=Submit Edit
editCodePopover.acceptButton.title=Accept Suggestion
editCodePopover.followUpButton.title=Submit Follow-up
editCodePopover.cancel.helpText=Esc to cancel
smartTextPane.submitButton.title=Send Message
smartTextPane.submitButton.description=Send message
smartTextPane.stopButton.title=Stop