Use an abstract item model for search and replace matches
This is a quite big change...
This change introduces a model to store the matches and should improve both the performance and code readability.
One new feature is also introduced: Try to keep the ranges up to date in the model also if we edit the document.