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/PositionCache.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/PositionCache.cxx') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 9cb617174..5cc8f8fe8 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -856,16 +856,12 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin } if (FlagSet(breakFor, BreakFor::Selection)) { - const SelectionPosition posStart(posLineStart); - const SelectionPosition posEnd(posLineStart + lineRange.end); - const SelectionSegment segmentLine(posStart, posEnd); + const SelectionSegment segmentLine(posLineStart, posLineStart + lineRange.end); 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 -- cgit v1.2.3