Merge pull request #3149 from facelezzzz/i_2518
Show IDE completions side-by-side
This commit is contained in:
commit
9bccbf74fb
4 changed files with 44 additions and 5 deletions
|
|
@ -0,0 +1,25 @@
|
|||
package com.github.continuedev.continueintellijextension.actions
|
||||
|
||||
import com.github.continuedev.continueintellijextension.autocomplete.AcceptAutocompleteAction
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.intellij.openapi.actionSystem.ActionPromoter
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
class ContinueActionPromote : ActionPromoter {
|
||||
|
||||
override fun promote(@NotNull actions: List<AnAction>, @NotNull context: DataContext): List<AnAction>? {
|
||||
|
||||
if (actions.none { it is AcceptAutocompleteAction }) {
|
||||
return null
|
||||
} else {
|
||||
val settings = ServiceManager.getService(ContinueExtensionSettings::class.java)
|
||||
if (!settings.continueState.showIDECompletionSideBySide) {
|
||||
return null;
|
||||
}
|
||||
return actions.filterIsInstance<AcceptAutocompleteAction>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,8 +98,7 @@ class AutocompleteService(private val project: Project) {
|
|||
|
||||
if (shouldRenderCompletion(finalTextToInsert, column, lineLength, editor)) {
|
||||
renderCompletion(editor, offset, finalTextToInsert)
|
||||
pendingCompletion = pendingCompletion?.copy(text = finalTextToInsert)
|
||||
|
||||
pendingCompletion = PendingCompletion(editor, offset, completionId, finalTextToInsert)
|
||||
// Hide auto-popup
|
||||
// AutoPopupController.getInstance(project).cancelAllRequests()
|
||||
}
|
||||
|
|
@ -152,8 +151,8 @@ class AutocompleteService(private val project: Project) {
|
|||
return
|
||||
}
|
||||
if (isInjectedFile(editor)) return
|
||||
// Don't render completions when code completion dropdown is visible
|
||||
if (!autocompleteLookupListener.isLookupEmpty()) {
|
||||
// Skip rendering completions if the code completion dropdown is already visible and the IDE completion side-by-side setting is disabled
|
||||
if (shouldSkipRender(ServiceManager.getService(ContinueExtensionSettings::class.java))) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -210,6 +209,10 @@ class AutocompleteService(private val project: Project) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun shouldSkipRender(settings: ContinueExtensionSettings) =
|
||||
!settings.continueState.showIDECompletionSideBySide && !autocompleteLookupListener.isLookupEmpty()
|
||||
|
||||
|
||||
private fun splitKeepingDelimiters(input: String, delimiterPattern: String = "\\s+"): List<String> {
|
||||
val initialSplit = input.split("(?<=$delimiterPattern)|(?=$delimiterPattern)".toRegex())
|
||||
.filter { it.isNotEmpty() }
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class ContinueSettingsComponent : DumbAware {
|
|||
val enableContinueTeamsBeta: JCheckBox = JCheckBox("Enable Continue for Teams Beta")
|
||||
val enableOSR: JCheckBox = JCheckBox("Enable Off-Screen Rendering")
|
||||
val displayEditorTooltip: JCheckBox = JCheckBox("Display Editor Tooltip")
|
||||
val showIDECompletionSideBySide: JCheckBox = JCheckBox("Show IDE completions side-by-side")
|
||||
|
||||
init {
|
||||
val constraints = GridBagConstraints()
|
||||
|
|
@ -63,6 +64,8 @@ class ContinueSettingsComponent : DumbAware {
|
|||
constraints.gridy++
|
||||
panel.add(displayEditorTooltip, constraints)
|
||||
constraints.gridy++
|
||||
panel.add(showIDECompletionSideBySide, constraints)
|
||||
constraints.gridy++
|
||||
|
||||
// Add a "filler" component that takes up all remaining vertical space
|
||||
constraints.weighty = 1.0
|
||||
|
|
@ -94,6 +97,7 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
|
|||
var enableContinueTeamsBeta: Boolean = false
|
||||
var enableOSR: Boolean = shouldRenderOffScreen()
|
||||
var displayEditorTooltip: Boolean = true
|
||||
var showIDECompletionSideBySide: Boolean = false
|
||||
}
|
||||
|
||||
var continueState: ContinueState = ContinueState()
|
||||
|
|
@ -206,7 +210,8 @@ class ContinueExtensionConfigurable : Configurable {
|
|||
mySettingsComponent?.enableTabAutocomplete?.isSelected != settings.continueState.enableTabAutocomplete ||
|
||||
mySettingsComponent?.enableContinueTeamsBeta?.isSelected != settings.continueState.enableContinueTeamsBeta ||
|
||||
mySettingsComponent?.enableOSR?.isSelected != settings.continueState.enableOSR ||
|
||||
mySettingsComponent?.displayEditorTooltip?.isSelected != settings.continueState.displayEditorTooltip
|
||||
mySettingsComponent?.displayEditorTooltip?.isSelected != settings.continueState.displayEditorTooltip ||
|
||||
mySettingsComponent?.showIDECompletionSideBySide?.isSelected != settings.continueState.showIDECompletionSideBySide
|
||||
return modified
|
||||
}
|
||||
|
||||
|
|
@ -220,6 +225,8 @@ class ContinueExtensionConfigurable : Configurable {
|
|||
mySettingsComponent?.enableContinueTeamsBeta?.isSelected ?: false
|
||||
settings.continueState.enableOSR = mySettingsComponent?.enableOSR?.isSelected ?: true
|
||||
settings.continueState.displayEditorTooltip = mySettingsComponent?.displayEditorTooltip?.isSelected ?: true
|
||||
settings.continueState.showIDECompletionSideBySide =
|
||||
mySettingsComponent?.showIDECompletionSideBySide?.isSelected ?: false
|
||||
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(SettingsListener.TOPIC)
|
||||
.settingsUpdated(settings.continueState)
|
||||
|
|
@ -235,6 +242,8 @@ class ContinueExtensionConfigurable : Configurable {
|
|||
mySettingsComponent?.enableContinueTeamsBeta?.isSelected = settings.continueState.enableContinueTeamsBeta
|
||||
mySettingsComponent?.enableOSR?.isSelected = settings.continueState.enableOSR
|
||||
mySettingsComponent?.displayEditorTooltip?.isSelected = settings.continueState.displayEditorTooltip
|
||||
mySettingsComponent?.showIDECompletionSideBySide?.isSelected =
|
||||
settings.continueState.showIDECompletionSideBySide
|
||||
|
||||
ContinueExtensionSettings.instance.addRemoteSyncJob()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
id="AutocompleteSpinnerWidget"/>
|
||||
<notificationGroup id="Continue"
|
||||
displayType="BALLOON"/>
|
||||
<actionPromoter order="last"
|
||||
implementation="com.github.continuedev.continueintellijextension.actions.ContinueActionPromote"/>
|
||||
</extensions>
|
||||
|
||||
<resource-bundle>messages.MyBundle</resource-bundle>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue