mathquill/mathquill — pull request #141 by laughinghan (2013-01-02 05:58:03+00:00)
Title: first successful fix for selecting in TextBlocks

@jayferd, can you take a look? I'm sick of it and need a fresh set of eyes. It's pretty ugly, way too much checking of the `anticursor`.

Food for thought, `blur` is called on the `TextBlock` in 3 situations:
- clicking or keyboard-moving outside the `TextBlock`. We actually want to merge all `TextPiece`s in this case
- keyboard-selecting out of the `TextBlock` (which involves the `cursor` moving out of the `TextBlock`). We don't want to merge the `TextPiece`s around the `anticursor` in this case, and there shouldn't be anything else at all that needs merging (since to keyboard-select out of the `TextBlock`, the `cursor` must've been at the edge)
- mouse-selecting within or outside the `TextBlock`, `blur` is called **_twice_**, when `seek`ing and again after `select`ing. We want to merge the `TextPiece`s around where the `cursor` was but **_not_** around where the `anticursor` is

If we're pickier about when we try to merge, maybe we can be less worried about munging the `anticursor`'s surrounding `TextPiece`s.