Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unnecessary caret movement when switching tabs #308

Merged
merged 4 commits into from
May 24, 2021

Conversation

citizenmatt
Copy link
Member

Changes gt and gT actions from MotionActionHandler to VimActionHandler, as they're not motions. This was causing a problem because IdeaVim would switch tabs then try to move the caret to the current offset, which we don't optimise away because it might result in a different visual position thanks to inlays. Because the editor was no longer visible, the visible area is effectively zero, and repositioning the caret to fit in this area would move it to the top left of the editor. Fixes VIM-2308

@@ -79,7 +79,7 @@ class RegisterActionsTest : VimTestCase() {
val after = "I f${c}ound it in a legendary land"
var motionRightAction: ActionBeanClass? = null
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
motionRightAction = VIM_ACTIONS_EP.extensions().findAny().get()
motionRightAction = VIM_ACTIONS_EP.extensions().filter { it.actionId == "VimPreviousTabAction" }.findFirst().get()
Copy link
Member

Choose a reason for hiding this comment

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

The PR is good, but what is this change about?

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes the action we're using explicit, rather than relying on the order of the actions in VimActions.xml. The findAny function is documented as returning "any" item from the collection, but in practice it was returning the first item, which just happened to be the "previous tab action". I moved that action from the motion.tabs package to windows.tab, and moved the registration in VimActions.xml to match, and that broke the assumption on the order of the actions.

@AlexPl292 AlexPl292 merged commit 5a85565 into JetBrains:master May 24, 2021
@citizenmatt citizenmatt deleted the VIM-2308 branch May 24, 2021 09:03
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