From 98b4417eb304b428ea1344e2c8853b7ef021864c Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 16 Oct 2014 14:12:03 +1100 Subject: Explain how multiple selections are processed. --- src/Editor.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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 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::reverse_iterator rit = selPtrs.rbegin(); rit != selPtrs.rend(); ++rit) { SelectionRange *currentSel = *rit; -- cgit v1.2.3