Skip to content

Commit 3d0c8b8

Browse files
committed
Fix flaky TemplateTest by adjusting escape sequence timing
Fix flaky inline rename test
1 parent 9236b4c commit 3d0c8b8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/com/maddyhome/idea/vim/helper/ModeExtensions.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2023 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -17,6 +17,7 @@ import com.maddyhome.idea.vim.api.VimEditor
1717
import com.maddyhome.idea.vim.api.getLineEndForOffset
1818
import com.maddyhome.idea.vim.api.getLineStartForOffset
1919
import com.maddyhome.idea.vim.api.injector
20+
import com.maddyhome.idea.vim.group.visual.VimVisualTimer
2021
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
2122
import com.maddyhome.idea.vim.newapi.IjEditorExecutionContext
2223
import com.maddyhome.idea.vim.newapi.IjVimCaret
@@ -28,6 +29,9 @@ import com.maddyhome.idea.vim.state.mode.inSelectMode
2829
internal fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
2930
if (!this.inSelectMode) return
3031

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

4953
internal fun Editor.exitInsertMode(context: DataContext) {
54+
// Cancel any pending visual timer mode change. When the user explicitly presses Escape to exit INSERT mode,
55+
// we don't want a delayed selection change handler to override their intent and switch back to INSERT.
56+
VimVisualTimer.drop()
5057
VimPlugin.getChange().processEscape(IjVimEditor(this), IjEditorExecutionContext(context))
5158
}

tests/java-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/group/visual/TemplateTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2024 The IdeaVim authors
2+
* Copyright 2003-2026 The IdeaVim authors
33
*
44
* Use of this source code is governed by an MIT-style
55
* license that can be found in the LICENSE.txt file or at
@@ -809,7 +809,6 @@ class TemplateTest : VimJavaTestCase() {
809809
waitAndAssertMode(fixture, Mode.SELECT(SelectionType.CHARACTER_WISE))
810810
typeText("myNewVar", "<CR>") // Typing first char switches to Insert
811811

812-
// Insert ends after the symbol, then switching to Normal moves back a char
813812
assertState(
814813
"""
815814
|class Hello {

0 commit comments

Comments
 (0)