From 2345f51b8fea92bf794300c5b4373ee3c03eb1e0 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 7 Feb 2026 11:55:11 +1100 Subject: Avoid some warnings to make more interesting issues visible. --- src/EditView.cxx | 17 +++++++++-------- src/EditView.h | 2 +- src/PositionCache.cxx | 5 ++--- src/PositionCache.h | 2 ++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/EditView.cxx b/src/EditView.cxx index a34b0cbba..553a43307 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -190,7 +190,7 @@ EditView::EditView() { imeCaretBlockOverride = false; llc.SetLevel(LineCache::Caret); posCache = CreatePositionCache(); - posCache->SetSize(0x400); + posCache->SetSize(positionCacheDefaultSize); maxLayoutThreads = 1; tabArrowHeight = 4; customDrawTabArrow = nullptr; @@ -740,7 +740,8 @@ SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditMo const int spaceOffset = static_cast( (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth); return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset); - } else if (canReturnInvalid) { + } + if (canReturnInvalid) { if (pt.x < (ll->positions[rangeSubLine.end] - subLineStart)) { return SelectionPosition(model.pdoc->MovePositionOutsideChar(rangeSubLine.end + posLineStart, 1)); } @@ -1908,7 +1909,7 @@ void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, // Draw the arrow head if needed if (vsDraw.tabDrawMode == TabDrawMode::LongArrow) { - XYPOSITION ydiff = std::floor(rcTab.Height() / 2.0f); + XYPOSITION ydiff = std::floor(rcTab.Height() / 2); XYPOSITION xhead = rightStroke - ydiff; if (xhead <= rcTab.left) { ydiff -= rcTab.left - xhead; @@ -2027,7 +2028,7 @@ void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &v const Sci::Position endPos = std::min(rangeRun.end, posLineEnd); const int edition = model.pdoc->EditionAt(startPos); if (edition != 0) { - const int indicator = (edition - 1) * 2 + indexHistory; + const int indicator = ((edition - 1) * 2) + indexHistory; const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1); DrawIndicator(indicator, startPos - posLineStart, endPos - posLineStart, surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, Indicator::State::normal, @@ -2044,7 +2045,7 @@ void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &v const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(startPos + 1, 1); for (unsigned int edition = 0; edition < 4; edition++) { if (editions & (1 << edition)) { - const int indicator = edition * 2 + indexHistory + 1; + const int indicator = (edition * 2) + indexHistory + 1; DrawIndicator(indicator, startPos - posLineStart, posSecond - posLineStart, surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, Indicator::State::normal, 1, model.BidirectionalEnabled(), tabWidthMinimumPixels); @@ -2103,7 +2104,7 @@ ColourRGBA InvertedLight(ColourRGBA orig) noexcept { } -void EditView::DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset) { +void EditView::DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset) const { const Point from = Point::FromInts(0, offset ? 1 : 0); const PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom); @@ -2215,7 +2216,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.WhiteSpaceVisible(inIndentation)) { const PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - const int segmentTop = static_cast(rcSegment.top) + vsDraw.lineHeight / 2; + const int segmentTop = static_cast(rcSegment.top) + (vsDraw.lineHeight / 2); const ColourRGBA whiteSpaceFore = vsDraw.ElementColour(Element::WhiteSpace).value_or(textFore); if (!customDrawTabArrow) DrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(whiteSpaceFore, 1.0f)); @@ -2282,7 +2283,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } const int halfDotWidth = vsDraw.whitespaceSize / 2; PRectangle rcDot(xmid - halfDotWidth, - rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); + rcSegment.top + (vsDraw.lineHeight / 2), 0.0f, 0.0f); rcDot.right = rcDot.left + vsDraw.whitespaceSize; rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; const ColourRGBA whiteSpaceFore = vsDraw.ElementColour(Element::WhiteSpace).value_or(textFore); diff --git a/src/EditView.h b/src/EditView.h index 10ba31fa6..58e9c3d80 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -144,7 +144,7 @@ private: Sci::Line line, int xOrigin, PRectangle rcLine, int subLine, DrawPhase phase); void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineDoc, int xOrigin, PRectangle rcLine, int subLine) const; - void DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset); + void DrawIndentGuide(Surface *surface, XYPOSITION start, PRectangle rcSegment, bool highlight, bool offset) const; void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Sci::Line lineVisible, Range lineRange, Sci::Position posLineStart, ColourOptional background); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index abe467f10..1f05ca752 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -1000,14 +1000,13 @@ public: }; class PositionCache : public IPositionCache { - static constexpr size_t defaultCacheSize = 0x400; - std::vector pces{ defaultCacheSize }; + std::vector pces{ positionCacheDefaultSize }; std::mutex mutex; uint16_t clock = 1; bool allClear = true; public: PositionCache(); - // Deleted so LineAnnotation objects can not be copied. + // Deleted so PositionCache objects can not be copied. PositionCache(const PositionCache &) = delete; PositionCache(PositionCache &&) = delete; void operator=(const PositionCache &) = delete; diff --git a/src/PositionCache.h b/src/PositionCache.h index d8f778c5c..9138d18e7 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -257,6 +257,8 @@ public: bool More() const noexcept; }; +constexpr size_t positionCacheDefaultSize = 0x400; + class IPositionCache { public: virtual ~IPositionCache() = default; -- cgit v1.2.3