Skip to content

Fix(VIM-4104): Allow Tab to move to next component#1446

Open
citizenmatt wants to merge 2 commits intoJetBrains:masterfrom
citizenmatt:fix/allow-dialog-tab-navigation
Open

Fix(VIM-4104): Allow Tab to move to next component#1446
citizenmatt wants to merge 2 commits intoJetBrains:masterfrom
citizenmatt:fix/allow-dialog-tab-navigation

Conversation

@citizenmatt
Copy link
Copy Markdown
Member

When IdeaVim is not active, and the current editor is single line, or hosted in a dialog/tool window, or a readonly viewer (e.g. the Commit tool window editor), then hitting Tab will move focus to the next component rather than inserting a tab character. When IdeaVim is active, Tab does nothing (in Insert mode) because the VimShortcutKeyAction handles the keystroke, passing it through the key handler pipeline and then trying to invoke the (disabled) TabAction platform action to insert the tab character.

This PR fixes this behaviour by making VimShortcutKeyAction disabled if the above conditions are met. Since no actions are enabled, Swing will handle the keystroke.

IdeaVim will not disable the action if the user has explicitly created an (Insert mode) map for Tab; if the user has explicitly set up a map, we should use it. The IdeaVim action is also only disabled in Insert mode, because Tab is a valid command in Normal. Admittedly, this command is navigating the jump list, and is unlikely in a single line or hosted editor. We could consider allowing this extra behaviour in Normal (or more) modes.

Fixes VIM-4104.

@citizenmatt citizenmatt force-pushed the fix/allow-dialog-tab-navigation branch from c97e5a1 to ace2a25 Compare April 28, 2026 18:43
Comment on lines +176 to +177
if (injector.keyGroup.getKeyMapping(MappingMode.INSERT).get(listOf(keyStroke)) == null) {
if (editor.isOneLineMode || (editor as? EditorEx)?.isEmbeddedIntoDialogWrapper == true || editor.isViewer) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick maybe extract injector.keyGroup.getKeyMapping(MappingMode.INSERT).get(listOf(keyStroke)) == null to seperate method hasInsertMapping or something like that and join into second if so we won't need nested if statement.

Btw have you chacked how it behaves for other onle line editors?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll get it updated, and I'll double check with other one-line editors

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't think we enable Vim features in any editors other than main and commit now, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added function to check for mappings. It's essentially the same as maparg(), so you can probably guess what my next PR will be 😁

@citizenmatt citizenmatt force-pushed the fix/allow-dialog-tab-navigation branch from a60d435 to 13c4b95 Compare May 1, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants