Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2023 The IdeaVim authors
* Copyright 2003-2026 The IdeaVim authors
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE.txt file or at
Expand All @@ -17,6 +17,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.group.visual.VimVisualTimer
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
import com.maddyhome.idea.vim.newapi.IjEditorExecutionContext
import com.maddyhome.idea.vim.newapi.IjVimCaret
Expand All @@ -28,6 +29,9 @@ import com.maddyhome.idea.vim.state.mode.inSelectMode
internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
if (!this.inSelectMode) return

// Cancel any pending visual timer mode change. When the user explicitly exits SELECT mode,
// we don't want a delayed selection change handler to override their intent.
VimVisualTimer.drop()
mode = mode.returnTo
SelectionVimListenerSuppressor.lock().use {
carets().forEach { vimCaret ->
Expand All @@ -47,5 +51,8 @@ internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
}

internal fun Editor.exitInsertMode(context: DataContext) {
// Cancel any pending visual timer mode change. When the user explicitly presses Escape to exit INSERT mode,
// we don't want a delayed selection change handler to override their intent and switch back to INSERT.
VimVisualTimer.drop()
VimPlugin.getChange().processEscape(IjVimEditor(this), IjEditorExecutionContext(context))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2024 The IdeaVim authors
* Copyright 2003-2026 The IdeaVim authors
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE.txt file or at
Expand Down Expand Up @@ -809,7 +809,6 @@ class TemplateTest : VimJavaTestCase() {
waitAndAssertMode(fixture, Mode.SELECT(SelectionType.CHARACTER_WISE))
typeText("myNewVar", "<CR>") // Typing first char switches to Insert

// Insert ends after the symbol, then switching to Normal moves back a char
assertState(
"""
|class Hello {
Expand Down
Loading