mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[inline-completion] ML-862 ML-864 hide inline on caret position change
GitOrigin-RevId: cca33c0c0def34d5d27151b0c02a87b976c6131c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cf03e94721
commit
6a3ec29602
@@ -31,9 +31,11 @@ class InlineCompletionEditorListener(scope: CoroutineScope) : EditorFactoryListe
|
||||
|
||||
editor.putUserData(InlineCompletionHandler.KEY, handler)
|
||||
val docListener = InlineCompletionDocumentListener(editor)
|
||||
val caretListener = InlineCaretListener(editor)
|
||||
|
||||
editor.document.addDocumentListener(docListener, disposable)
|
||||
editor.addFocusListener(focusListener, disposable)
|
||||
editor.caretModel.addCaretListener(caretListener, disposable)
|
||||
}
|
||||
|
||||
override fun editorReleased(event: EditorFactoryEvent) {
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.intellij.codeWithMe.ClientId
|
||||
import com.intellij.codeWithMe.isCurrent
|
||||
import com.intellij.openapi.editor.ClientEditorManager
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.event.CaretEvent
|
||||
import com.intellij.openapi.editor.event.CaretListener
|
||||
import com.intellij.openapi.editor.event.DocumentEvent
|
||||
import com.intellij.openapi.editor.event.DocumentListener
|
||||
import com.intellij.openapi.editor.ex.FocusChangeListener
|
||||
@@ -59,3 +61,16 @@ class InlineCompletionFocusListener : FocusChangeListener {
|
||||
editor.resetInlineCompletionContext()
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
class InlineCaretListener(private val editor: Editor) : CaretListener {
|
||||
override fun caretPositionChanged(event: CaretEvent) {
|
||||
if (isSimple(event)) return
|
||||
|
||||
editor.resetInlineCompletionContext()
|
||||
}
|
||||
|
||||
private fun isSimple(event: CaretEvent): Boolean {
|
||||
return event.oldPosition.line == event.newPosition.line && event.oldPosition.column + 1 == event.newPosition.column
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user