Currently screenPositionForPixelPosition special cases pixel positions
below the last row so that the column position is always set to the
last column of the last line, even if the pixel 'x' position is less
then that column.
This patch special cases picks above the first row so that the text
column position will be in the first column even if the pixel 'x'
position is greater then that column.
At a higher level, this patch fixes the problem where you can’t select
to the start of a text field by just clicking and dragging up. Instead
you have to click and drag back (x axis) beyond the start of the text
field.
When clipping a screen position, callers used to have to pick between
clipping to the left edge or the right edge when the position was in the
middle of an atomic token. This change allows them to choose the closest
edge, and makes this the default.
This makes selecting hard tabs (or any other atomic tokens) work in a
similar manner as in other text editors; that is, when clicking near
the middle of a tab, the insertion point will move to the closest edge
rather than the left edge.
screenColumnForBufferColumn used to break only if the current column
was strictly greater than the target column. This commit changes it so
it breaks when greater or equal, which is how bufferColumnForScreenColumn
works.
This also adds some unit tests for screenColumnForBufferColumn's
interactions with hard tab characters.
DisplayBuffer::bufferPositionForScreenPosition calls clipScreenPosition
first thing, meaning that Marker::setHead/TailScreenPosition don't need
to call clipScreenPosition before calling bufferPositionForScreenPosition.
Rather than when the selection’s marker changes. This is simpler than
suppressing autoscroll via state when we don’t want it. It also captures
the intent to autoscroll when attempting to move the cursor at the
beginning or end of the document.
Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>