Skip to content

Commit

Permalink
[VIM-3577] Store the information if the editor was initialized in ins…
Browse files Browse the repository at this point in the history
…ert mode
  • Loading branch information
AlexPl292 committed Dec 18, 2024
1 parent 5e60ea7 commit c225452
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ class IJEditorFocusListener : EditorListener {
val ijEditor = editor.ij
val isCurrentEditorTerminal = isTerminal(ijEditor)

KeyHandler.getInstance().lastUsedEditorInfo = LastUsedEditorInfo(currentEditorHashCode, isCurrentEditorTerminal)
KeyHandler.getInstance().lastUsedEditorInfo = LastUsedEditorInfo(currentEditorHashCode, false)

val switchToInsertMode = Runnable {
val context: ExecutionContext = injector.executionContextManager.getEditorExecutionContext(editor)
VimPlugin.getChange().insertBeforeCursor(editor, context)
KeyHandler.getInstance().lastUsedEditorInfo = LastUsedEditorInfo(currentEditorHashCode, true)
}
if (isCurrentEditorTerminal && !ijEditor.inInsertMode) {
switchToInsertMode.run()
} else if (ijEditor.isInsertMode && (oldEditorInfo.isTerminal || !ijEditor.document.isWritable)) {
} else if (ijEditor.isInsertMode && (oldEditorInfo.isInsertModeForced || !ijEditor.document.isWritable)) {
val context: ExecutionContext = injector.executionContextManager.getEditorExecutionContext(editor)
val mode = injector.vimState.mode
when (mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,5 +479,8 @@ typealias KeyProcessing = (KeyHandlerState, VimEditor, ExecutionContext) -> Unit

data class LastUsedEditorInfo(
val hash: Int,
val isTerminal: Boolean,
/**
* If true, this editor was initialized in insert mode
*/
val isInsertModeForced: Boolean,
)

0 comments on commit c225452

Please sign in to comment.