mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-02-25 02:46:01 +01:00
Create a function to get the execution context from the editor
This is a part of VIM-3376. This context will not be a custom EditorDataContext, but some context created by the platform. In some places we don't have any kind of "current context", but we have to use it for the function. However, such context can be simply retrieved from the editor.
This commit is contained in:
parent
fe9a6b5cfb
commit
209052ffa6
src/main/java/com/maddyhome/idea/vim
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api
@ -117,7 +117,7 @@ internal object IdeaSelectionControl {
|
||||
is Mode.VISUAL -> VimPlugin.getVisualMotion().enterVisualMode(editor.vim, mode.selectionType)
|
||||
is Mode.SELECT -> VimPlugin.getVisualMotion().enterSelectMode(editor.vim, mode.selectionType)
|
||||
is Mode.INSERT -> VimPlugin.getChange()
|
||||
.insertBeforeCursor(editor.vim, injector.executionContextManager.onEditor(editor.vim))
|
||||
.insertBeforeCursor(editor.vim, injector.executionContextManager.getEditorExecutionContext(editor.vim))
|
||||
|
||||
is Mode.NORMAL -> Unit
|
||||
else -> error("Unexpected mode: $mode")
|
||||
|
@ -164,7 +164,7 @@ internal object IdeaSpecifics {
|
||||
if (editor.vim.inNormalMode) {
|
||||
VimPlugin.getChange().insertBeforeCursor(
|
||||
editor.vim,
|
||||
injector.executionContextManager.onEditor(editor.vim),
|
||||
injector.executionContextManager.getEditorExecutionContext(editor.vim),
|
||||
)
|
||||
KeyHandler.getInstance().reset(editor.vim)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package com.maddyhome.idea.vim.newapi
|
||||
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.ExecutionContextManagerBase
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
@ -22,4 +23,8 @@ internal class IjExecutionContextManager : ExecutionContextManagerBase() {
|
||||
}
|
||||
return IjEditorExecutionContext(EditorDataContext.init((editor as IjVimEditor).editor, prevContext?.ij))
|
||||
}
|
||||
|
||||
override fun getEditorExecutionContext(editor: VimEditor): ExecutionContext {
|
||||
return EditorUtil.getEditorDataContext(editor.ij).vim
|
||||
}
|
||||
}
|
||||
|
@ -23,4 +23,5 @@ public sealed interface ExecutionContext {
|
||||
|
||||
public interface ExecutionContextManager {
|
||||
public fun onEditor(editor: VimEditor, prevContext: ExecutionContext? = null): ExecutionContext.Editor
|
||||
public fun getEditorExecutionContext(editor: VimEditor): ExecutionContext
|
||||
}
|
||||
|
@ -21,4 +21,8 @@ public class ExecutionContextManagerStub : ExecutionContextManager {
|
||||
override fun onEditor(editor: VimEditor, prevContext: ExecutionContext?): ExecutionContext.Editor {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getEditorExecutionContext(editor: VimEditor): ExecutionContext {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user