Handle coincident page marks better #1277
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
ReplaceSelectionsWith
function handles keeping page marks in approximately the same location when a Search/Replace operation spans a page boundary (by maintaining the relative proportion of text each side of the page boundary).This did not cope correctly when there were two or more page marks at the same location (i.e. blank pages). The page marks could get reversed, so that 015 came before 014, for example (although still both at the same location).
Avoiding changing the mark gravity (whether the mark goes left or right of text inserted at the mark) fixes this for marks within the S/R region. Temporarily setting "right" gravity for page marks that immediately follow the S/R region keeps those page marks correct.