diff options
| author | Neil <nyamatongwe@gmail.com> | 2026-02-07 11:55:11 +1100 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2026-02-07 11:55:11 +1100 |
| commit | 2345f51b8fea92bf794300c5b4373ee3c03eb1e0 (patch) | |
| tree | b91bd6ffa839c976a923137d05204f3c37032bc8 | |
| parent | ac8ccbc3eaea26e831e1751fc627cf0bb09c190d (diff) | |
| download | scintilla-mirror-2345f51b8fea92bf794300c5b4373ee3c03eb1e0.tar.gz | |
Avoid some warnings to make more interesting issues visible.
| -rw-r--r-- | src/EditView.cxx | 17 | ||||
| -rw-r--r-- | src/EditView.h | 2 | ||||
| -rw-r--r-- | src/PositionCache.cxx | 5 | ||||
| -rw-r--r-- | 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<int>( (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<int>(rcSegment.top) + vsDraw.lineHeight / 2; + const int segmentTop = static_cast<int>(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<PositionCacheEntry> pces{ defaultCacheSize }; + std::vector<PositionCacheEntry> 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; |
