Skip to content

Commit

Permalink
Fix(VIM-3157): Do not invoke enter in invokeLater for python console
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPl292 committed Nov 13, 2023
1 parent 2436164 commit 1dc6045
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.actionSystem.EditorActionHandler
import com.intellij.openapi.editor.impl.CaretModelImpl
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.util.removeUserData
Expand Down Expand Up @@ -74,7 +75,7 @@ internal abstract class OctopusHandler(private val nextHandler: EditorActionHand

final override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
if (isThisHandlerEnabled(editor, caret, dataContext)) {
val executeInInvokeLater = (editor.caretModel as? CaretModelImpl)?.isIteratingOverCarets ?: true
val executeInInvokeLater = executeInInvokeLater(editor)
val executionHandler = {
try {
(dataContext as? UserDataHolder)?.putUserData(commandContinuation, nextHandler)
Expand Down Expand Up @@ -103,6 +104,12 @@ internal abstract class OctopusHandler(private val nextHandler: EditorActionHand
}
}

private fun executeInInvokeLater(editor: Editor): Boolean {
// Currently we have a workaround for the PY console VIM-3157
if (FileDocumentManager.getInstance().getFile(editor.document)?.name == "Python Console.py") return false
return (editor.caretModel as? CaretModelImpl)?.isIteratingOverCarets ?: true
}

private fun isThisHandlerEnabled(editor: Editor, caret: Caret?, dataContext: DataContext?): Boolean {
if (!VimPlugin.isEnabled()) return false
if (!isHandlerEnabled(editor, dataContext)) return false
Expand Down

0 comments on commit 1dc6045

Please sign in to comment.