AceJump icon indicating copy to clipboard operation
AceJump copied to clipboard

Add the ability to adjust the position of the cursor after the jump

Open Gruzchick opened this issue 3 years ago • 7 comments

Some people will find it more convenient if the cursor is positioned after the character. Like in this plugin https://plugins.jetbrains.com/plugin/9803-acejump-lite

image

It would be great to add "jump after" mode.

Gruzchick avatar Jan 14 '22 19:01 Gruzchick

I mistakenly thought that the end mod is when the cursor after the jump is set immediately after the target character, but it is set at the end of the word (

Gruzchick avatar Jan 14 '22 19:01 Gruzchick

Personally I would prefer the ability to add additional shortcuts for the All Words Mode s that set the caret at the end of the word: image

Clindbergh avatar Mar 31 '22 19:03 Clindbergh

Personally I would prefer the ability to add additional shortcuts for the All Words Mode s that set the caret at the end of the word: image

There's no accounting for taste 😀

Gruzchick avatar Apr 03 '22 15:04 Gruzchick

There's no accounting for taste 😀

Sure 😆

However this time I actually think the difference is actually significant. My suggestion allows using both modes (caret after the word and word before caret) simultaneously. Having a setting to place the caret at the end would not allow this.

If you intend to often enable and disable the setting and want to keep using the same keyboard shortcuts, you would be quicker than changing 3 new keyboard shortcuts. However I think that's an exotic use case. @Gruzchick, do you see other benefits of the approach with single checkbox setting or would you be happy with 3 additional actions as I suggested?

Clindbergh avatar Apr 04 '22 15:04 Clindbergh

@Clindbergh I just suggested adding the functionality that I needed, without specifying how it would be implemented.

I agree that it will be convenient to make the ability to add additional shortcuts

Gruzchick avatar Apr 07 '22 18:04 Gruzchick

Hey @Gruzchick/@clindbergh, thanks for the feedback, this all seems reasonable to me. If either of you do feel like implementing something, AceJump welcomes PRs! One possibility would be to chain together Vim commands to update the caret position after jumping to some specific location. It would be great if custom actions could be composed together without adding a bunch of configuration settings. This kind of advanced customizability was discussed a while ago and would enable a wider set of scriptable events, @chylex might have some suggestions how to do that.

breandan avatar Apr 07 '22 22:04 breandan

I experimented with this a while ago, I still have the old code in a branch https://github.com/chylex/IntelliJ-AceJump/blob/experimental-rework/src/main/kotlin/org/acejump/action/AceTagAction.kt

They are still hard-coded actions, but it's more flexible than an enum and you can combine multiple actions in one. For example the "Target" mode calls a JumpToWordStart action first:

  object GoToDeclaration : AceTagAction() {
    override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
      JumpToWordStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
      ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_GOTO_TYPE_DECLARATION else IdeActions.ACTION_GOTO_DECLARATION) }
    }
  }

Refactoring current enums to AceTagAction could be a start, but there branch does not have any example of how this could be configured in the settings UI.

chylex avatar Apr 07 '22 23:04 chylex