This fixes the problem for single-replaces, but it doesn't work for Replace All. I think the right fix is probably to make the same fix in the call to `_showReplaceAllPanel()` on line 558.

Also, there's a few other confusing things in this function that we should clean up at the same time (they're part of what caused the confusion in the first place). Basically, we should get rid of the outer definition of `match` and `fnMatch` -- I think these were from legacy code that I didn't properly clean up when I refactored some of the original code into `doReplace()`. There's also an `if (all)` block (driven from the `all` parameter) that I think is also obsolete code--I don't think there's any way to get into that `if` anymore, and the new Replace All functionality is in `_showReplaceAllPanel()`.

Let me know if you're comfortable looking into those. If not, I can take a look since I think it was my fault in the first place that they didn't get cleaned up.