aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ebe65f1fa..bd15ac74e 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1790,12 +1790,15 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
{
UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
+ // Vector elements point into selection in order to change selection.
std::vector<SelectionRange *> selPtrs;
for (size_t r = 0; r < sel.Count(); r++) {
selPtrs.push_back(&sel.Range(r));
}
+ // Order selections by position in document.
std::sort(selPtrs.begin(), selPtrs.end(), cmpSelPtrs);
+ // Loop in reverse to avoid disturbing positions of selections yet to be processed.
for (std::vector<SelectionRange *>::reverse_iterator rit = selPtrs.rbegin();
rit != selPtrs.rend(); ++rit) {
SelectionRange *currentSel = *rit;