acejump / AceJump

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

Prefer 1-key tags #471

Open arialdomartini opened 1 week ago

arialdomartini commented 1 week ago

In many cases, when there are fewer candidates then available allowed characters in tags, AceJump could offer all 1-key tags.

Yet, for some reason, it suggests many 2-key tags.

Here a case. I defined the following characters as available allowed characters in tags:

fjdksla;rueiwoqpvmc,x.z/

They are 23.

With this setup, here's what I see activating "All lines marks mode"

image

Notice that, the candidates are 19, so technically there is no need to use 2-char tags, because there are enough available allowed characters in tags to have all 1-char tags.

arialdomartini commented 1 week ago

Reading past issues, I find this one could be a duplicate of #378

breandan commented 1 week ago

Yes, #378 is related - thanks for reporting. It looks like it should be possible to assign all one-letter tags in the scenario you described. There are two places to consider:

https://github.com/acejump/AceJump/blob/cb55f09c5213234e2fbe128663ca2126773db2ba/src/main/kotlin/org/acejump/search/Tagger.kt#L50

The second place is here:

https://github.com/acejump/AceJump/blob/cb55f09c5213234e2fbe128663ca2126773db2ba/src/main/kotlin/org/acejump/search/Solver.kt#L183

We might be able to add a special case to detect when (1) the number of sites to tag is fewer than the number of allowed characters and when (2) all the allowed characters can be assigned to sites without introducing a tag collision, to fall back to single-character tags.

It might also be tricky, because even though there exists a matching requiring fewer than n single character tags in total does not mean it will be easy to find because the tag constraints could require some backtracking to utilize all the tags. In the worst case, it could require trying all sites x allowed characters matchings.