core: Implement proper automatic tab ordering #16323
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #5443. Fixes #15853.
This PR implements proper automatic tab ordering that behaves exactly the same as in FP.
The Behavior of Automatic Tab Ordering
The automatic order depends only on the position of the top-left highlight bound corner, referred to as
(x,y)
. It does not depend on object's size or other corners.The value of
6y+x
is used to order objects by it. This means that the next object to be tabbed is the next one that touches the liney=-(x-p)/6
(with the smallestp
).When two objects have the same value of
6y+x
(i.e. when the line touches two objects at the same time), only one of them is included.This behavior is similar to the naive approach of "left-to-right, top-to-bottom", but (besides being sometimes seen as random jumps) takes into account the fact that the next object to the right may be positioned slightly higher. This is especially true for objects placed by hand or objects with different heights (as FP uses the top left corner instead of the center).
The following image presents this behavior visually.
This behavior has been discovered experimentally by placing tabbable objects randomly and bisecting one of their coordinates to find a difference in behavior.