Description

"As we enjoy great advantages from the inventions of others, we should be
glad of an opportunity to serve others by any invention of ours; and this we
should do freely and generously."

ALT+A and ALT+C to copy all

ALT+R to replace:

"As we enjoy great advantages from the inventions of others, we should be
glad of an opportunity to serve others by any invention of ours; and this we
should do freely and generously."

with

As Ben Franklin put it:
"As we enjoy great advantages from the inventions of others, we should be
glad of an opportunity to serve others by any invention of ours; and this we
should do freely and generously."

Change History
(12)

Actually, the problem here is not recursive replacement, but a repetitive one,
since the search is performed using the wrap=true parameter, so that after reaching the end of the text it simply starts over at the beginning and finds the previous replacements again.

The patch avoids wrapping-around when replacing, it just runs from the very beginning to the end once.
Furthermore I thought it'd be better to not scroll during entire document when performing replace all.

Your patch fixes the problem, thanks!
I'm not sure though why the caret is placed after the last occurence that's been replaced, but the view isn't scrolled to it. I'd say, either you scroll to the caret so the user sees where he's going to type, or don't scroll and leave the caret where it was before the replace action. I think I'd prefer the latter...

Oh, and next time, please use "git format-patch" in order to be easier credited.

I'm not sure though why the caret is placed after the last occurence that's been replaced, but the view isn't scrolled to it. I'd say, either you scroll to the caret so the user sees where he's going to type, or don't scroll and leave the caret where it was before the replace action. I think I'd prefer the latter...

Good point!
Added a final ScrollToSelection() after all replacements are done. Intermediate scrolling is still ommited though.
I think it makes more sense to scroll to the last replacement because the original caret position is not necessarily preserved, for instance when the replacement is an empty string. Then your final caret position is hard to predict.

Oh, and next time, please use "git format-patch" in order to be easier credited.

Added a final ScrollToSelection() after all replacements are done. Intermediate scrolling is still ommited though.
I think it makes more sense to scroll to the last replacement because the original caret position is not necessarily preserved, for instance when the replacement is an empty string. Then your final caret position is hard to predict.

Hmm... isn't as trivial as I first thought then. I guess one would have to save the original caret position and then account for the number of characters that were removed/added by the replacement action. I may file another enhancement ticket for that...

Oh, and next time, please use "git format-patch" in order to be easier credited.

You'll have to locally commit your changes first. Then "git format-patch origin" will generate the patch. No need to "git diff" . As usual it's most convenient to work in your own branch, never on master.