I wasnt sure just what happened to the selection and selection length during various editing actions, and I felt I needed to know. Rather than record that learning in tests, I put tracing statements into the code, ran the XML Notepad, and observed the results manually.
I do strongly favor experiments when we dont know something, but here I was trying to learn details before nailing down the basics. It was as if I was fumbling around in the dark, not doing a focused experiment. Tracing statements are a strong sign of trouble, and confused experiments are as well. I should have paid more attention to these signs.