Skip to content

Conversation

@edralston
Copy link

If a hint pattern results in the number of hint labels exceeding the size of the alphabet, then some of the labels will need to be two characters instead of just one character. Sometimes this results in a mixture of single-character and two-character hint labels. However, as currently implemented, there is a chance for some of the two-character hint labels starting with the same character as a single-character label. For example, the set of hint labels might contain "j" and "ja" and "jb" and "jc" but in this case, it would be impossible to select the object associated with hint label "j" since the hint engine will still be attempting to match against "ja" or "jb" etc.

This commit resolves this issue by removing the shorter label ("j" in the example above) before adding the longer labels ("ja" and "jb" etc.).

If the number of labels is larger than the alphabet size, then we need to
widen the labels to more than just one character wide.
We take care to make sure that when we add two-character labels, we remove
the associated single-character label.  For example, if we add the two-character
labels "ja" and "jb" and "jc" we make sure to first remove the single-character
label "j".  If we don't remove "j" then the user will never be able to actually
select the object with label "j" because the hint engine will still be
trying to match against "ja" or "jb" etc.
This applies to three-character labels and so on as well.
Reverse the order of hint labels so that the "simpler" ones (shorter labels and
labels that use characters earlier in the alphabet) come first.  This is done because
the user is probably more likely to want to select the hint label that is lower
on the screen.
@edralston edralston changed the title Bugfix/hint label Avoid hint label collision Aug 28, 2025
@raphamorim
Copy link
Owner

man this was such good pr i apologise, sorry for late reply.

I will review it if is still interest @edralston

@edralston
Copy link
Author

Yes I believe this is still valid

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