mathquill/mathquill — pull request #266 by laughinghan (2014-03-25 22:43:55+00:00)
Title: Fix #172: keyboard select after mouse select

There's 3 problems blocking #172. One is trivial:

- the `mouseup` handler no longer deletes the anticursor

The other 2 are solvable with the same architectural change:

- mouse selection doesn't call `.selectOutOf()`, and hence didn't set
`.selectedOutOf`, which unselecting back into commands with the
keyboard (`MathCommand::unselectInto`) relied on; now instead,
`Cursor::startSelection` computes the persistent reverse ancestor
chain of the anticursor, which `MathCommand::unselectInto` easily
uses to find which block of the command the anticursor is in to
unselect back into. `Fragment::between` can't work with a persistent
ancestor map, of course, but this greatly simplifies finding the LCA
and determining the selection fragment anyway, so now inline that
stuff into `Cursor::select`

- cursor needs to be at the moving edge of the selection, which is
always true with keyboard selection, but with mouse selection, the
cursor could be nested arbitrarily deeply inside the selection, and
the information about the directionality of the selection (and hence
which end of the selection the cursor should be at) was trapped
inside `Fragment::between`; now instead that's all inlined into
`Cursor::select`, which now knows which end of the selection to
insert the cursor at