From f8d3a96296b898cbca5faf1e326b3a3b0d162672 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 5 Feb 2025 20:19:18 +1100 Subject: Use new SelectionSegment constructor and SelectionRange::AsSegment to simplify code. --- src/Editor.cxx | 4 ++-- src/PositionCache.cxx | 12 ++++-------- src/Selection.cxx | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index a29aa08fc..77d2eb175 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -8503,8 +8503,8 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case Message::GetLineSelStartPosition: case Message::GetLineSelEndPosition: { const SelectionSegment segmentLine( - SelectionPosition(pdoc->LineStart(LineFromUPtr(wParam))), - SelectionPosition(pdoc->LineEnd(LineFromUPtr(wParam)))); + pdoc->LineStart(LineFromUPtr(wParam)), + pdoc->LineEnd(LineFromUPtr(wParam))); for (size_t r=0; rCount(); r++) { const SelectionSegment portion = psel->Range(r).Intersect(segmentLine); - if (!(portion.start == portion.end)) { - if (portion.start.IsValid()) - Insert(portion.start.Position() - posLineStart); - if (portion.end.IsValid()) - Insert(portion.end.Position() - posLineStart); + if (!portion.Empty()) { + Insert(portion.start.Position() - posLineStart); + Insert(portion.end.Position() - posLineStart); } } // On the curses platform, the terminal is drawing its own caret, so add breaks around the diff --git a/src/Selection.cxx b/src/Selection.cxx index 20fb1efca..527a9d29a 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -327,7 +327,7 @@ SelectionRange Selection::RectangularCopy() const noexcept { SelectionSegment Selection::Limits() const noexcept { PLATFORM_ASSERT(!ranges.empty()); - SelectionSegment sr(ranges[0].anchor, ranges[0].caret); + SelectionSegment sr = ranges[0].AsSegment(); for (size_t i=1; i