diff --git a/build.gradle.kts b/build.gradle.kts index e3db85c..1659c40 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ repositories { intellij { type.set("IU") - version.set("2023.2") + version.set("233.11799-EAP-CANDIDATE-SNAPSHOT") updateSinceUntilBuild.set(false) plugins.add("com.intellij.java") @@ -35,7 +35,7 @@ dependencies { } tasks.patchPluginXml { - sinceBuild.set("232") + sinceBuild.set("233.11799.30") } tasks.test { diff --git a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/codeCompletion/CodeCompletionPopupListener.kt b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/codeCompletion/CodeCompletionPopupListener.kt index 7a6ec47..e0aa389 100644 --- a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/codeCompletion/CodeCompletionPopupListener.kt +++ b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/codeCompletion/CodeCompletionPopupListener.kt @@ -1,10 +1,13 @@ package com.chylex.intellij.keyboardmaster.feature.codeCompletion import com.intellij.codeInsight.lookup.Lookup +import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementPresentation import com.intellij.codeInsight.lookup.LookupManagerListener +import com.intellij.codeInsight.lookup.impl.LookupCellRenderer.ItemPresentationCustomizer import com.intellij.codeInsight.lookup.impl.LookupImpl import com.intellij.openapi.util.Key +import javax.swing.Icon /** * Adds hints to code completion popup items with the character that selects the item. @@ -37,26 +40,32 @@ class CodeCompletionPopupListener : LookupManagerListener { newLookup.putUserData(IS_MODIFIED_KEY, true) @Suppress("UnstableApiUsage") - newLookup.addPresentationCustomizer { item, presentation -> - val itemList = newLookup.list.model - val itemCount = itemList.size - val offset = getPageOffset(newLookup) - - for (index in 0 until CodeCompletionPopupConfiguration.itemShortcutCount) { - val itemIndex = offset + index - if (itemIndex >= itemCount) { - break + newLookup.addPresentationCustomizer(object : ItemPresentationCustomizer { + override fun customizePresentation(item: LookupElement, presentation: LookupElementPresentation): LookupElementPresentation { + val itemList = newLookup.list.model + val itemCount = itemList.size + val offset = getPageOffset(newLookup) + + for (index in 0 until CodeCompletionPopupConfiguration.itemShortcutCount) { + val itemIndex = offset + index + if (itemIndex >= itemCount) { + break + } + + if (item === itemList.getElementAt(itemIndex)) { + val customized = LookupElementPresentation() + customized.copyFrom(presentation) + customized.appendTailTextItalic(CodeCompletionPopupConfiguration.getHintText(index), true) + return customized + } } - if (item === itemList.getElementAt(itemIndex)) { - val customized = LookupElementPresentation() - customized.copyFrom(presentation) - customized.appendTailTextItalic(CodeCompletionPopupConfiguration.getHintText(index), true) - return@addPresentationCustomizer customized - } + return presentation } - presentation - } + override fun customizeEmptyIcon(icon: Icon): Icon { + return icon + } + }) } }