Last time out, I found a bug. Our rules of engagement require us to write a test, first to show that the bug exists and later to verify that we have fixed it, but we don’t know how to write that test! We get by with a little help from our friends.
In the previous chapter, I found a defect in the program: when insertion of a new set of paragraph tags takes you below the bottom of the window, the text doesn’t scroll up to keep the cursor on the screen. You have to keep clicking on the scroll bars to bring the line back up.
It took me only a little while to find and fix the defect. Here’s the code, from the XMLNotepad class, with the fix. That’s what we’re going to work on today:
void XMLKeyDownHandler(object ...