mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IDEA-303665 fixed wrong alignment for text completion popup
GitOrigin-RevId: 144579858f1edd8218332e0b0372498b2224cc7d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb9d6ac6ce
commit
a15c4b5895
@@ -130,7 +130,7 @@ abstract class TextCompletionField<T>(private val project: Project?) : Extendabl
|
||||
}
|
||||
popup = TextCompletionPopup(project, this, contributor, renderer)
|
||||
.also { Disposer.register(it, Disposable { popup = null }) }
|
||||
.also { it.showUnderneathOf(this) }
|
||||
.apply { showUnderneathOfTextComponent() }
|
||||
}
|
||||
updatePopup()
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.externalSystem.service.ui.completion
|
||||
|
||||
import com.intellij.codeInsight.lookup.impl.LookupCellRenderer.*
|
||||
import com.intellij.codeInsight.lookup.impl.LookupCellRenderer.BACKGROUND_COLOR
|
||||
import com.intellij.codeInsight.lookup.impl.LookupCellRenderer.SELECTED_BACKGROUND_COLOR
|
||||
import com.intellij.lang.LangBundle
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.addKeyboardAction
|
||||
import com.intellij.openapi.ui.getKeyStrokes
|
||||
import com.intellij.openapi.ui.popup.AlignedPopup
|
||||
import com.intellij.openapi.ui.popup.ListPopupStep
|
||||
import com.intellij.openapi.ui.popup.ListSeparator
|
||||
import com.intellij.openapi.ui.popup.util.BaseStep
|
||||
@@ -15,10 +17,7 @@ import com.intellij.ui.ColoredListCellRenderer
|
||||
import com.intellij.ui.popup.list.ListPopupImpl
|
||||
import java.awt.Dimension
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.Icon
|
||||
import javax.swing.JList
|
||||
import javax.swing.ListCellRenderer
|
||||
import javax.swing.ListSelectionModel
|
||||
import javax.swing.*
|
||||
|
||||
class TextCompletionPopup<T>(
|
||||
project: Project?,
|
||||
@@ -32,13 +31,16 @@ class TextCompletionPopup<T>(
|
||||
fun update() {
|
||||
listModel.updateOriginalList()
|
||||
|
||||
val insets = textComponent.insets
|
||||
val popupWidth = textComponent.width - (insets.right + insets.left)
|
||||
val rowNumber = maxOf(1, minOf(list.model.size, list.visibleRowCount))
|
||||
val popupHeight = list.fixedCellHeight * rowNumber
|
||||
val popupWidth = textComponent.width
|
||||
val numLines = maxOf(1, minOf(list.model.size, list.visibleRowCount))
|
||||
val popupHeight = list.fixedCellHeight * numLines
|
||||
size = Dimension(popupWidth, popupHeight)
|
||||
}
|
||||
|
||||
fun showUnderneathOfTextComponent() {
|
||||
AlignedPopup.showUnderneathWithoutAlignment(this, textComponent)
|
||||
}
|
||||
|
||||
override fun process(aEvent: KeyEvent) {
|
||||
if (aEvent.keyCode != KeyEvent.VK_LEFT &&
|
||||
aEvent.keyCode != KeyEvent.VK_RIGHT) {
|
||||
|
||||
Reference in New Issue
Block a user