diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Selection.cxx | 27 | ||||
-rw-r--r-- | src/Selection.h | 12 |
2 files changed, 21 insertions, 18 deletions
diff --git a/src/Selection.cxx b/src/Selection.cxx index 53559e329..48cebb16c 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -230,7 +230,7 @@ SelectionSegment Selection::Limits() const noexcept { } } -SelectionSegment Selection::LimitsForRectangularElseMain() const { +SelectionSegment Selection::LimitsForRectangularElseMain() const noexcept { if (IsRectangular()) { return Limits(); } else { @@ -343,10 +343,12 @@ void Selection::TrimOtherSelections(size_t r, SelectionRange range) noexcept { } } -void Selection::SetSelection(SelectionRange range) { - ranges.clear(); - ranges.push_back(range); - mainRange = ranges.size() - 1; +void Selection::SetSelection(SelectionRange range) noexcept { + if (ranges.size() > 1) { + ranges.erase(ranges.begin() + 1, ranges.end()); + } + ranges[0] = range; + mainRange = 0; } void Selection::AddSelection(SelectionRange range) { @@ -360,7 +362,7 @@ void Selection::AddSelectionWithoutTrim(SelectionRange range) { mainRange = ranges.size() - 1; } -void Selection::DropSelection(size_t r) { +void Selection::DropSelection(size_t r) noexcept { if ((ranges.size() > 1) && (r < ranges.size())) { size_t mainNew = mainRange; if (mainNew >= r) { @@ -375,7 +377,7 @@ void Selection::DropSelection(size_t r) { } } -void Selection::DropAdditionalRanges() { +void Selection::DropAdditionalRanges() noexcept { SetSelection(RangeMain()); } @@ -425,17 +427,18 @@ Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const noexcept { return virtualSpace; } -void Selection::Clear() { - ranges.clear(); - ranges.emplace_back(); - mainRange = ranges.size() - 1; +void Selection::Clear() noexcept { + if (ranges.size() > 1) { + ranges.erase(ranges.begin() + 1, ranges.end()); + } + mainRange = 0; selType = SelTypes::stream; moveExtends = false; ranges[mainRange].Reset(); rangeRectangular.Reset(); } -void Selection::RemoveDuplicates() { +void Selection::RemoveDuplicates() noexcept { for (size_t i=0; i<ranges.size()-1; i++) { if (ranges[i].Empty()) { size_t j=i+1; diff --git a/src/Selection.h b/src/Selection.h index 03ce5083c..9f7d73c3c 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -166,7 +166,7 @@ public: // This is for when you want to move the caret in response to a // user direction command - for rectangular selections, use the range // that covers all selected text otherwise return the main selection. - SelectionSegment LimitsForRectangularElseMain() const; + SelectionSegment LimitsForRectangularElseMain() const noexcept; size_t Count() const noexcept; size_t Main() const noexcept; void SetMain(size_t r) noexcept; @@ -183,19 +183,19 @@ public: void MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) noexcept; void TrimSelection(SelectionRange range) noexcept; void TrimOtherSelections(size_t r, SelectionRange range) noexcept; - void SetSelection(SelectionRange range); + void SetSelection(SelectionRange range) noexcept; void AddSelection(SelectionRange range); void AddSelectionWithoutTrim(SelectionRange range); - void DropSelection(size_t r); - void DropAdditionalRanges(); + void DropSelection(size_t r) noexcept; + void DropAdditionalRanges() noexcept; void TentativeSelection(SelectionRange range); void CommitTentative() noexcept; InSelection RangeType(size_t r) const noexcept; InSelection CharacterInSelection(Sci::Position posCharacter) const noexcept; InSelection InSelectionForEOL(Sci::Position pos) const noexcept; Sci::Position VirtualSpaceFor(Sci::Position pos) const noexcept; - void Clear(); - void RemoveDuplicates(); + void Clear() noexcept; + void RemoveDuplicates() noexcept; void RotateMain() noexcept; bool Tentative() const noexcept { return tentativeMain; } std::vector<SelectionRange> RangesCopy() const { |