aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2021-09-29 14:04:04 +1000
committerZufu Liu <unknown>2021-09-29 14:04:04 +1000
commitec6eb4ba32bf8009102b28f1e4c0d86dc133c5b2 (patch)
treec7c900c3be5567471a99129df95391af7687ca01
parentb223a152d5da7907fa7e8513b107a9cb750c9d5d (diff)
downloadscintilla-mirror-ec6eb4ba32bf8009102b28f1e4c0d86dc133c5b2.tar.gz
Feature [feature-requests:#1416] Shorten code and avoid cppcheck warning.
-rw-r--r--cppcheck.suppress3
-rw-r--r--win32/PlatWin.cxx8
2 files changed, 1 insertions, 10 deletions
diff --git a/cppcheck.suppress b/cppcheck.suppress
index c1b047974..4524c66ed 100644
--- a/cppcheck.suppress
+++ b/cppcheck.suppress
@@ -22,9 +22,6 @@ shiftTooManyBitsSigned:scintilla/src/MarginView.cxx
// DLL entry points are unused inside Scintilla
unusedFunction:scintilla\win32\ScintillaDLL.cxx
-// Doesn't see change: int x = 1; if (b) { x = y; } if (x > 3) {
-knownConditionTrueFalse:scintilla\win32\PlatWin.cxx
-
// The styler parameter is not const as LexAccessor::operator[] is not const
constParameter:scintilla/lexlib/StyleContext.cxx
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index c4f08b798..9035aa6f2 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -3714,13 +3714,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
if (std::abs(wheelDelta) >= WHEEL_DELTA) {
const int nRows = GetVisibleRows();
- int linesToScroll = 1;
- if (nRows > 1) {
- linesToScroll = nRows - 1;
- }
- if (linesToScroll > 3) {
- linesToScroll = 3;
- }
+ int linesToScroll = std::clamp(nRows - 1, 1, 3);
linesToScroll *= (wheelDelta / WHEEL_DELTA);
int top = ListBox_GetTopIndex(lb) + linesToScroll;
if (top < 0) {