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

1 Letter tag shortcuts #378

Open rog1039 opened 3 years ago

rog1039 commented 3 years ago

Is your feature request related to a problem? Please describe. I am wondering if it is possible for AceJump to exhaust all 1-character tag shortcuts before making 2-letter tag shortcuts. In an example, There are only 22 highlighted tag locations yet some of them are multiple letters such as FF and FT. I would have thought a-z would be exhausted before adding 2-letter tags.

Describe the solution you'd like I would prefer to use up all 1 letter tag options first.

I couldn't find an existing issue on this so thought I would bring it up. Is there some way to configure acejump so that this behavior is the default?

Thanks, Paul

breandan commented 3 years ago

Hi @rog1039, thanks for your question. By default, AceJump does prefer to use single-character tags tags, however they may be unavailable to assign for several reasons. It may be the case an off-screen word is preventing a single-character tag from being assigned, or in some circumstances it may be impossible to assign a single-character tag without a collision. Since AceJump is also used for search, we must ensure tags do not elide text elsewhere in the file during tag assignment.

In order to increase the likelihood that single-character tags are assigned, you can deselect the option Search whole file under Settings | Tools | AceJump | Behavior. Although this will disable AceJump's whole-file search, it will ensure that shorter tags appear more often, since AceJump only needs to consider the region of text contained within the vertical screen boundaries. This typically has fewer constraints, making single-character tags eligible for assignment more frequently.

rog1039 commented 3 years ago

Hi @breandan,

Thanks for the explanation. I have turned off Search Whole File and I also changed Minimum typed characters to 2 hoping that would help. Turning off Search whole file did help some I think but I'm not sure Minimum typed characters had an effect.

I included a video that shows the behavior in more detail. In this example I am typing 'Prop' into the search. https://user-images.githubusercontent.com/5702706/119708864-94d7b300-be2a-11eb-8d64-93ca7841a1d2.mp4

After initially typing P I count 24 tags, although since changing Minimum typed characters nothing is showing with a tag value yet. I would assume at this point all 24 tags could have assigned tag values and if so, they could all be single letter I think since I only see 24 highlighted tags. Upon typing the next few characters, rop, 20 tags remain and we can see 6 of them are assigned double letter tags.

So I guess I have two questions:

And as I type this, I feel like I am being very nitpicky on this topic. This extension is already amazing to use day-to-day so if this is more trouble that it's worth please feel free to close this issue.

Thanks!

breandan commented 3 years ago

Hi @rog1039, thanks for recording the screencast and sharing your experience. I can see what you mean, and understand your curiosity, as the tagging mechanics are not always intuitive. Since AceJump generates tags dynamically based on the editor contents, their length, characters, and even placement can sometimes be unpredictable. I will try to explain.

AceJump initially assigns two-character tags to all matching strings in the editor. After assignment, if AceJump determines a tag can be shortened to a single-character tag it will do so immediately. If you continue typing and AceJump later determines that a two-character tag starts with a unique character (i.e. a character which occurs in the first position of exactly one tag in the session), it will be shortened immediately. Otherwise, a tag, once assigned, never changes as you continue typing.

Is there a reason that after typing Prop the characters don't all have single charater tags?

Yes, if you look carefully at the first character of all two-character tags at 0:10 of your recording, you will notice that their first character (DD, JJ, JI, HH, HU, DR) is non-unique. Those tags cannot be shortened without receiving additional query characters or changing the first tag character (which we never do).

Would it be possible to delay assigning tag values until the Minimum typed characters has been reached?

Yes, this is exactly what should be occurring. After activation, AceJump waits to receive N minimum typed characters to assign tags (please let us know if this is not the case). For example, if you increase the minimum length to 4, it is more likely that all locations will be tagged with a single character after typing Prop in the scenario you shared above.

And as I type this, I feel like I am being very nitpicky on this topic.

Not at all! I am glad you brought this to our attention. Please let me know if you have any further suggestions or I can provide any other details about the tag assignment algorithm.

piskov commented 1 week ago

Collisions could be avoided by using punctuation symbols like in vs code vim plugin:

image