Skip to content

Commit 9cdca52

Browse files
committed
fix(codecomplete): fix LLMInlayManager imports for 241 version #109
- Remove unnecessary space in serviceImplementation attribute in autodev-core.xml - Clean up unused import and remove deprecated code in LLMInlayManagerImpl - Simplify and remove temporary save veto handler in LLMInlayManagerImpl
1 parent 2ff3c17 commit 9cdca52

File tree

3 files changed

+5
-33
lines changed

3 files changed

+5
-33
lines changed

src/233/main/resources/META-INF/autodev-core.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<applicationService serviceImplementation="cc.unitmesh.devti.settings.AutoDevSettingsState"/>
3131

3232
<applicationService
33-
serviceInterface=" com.intellij.temporary.inlay.codecomplete.LLMInlayManager"
34-
serviceImplementation=" com.intellij.temporary.inlay.codecomplete.LLMInlayManagerImpl"/>
33+
serviceInterface="com.intellij.temporary.inlay.codecomplete.LLMInlayManager"
34+
serviceImplementation="com.intellij.temporary.inlay.codecomplete.LLMInlayManagerImpl"/>
3535

3636
<typedHandler order="first, before completionAutoPopup"
3737
implementation="cc.unitmesh.devti.inlay.TypeOverHandler"/>

src/main/kotlin/com/intellij/temporary/inlay/codecomplete/LLMEditorSaveVetoer.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/kotlin/com/intellij/temporary/inlay/codecomplete/LLMInlayManagerImpl.kt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import com.intellij.openapi.editor.EditorCustomElementRenderer
1414
import com.intellij.openapi.editor.Inlay
1515
import com.intellij.openapi.editor.ex.EditorEx
1616
import com.intellij.openapi.editor.impl.ImaginaryEditor
17-
import com.intellij.openapi.extensions.ExtensionPoint
1817
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer
1918
import com.intellij.openapi.project.Project
2019
import com.intellij.openapi.util.Disposer
@@ -30,7 +29,6 @@ class LLMInlayManagerImpl : LLMInlayManager {
3029
companion object {
3130
private val logger = logger<LLMInlayManagerImpl>()
3231
private val KEY_LAST_REQUEST = Key.create<CodeCompletionRequest>("llm.editorRequest")
33-
val KEY_DOCUMENT_SAVE_VETO = Key.create<Boolean>("llm.docSaveVeto")
3432
private val KEY_PROCESSING = KeyWithDefaultValue.create("llm.processing", false)
3533
private val KEY_EDITOR_SUPPORTED = Key.create<Boolean>("llm.editorSupported")
3634
}
@@ -66,32 +64,16 @@ class LLMInlayManagerImpl : LLMInlayManager {
6664
if (project.isDisposed) return@runWriteCommandAction
6765
val document = editor.document
6866
try {
69-
KEY_DOCUMENT_SAVE_VETO[document] = true
70-
wrapWithTemporarySaveVetoHandler {
71-
document.insertString(request.offset, currentCompletion)
72-
editor.caretModel.moveToOffset(request.offset + currentCompletion.length)
73-
return@wrapWithTemporarySaveVetoHandler
74-
}
67+
document.insertString(request.offset, currentCompletion)
68+
editor.caretModel.moveToOffset(request.offset + currentCompletion.length)
7569
} finally {
76-
KEY_DOCUMENT_SAVE_VETO[document] = null
70+
//
7771
}
7872
})
7973

8074
return true
8175
}
8276

83-
@Suppress("UnstableApiUsage")
84-
private fun wrapWithTemporarySaveVetoHandler(runnable: Runnable) {
85-
val disposable = Disposer.newDisposable()
86-
try {
87-
val ep = ApplicationManager.getApplication().getExtensionArea()
88-
.getExtensionPoint(FileDocumentSynchronizationVetoer.EP_NAME)
89-
ep.registerExtension(LLMEditorSaveVetoer(), disposable)
90-
runnable.run()
91-
} finally {
92-
Disposer.dispose(disposable)
93-
}
94-
}
9577

9678
@RequiresEdt
9779
override fun collectInlays(editor: Editor, startOffset: Int, endOffset: Int): List<LLMInlayRenderer> {

0 commit comments

Comments
 (0)