Skip to content

Commit 2ff3c17

Browse files
committed
fix(inlay): fix compatibility issue with IDEA 241 version for #109
Handle LLMEditorSaveVetoer to properly interact with document save veto. Update handling of document save veto in LLMEditorSaveVetoer to address extension point and ensure proper application of the save veto.
1 parent a5d5e4d commit 2ff3c17

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package com.intellij.temporary.inlay.codecomplete
22

33
import com.intellij.openapi.editor.Document
44
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer
5-
import com.intellij.openapi.util.UserDataHolder
65

76
class LLMEditorSaveVetoer : FileDocumentSynchronizationVetoer() {
87
override fun maySaveDocument(document: Document, isSaveExplicit: Boolean): Boolean {
9-
return !LLMInlayManagerImpl.KEY_DOCUMENT_SAVE_VETO.isIn(document as UserDataHolder)
8+
return !LLMInlayManagerImpl.KEY_DOCUMENT_SAVE_VETO.isIn(document)
109
}
1110
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface LLMInlayManager : Disposable {
2626
fun editorModified(editor: Editor, changeOffset: Int)
2727

2828
fun editorModified(editor: Editor)
29+
2930
fun countCompletionInlays(editor: Editor, tabRange: TextRange) : Int
3031

3132
companion object {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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
1718
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer
1819
import com.intellij.openapi.project.Project
1920
import com.intellij.openapi.util.Disposer
@@ -38,7 +39,7 @@ class LLMInlayManagerImpl : LLMInlayManager {
3839

3940
@RequiresEdt
4041
override fun isAvailable(editor: Editor): Boolean {
41-
var isAvailable= KEY_EDITOR_SUPPORTED[editor]
42+
var isAvailable = KEY_EDITOR_SUPPORTED[editor]
4243
if (isAvailable == null) {
4344
isAvailable = editor !is EditorWindow && editor !is ImaginaryEditor && (
4445
editor !is EditorEx || !editor.isEmbeddedIntoDialogWrapper) &&
@@ -79,11 +80,12 @@ class LLMInlayManagerImpl : LLMInlayManager {
7980
return true
8081
}
8182

83+
@Suppress("UnstableApiUsage")
8284
private fun wrapWithTemporarySaveVetoHandler(runnable: Runnable) {
8385
val disposable = Disposer.newDisposable()
8486
try {
85-
val extensionArea = ApplicationManager.getApplication().extensionArea
86-
val ep = extensionArea.getExtensionPoint(FileDocumentSynchronizationVetoer.EP_NAME)
87+
val ep = ApplicationManager.getApplication().getExtensionArea()
88+
.getExtensionPoint(FileDocumentSynchronizationVetoer.EP_NAME)
8789
ep.registerExtension(LLMEditorSaveVetoer(), disposable)
8890
runnable.run()
8991
} finally {

0 commit comments

Comments
 (0)