aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Selection.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-02-05 12:37:59 +1100
committerNeil <nyamatongwe@gmail.com>2025-02-05 12:37:59 +1100
commitac415de8e8457471528908f73996be78613c4620 (patch)
tree4c80b3ad47b2af01d085ba96260020c76745f9a4 /src/Selection.h
parent3b6cb53b53977939b47eda34fd1d16a91e6517ec (diff)
downloadscintilla-mirror-ac415de8e8457471528908f73996be78613c4620.tar.gz
Simplify SelectionRange::Intersect and add SelectionRange constructor from
positions without virtual space. Add unit tests.
Diffstat (limited to 'src/Selection.h')
-rw-r--r--src/Selection.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Selection.h b/src/Selection.h
index 57de92a57..8ffcbb0bb 100644
--- a/src/Selection.h
+++ b/src/Selection.h
@@ -81,6 +81,12 @@ struct SelectionSegment {
end = a;
}
}
+ constexpr SelectionSegment(Sci::Position a, Sci::Position b) :
+ SelectionSegment(SelectionPosition(a), SelectionPosition(b)) {
+ }
+ [[nodiscard]] constexpr bool operator ==(const SelectionSegment &other) const noexcept {
+ return (start == other.start) && (end == other.end);
+ }
bool Empty() const noexcept {
return start == end;
}
@@ -115,6 +121,9 @@ struct SelectionRange {
constexpr SelectionRange(Sci::Position caret_, Sci::Position anchor_) noexcept : caret(caret_), anchor(anchor_) {
}
explicit SelectionRange(std::string_view sv);
+ SelectionSegment AsSegment() const noexcept {
+ return {caret, anchor};
+ }
bool Empty() const noexcept {
return anchor == caret;
}