diff --git a/src/main/java/com/maddyhome/idea/vim/PluginStartup.kt b/src/main/java/com/maddyhome/idea/vim/PluginStartup.kt index 730327f2d7..4594281bd7 100644 --- a/src/main/java/com/maddyhome/idea/vim/PluginStartup.kt +++ b/src/main/java/com/maddyhome/idea/vim/PluginStartup.kt @@ -38,7 +38,7 @@ internal class PyNotebooksCloseWorkaround : ProjectManagerListener { override fun projectClosingBeforeSave(project: Project) { // TODO: Confirm context in CWM scenario if (injector.globalIjOptions().closenotebooks) { - injector.editorGroup.localEditors().forEach { vimEditor -> + injector.editorGroup.getEditors().forEach { vimEditor -> val editor = (vimEditor as IjVimEditor).editor val virtualFile = EditorHelper.getVirtualFile(editor) if (virtualFile?.extension == "ipynb") { diff --git a/src/main/java/com/maddyhome/idea/vim/group/EditorGroup.java b/src/main/java/com/maddyhome/idea/vim/group/EditorGroup.java index f5957a39d4..a2fb67c0b5 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/EditorGroup.java +++ b/src/main/java/com/maddyhome/idea/vim/group/EditorGroup.java @@ -337,7 +337,7 @@ public Integer getMaxLineNumber(@NotNull Editor editor) { @NotNull @Override - public Collection localEditors() { + public Collection getEditors() { return getLocalEditors() .filter(UserDataManager::getVimInitialised) .map(IjVimEditor::new) @@ -346,7 +346,7 @@ public Collection localEditors() { @NotNull @Override - public Collection localEditors(@NotNull VimDocument buffer) { + public Collection getEditors(@NotNull VimDocument buffer) { final Document document = ((IjVimDocument)buffer).getDocument(); return getLocalEditors() .filter(editor -> UserDataManager.getVimInitialised(editor) && editor.getDocument().equals(document)) diff --git a/src/main/java/com/maddyhome/idea/vim/group/KeyGroup.java b/src/main/java/com/maddyhome/idea/vim/group/KeyGroup.java index 045f084187..2f77590803 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/KeyGroup.java +++ b/src/main/java/com/maddyhome/idea/vim/group/KeyGroup.java @@ -98,7 +98,7 @@ public boolean showKeyMappings(@NotNull Set modes, @NotNu @Override public void updateShortcutKeysRegistration() { - for (VimEditor editor : injector.getEditorGroup().localEditors()) { + for (VimEditor editor : injector.getEditorGroup().getEditors()) { unregisterShortcutKeys(editor); registerRequiredShortcutKeys(editor); } diff --git a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java index e7907d874e..5255f502eb 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java +++ b/src/main/java/com/maddyhome/idea/vim/group/SearchGroup.java @@ -1208,7 +1208,7 @@ public void documentChanged(@NotNull DocumentEvent event) { // ClientId.current will be a guest ID), but we don't care - we still need to add/remove highlights for the // changed text. Make sure we only update local editors, though. final Document document = event.getDocument(); - for (VimEditor vimEditor : injector.getEditorGroup().localEditors(new IjVimDocument(document))) { + for (VimEditor vimEditor : injector.getEditorGroup().getEditors(new IjVimDocument(document))) { final Editor editor = ((IjVimEditor)vimEditor).getEditor(); Collection hls = UserDataManager.getVimLastHighlighters(editor); if (hls == null) { diff --git a/src/main/java/com/maddyhome/idea/vim/group/VimJumpServiceImpl.kt b/src/main/java/com/maddyhome/idea/vim/group/VimJumpServiceImpl.kt index 8082c6f42c..d04e47407c 100644 --- a/src/main/java/com/maddyhome/idea/vim/group/VimJumpServiceImpl.kt +++ b/src/main/java/com/maddyhome/idea/vim/group/VimJumpServiceImpl.kt @@ -111,7 +111,7 @@ internal class JumpsListener(val project: Project) : RecentPlacesListener { } private fun buildJump(place: PlaceInfo): Jump? { - val editor = injector.editorGroup.localEditors().firstOrNull { it.ij.virtualFile == place.file } ?: return null + val editor = injector.editorGroup.getEditors().firstOrNull { it.ij.virtualFile == place.file } ?: return null val offset = place.caretPosition?.startOffset ?: return null val bufferPosition = editor.offsetToBufferPosition(offset) diff --git a/src/main/java/com/maddyhome/idea/vim/group/VimMarkServiceImpl.kt b/src/main/java/com/maddyhome/idea/vim/group/VimMarkServiceImpl.kt index 6124c39fba..7f4aad617a 100755 --- a/src/main/java/com/maddyhome/idea/vim/group/VimMarkServiceImpl.kt +++ b/src/main/java/com/maddyhome/idea/vim/group/VimMarkServiceImpl.kt @@ -232,7 +232,7 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone * Get any editor for the given document * * We need an editor to help calculate offsets for marks, and it doesn't matter which one we use, because they would - * all return the same results. However, we cannot use [VimEditorGroup.localEditors] because the change might have + * all return the same results. However, we cannot use [VimEditorGroup.getEditors] because the change might have * come from a remote guest and there might not be an open local editor. */ private fun getAnyEditorForDocument(doc: Document) = diff --git a/src/main/java/com/maddyhome/idea/vim/helper/EditorHelper.java b/src/main/java/com/maddyhome/idea/vim/helper/EditorHelper.java index 387277a11c..81be765b36 100644 --- a/src/main/java/com/maddyhome/idea/vim/helper/EditorHelper.java +++ b/src/main/java/com/maddyhome/idea/vim/helper/EditorHelper.java @@ -208,7 +208,7 @@ public static int getVisualColumnAtRightOfDisplay(final @NotNull Editor editor, if (doc == null) { return null; } - return injector.getEditorGroup().localEditors(new IjVimDocument(doc)).stream().findFirst().orElse(null); + return injector.getEditorGroup().getEditors(new IjVimDocument(doc)).stream().findFirst().orElse(null); } public static @NotNull String pad(final @NotNull Editor editor, diff --git a/src/main/java/com/maddyhome/idea/vim/helper/SearchHighlightsHelper.kt b/src/main/java/com/maddyhome/idea/vim/helper/SearchHighlightsHelper.kt index d12e979a44..81f0f3513b 100644 --- a/src/main/java/com/maddyhome/idea/vim/helper/SearchHighlightsHelper.kt +++ b/src/main/java/com/maddyhome/idea/vim/helper/SearchHighlightsHelper.kt @@ -98,7 +98,7 @@ private fun updateSearchHighlights( for (project in projectManager.openProjects) { val current = FileEditorManager.getInstance(project).selectedTextEditor ?: continue - val editors = injector.editorGroup.localEditors(IjVimDocument(current.document)) + val editors = injector.editorGroup.getEditors(IjVimDocument(current.document)) for (vimEditor in editors) { val editor = (vimEditor as IjVimEditor).editor if (editor.project != project) { diff --git a/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt b/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt index aa28338870..fc1692b4c5 100644 --- a/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt +++ b/src/main/java/com/maddyhome/idea/vim/listener/VimListenerManager.kt @@ -232,7 +232,7 @@ internal object VimListenerManager { } fun removeAll() { - injector.editorGroup.localEditors().forEach { editor -> + injector.editorGroup.getEditors().forEach { editor -> remove(editor.ij) } } diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ExOutputPanel.java b/src/main/java/com/maddyhome/idea/vim/ui/ExOutputPanel.java index 736321ceb3..02567ea05f 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ExOutputPanel.java +++ b/src/main/java/com/maddyhome/idea/vim/ui/ExOutputPanel.java @@ -369,7 +369,7 @@ public void lookAndFeelChanged(@NotNull LafManager source) { // This listener is only invoked for local scenarios, and we only need to update local editor UI. This will invoke // updateUI on the output pane and it's child components - for (VimEditor vimEditor : injector.getEditorGroup().localEditors()) { + for (VimEditor vimEditor : injector.getEditorGroup().getEditors()) { Editor editor = ((IjVimEditor)vimEditor).getEditor(); if (!ExOutputPanel.isPanelActive(editor)) continue; IJSwingUtilities.updateComponentTreeUI(ExOutputPanel.getInstance(editor)); diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimEditorGroup.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimEditorGroup.kt index 7f987c24da..8df8c6cadf 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimEditorGroup.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimEditorGroup.kt @@ -14,7 +14,7 @@ public interface VimEditorGroup { /** * Get a collection of all editors, including those that have not yet been initialised. * - * You probably don't want to use this - use [localEditors]! + * You probably don't want to use this - use [getEditors]! * * This function is only useful during plugin initialisation. It will return all currently open editors, including * those that have not yet been initialised, so the plugin can correctly initialise them. When the plugin starts, the @@ -40,7 +40,7 @@ public interface VimEditorGroup { * * Also note that it is possible for multiple editors in different projects to open the same file (document/buffer). */ - public fun localEditors(): Collection + public fun getEditors(): Collection /** * Get a collection of all initialised editors for the given buffer @@ -54,5 +54,5 @@ public interface VimEditorGroup { * Implementors should take care to only return "local" editors. I.e. for IntelliJ, this function will not include * hidden editors that are used to handle requests from Code With Me guests. */ - public fun localEditors(buffer: VimDocument): Collection + public fun getEditors(buffer: VimDocument): Collection } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimMarkServiceBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimMarkServiceBase.kt index ed30a819fc..9e8b6f9d52 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimMarkServiceBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimMarkServiceBase.kt @@ -136,7 +136,7 @@ public abstract class VimMarkServiceBase : VimMarkService { } override fun getAllMarksForFile(editor: VimEditor): List>> { - val localMarks = injector.editorGroup.localEditors() + val localMarks = injector.editorGroup.getEditors() .filter { it.getPath() == editor.getPath() } .flatMap { it.carets() } .map { Pair(it, getAllLocalMarks(it)) } @@ -413,7 +413,7 @@ public abstract class VimMarkServiceBase : VimMarkService { } override fun resetAllMarks() { - for (editor in injector.editorGroup.localEditors()) { + for (editor in injector.editorGroup.getEditors()) { editor.carets().forEach { resetAllMarksForCaret(it) } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimOptionGroupBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimOptionGroupBase.kt index de5e6e7864..40dcba8ebf 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimOptionGroupBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimOptionGroupBase.kt @@ -135,7 +135,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup { resetAllOptions(injector.fallbackWindow) // During testing, we do not expect to have any editors, so this collection is usually empty - injector.editorGroup.localEditors().forEach { resetAllOptions(it) } + injector.editorGroup.getEditors().forEach { resetAllOptions(it) } } override fun addOption(option: Option) { @@ -192,7 +192,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup { if (option.declaredScope != LOCAL_TO_WINDOW) { storage.setOptionValue(option, OptionAccessScope.GLOBAL(null), option.defaultValue) } - injector.editorGroup.localEditors().forEach { editor -> + injector.editorGroup.getEditors().forEach { editor -> when (option.declaredScope) { GLOBAL -> { } LOCAL_TO_BUFFER, @@ -612,7 +612,7 @@ private class OptionListenersImpl(private val optionStorage: OptionStorage, priv */ private fun onGlobalOptionChanged(optionName: String) { globalOptionListeners[optionName]?.forEach { it.onGlobalOptionChanged() } - fireEffectiveValueChanged(optionName, editorGroup.localEditors()) + fireEffectiveValueChanged(optionName, editorGroup.getEditors()) } /** @@ -621,7 +621,7 @@ private class OptionListenersImpl(private val optionStorage: OptionStorage, priv * Notifies all open editors for the current buffer (document). */ private fun onLocalToBufferOptionChanged(option: Option, editor: VimEditor) { - fireEffectiveValueChanged(option.name, editorGroup.localEditors(editor.document)) + fireEffectiveValueChanged(option.name, editorGroup.getEditors(editor.document)) } /** @@ -639,7 +639,7 @@ private class OptionListenersImpl(private val optionStorage: OptionStorage, priv * This will notify all open editors where the option is not locally set. */ private fun onGlobalLocalOptionGlobalValueChanged(option: Option) { - val affectedEditors = editorGroup.localEditors().filter { optionStorage.isUnsetValue(option, it) } + val affectedEditors = editorGroup.getEditors().filter { optionStorage.isUnsetValue(option, it) } fireEffectiveValueChanged(option.name, affectedEditors) } @@ -659,13 +659,13 @@ private class OptionListenersImpl(private val optionStorage: OptionStorage, priv // We could get essentially the same behaviour by calling onGlobalLocalOptionGlobalValueChanged followed by // onLocalXxxOptionChanged, but that would notify editors for string-based options twice. val affectedEditors = mutableListOf() - affectedEditors.addAll(editorGroup.localEditors().filter { optionStorage.isUnsetValue(option, it) }) + affectedEditors.addAll(editorGroup.getEditors().filter { optionStorage.isUnsetValue(option, it) }) if (option.declaredScope == GLOBAL_OR_LOCAL_TO_WINDOW) { if (!optionStorage.isUnsetValue(option, editor)) affectedEditors.add(editor) } else if (option.declaredScope == GLOBAL_OR_LOCAL_TO_BUFFER) { - affectedEditors.addAll(editorGroup.localEditors(editor.document).filter { !optionStorage.isUnsetValue(option, it) }) + affectedEditors.addAll(editorGroup.getEditors(editor.document).filter { !optionStorage.isUnsetValue(option, it) }) } fireEffectiveValueChanged(option.name, affectedEditors) diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt index 669b0bf353..12c9ad21b1 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/impl/state/VimStateMachineImpl.kt @@ -121,7 +121,7 @@ public class VimStateMachineImpl(private val editor: VimEditor?) : VimStateMachi editor.updateCaretsVisualAttributes() editor.updateCaretsVisualPosition() } else { - injector.editorGroup.localEditors().forEach { editor -> + injector.editorGroup.getEditors().forEach { editor -> editor.updateCaretsVisualAttributes() editor.updateCaretsVisualPosition() }