jagthedrummer/codemirror-ui — pull request #14 by martajd (2012-06-27 17:42:34+00:00)
Title: Replace All fix

This fixes the issue I reported earlier. What would happen is that Replace All was only using findNext(), so anything found beforehand was not replaced. When I added a findPrevious() while loop to replace matching items before the current cursor location what was happening was that if you were replacing the root of a word (e.g. you were replacing 'fast' with 'faster') it would get stuck on the root and repeatedly replace it getting a result like 'fasterererererer', and I'm definitely not that fast. I changed the replace all portion of the code with the replace all function from the CodeMirror search and replace demo from the CodeMirror site. While I don't know all of the nitty gritty, it appears to replace all of them in one fell swoop in a functional manner rather than looping through the words -- avoiding the problem altogether.

Known bug: I haven't implemented a better function for replace (singular) which can still fall into the root-word-loop problem. I will work on implementing the singular function from the CodeMirror site to fix this bug as well, as time permits