|
|
|
@ -35,6 +35,7 @@ import com.intellij.openapi.editor.ex.DocumentEx
|
|
|
|
|
import com.intellij.openapi.editor.ex.EditorEventMulticasterEx
|
|
|
|
|
import com.intellij.openapi.editor.ex.FocusChangeListener
|
|
|
|
|
import com.intellij.openapi.editor.impl.EditorComponentImpl
|
|
|
|
|
import com.intellij.openapi.editor.impl.EditorImpl
|
|
|
|
|
import com.intellij.openapi.fileEditor.FileEditorManager
|
|
|
|
|
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
|
|
|
|
|
import com.intellij.openapi.fileEditor.FileEditorManagerListener
|
|
|
|
@ -45,11 +46,14 @@ import com.intellij.openapi.fileEditor.ex.FileEditorWithProvider
|
|
|
|
|
import com.intellij.openapi.fileEditor.impl.EditorComposite
|
|
|
|
|
import com.intellij.openapi.fileEditor.impl.EditorWindow
|
|
|
|
|
import com.intellij.openapi.project.ProjectManager
|
|
|
|
|
import com.intellij.openapi.rd.createLifetime
|
|
|
|
|
import com.intellij.openapi.rd.createNestedDisposable
|
|
|
|
|
import com.intellij.openapi.util.Disposer
|
|
|
|
|
import com.intellij.openapi.util.Key
|
|
|
|
|
import com.intellij.openapi.util.removeUserData
|
|
|
|
|
import com.intellij.openapi.vfs.VirtualFile
|
|
|
|
|
import com.intellij.util.ExceptionUtil
|
|
|
|
|
import com.jetbrains.rd.util.lifetime.Lifetime
|
|
|
|
|
import com.maddyhome.idea.vim.EventFacade
|
|
|
|
|
import com.maddyhome.idea.vim.KeyHandler
|
|
|
|
|
import com.maddyhome.idea.vim.KeyHandlerStateResetter
|
|
|
|
@ -101,7 +105,6 @@ import com.maddyhome.idea.vim.ui.widgets.macro.MacroWidgetListener
|
|
|
|
|
import com.maddyhome.idea.vim.ui.widgets.macro.macroWidgetOptionListener
|
|
|
|
|
import com.maddyhome.idea.vim.ui.widgets.mode.listeners.ModeWidgetListener
|
|
|
|
|
import com.maddyhome.idea.vim.ui.widgets.mode.modeWidgetOptionListener
|
|
|
|
|
import com.maddyhome.idea.vim.vimDisposable
|
|
|
|
|
import java.awt.event.MouseAdapter
|
|
|
|
|
import java.awt.event.MouseEvent
|
|
|
|
|
import javax.swing.SwingUtilities
|
|
|
|
@ -264,12 +267,10 @@ internal object VimListenerManager {
|
|
|
|
|
// TODO: If the user changes the 'ideavimsupport' option, existing editors won't be initialised
|
|
|
|
|
if (vimDisabled(editor)) return
|
|
|
|
|
|
|
|
|
|
// As I understand, there is no need to pass a disposable that also disposes on editor close
|
|
|
|
|
// because all editor resources will be garbage collected anyway on editor close
|
|
|
|
|
// Note that this uses the plugin's main disposable, rather than VimPlugin.onOffDisposable, because we don't need
|
|
|
|
|
// to - we explicitly call VimListenerManager.removeAll from VimPlugin.turnOffPlugin, and this disposes each
|
|
|
|
|
// editor's disposable individually.
|
|
|
|
|
val disposable = editor.project?.vimDisposable ?: return
|
|
|
|
|
val pluginLifetime = VimPlugin.getInstance().createLifetime()
|
|
|
|
|
val editorLifetime = (editor as EditorImpl).disposable.createLifetime()
|
|
|
|
|
val disposable =
|
|
|
|
|
Lifetime.intersect(pluginLifetime, editorLifetime).createNestedDisposable("MyLifetimedDisposable")
|
|
|
|
|
|
|
|
|
|
val listenersDisposable = Disposer.newDisposable(disposable)
|
|
|
|
|
editor.putUserData(editorListenersDisposableKey, listenersDisposable)
|
|
|
|
|