insert inlays above

This commit is contained in:
Nate 2024-09-26 17:27:04 -07:00
parent f37884dee8
commit d1267877f4
3 changed files with 4 additions and 6 deletions

View file

@ -1,7 +1,6 @@
package com.github.continuedev.continueintellijextension.editor
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
import com.google.gson.Gson
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.WriteCommandAction
@ -18,7 +17,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.TextEditor
import com.intellij.openapi.project.Project
import com.intellij.ui.JBColor
import java.awt.event.KeyEvent
import javax.swing.BorderFactory
import javax.swing.JTextArea
import kotlin.math.min
@ -119,7 +117,7 @@ class DiffStreamHandler(
preferredSize = java.awt.Dimension(editor.contentComponent.width, preferredSize.height)
}
val disposable = editorComponentInlaysManager.insertAfter(deletionBufferStartLine - 1, component)
val disposable = editorComponentInlaysManager.insert(deletionBufferStartLine, component, true)
if (disposable != null) {
deletionInlays.add(disposable)
}

View file

@ -41,7 +41,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn
}
@RequiresEdt
fun insertAfter(lineIndex: Int, component: JComponent): Disposable? {
fun insert(lineIndex: Int, component: JComponent, showAbove: Boolean = false): Disposable? {
if (Disposer.isDisposed(this)) return null
if (onlyOneInlay) {
@ -57,7 +57,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn
EditorEmbeddedComponentManager.Properties(EditorEmbeddedComponentManager.ResizePolicy.none(),
null,
true,
false,
showAbove,
0,
offset))?.also {
managedInlays[wrappedComponent] = it

View file

@ -179,7 +179,7 @@ fun openInlineEdit(project: Project?, editor: Editor) {
diffStreamService.reject(editor)
inlayRef.get().dispose()
})
val inlay = manager.insertAfter(lineNumber, panel)
val inlay = manager.insert(startLineNum, panel, true)
panel.revalidate()
inlayRef.set(inlay)
val viewport = (editor as? EditorImpl)?.scrollPane?.viewport