acejump / AceJump

🅰️ single character search, select, and jump
https://plugins.jetbrains.com/plugin/7086-acejump
GNU General Public License v3.0
1.21k stars 91 forks source link

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

Open Gruzchick opened 2 years ago

Gruzchick commented 2 years ago

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 commented 2 years ago

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 (

Clindbergh commented 2 years ago

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

Gruzchick commented 2 years ago

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 😀

Clindbergh commented 2 years ago

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?

Gruzchick commented 2 years ago

@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

breandan commented 2 years ago

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.

chylex commented 2 years ago

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.