Last blog post I mentioned a problem with the selections, and it has been problematic in many areas for months. As I began to understand it more—because it was an afterthought, "isn't selection is just a bit set on some structure?"—I realized I need to go back to first principles.
I repeatedly go to Polya's How to Solve It for inspiration, and one of the main steps is understanding the problem. And under that is draw a picture. And introduce proper notation. It is math book, but I think that is so great. Proper notation so that you have the units or concepts that you can then manipulate on their own.
And I always underestimate drawing a picture, because usually it seems too simple. Just a box with two arrows, I should be able to keep that in my head. But I'm wrong, it's not about what I can do—it is about making the problem as simple as possible for you. Because the end result is what you create, not the method you took to get there.
I drew this:
And actually I'm cheating because that has the undo system on top, and below that I added restoring selections. And once I drew it, I was like: "oh yeah, just grab the current selection before you do an operation, and another after the operation. Then when you undo, use them again."
But I could not see that without a picture.
And all of a sudden dozens of bugs are fixed all at once.