diff options
author | Neil <nyamatongwe@gmail.com> | 2025-04-08 09:55:08 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-04-08 09:55:08 +1000 |
commit | 4e19675d86a4e9102b1aef5d16df3977d4ef2b61 (patch) | |
tree | ba87622205d2d09baeb93398c01e3480bd7489be | |
parent | a50597cb964a00bc4dccfafbda1501a0e14d32b9 (diff) | |
download | scintilla-mirror-4e19675d86a4e9102b1aef5d16df3977d4ef2b61.tar.gz |
Simplify code and fix impossible INTEGER_OVERFLOW warning from Coverity.
-rw-r--r-- | src/Document.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index b4fa617b2..027790303 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -632,14 +632,14 @@ constexpr bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional<FoldLevel> level, Sci::Line lastLine) { const FoldLevel levelStart = LevelNumberPart(level ? *level : GetFoldLevel(lineParent)); - const Sci::Line maxLine = LinesTotal(); - const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1; + const Sci::Line maxLine = LinesTotal() - 1; + const Sci::Line lookLastLine = (lastLine != -1) ? std::min(maxLine, lastLine) : maxLine; Sci::Line lineMaxSubord = lineParent; - while (lineMaxSubord < maxLine - 1) { + while (lineMaxSubord < maxLine) { EnsureStyledTo(LineStart(lineMaxSubord + 2)); if (!IsSubordinate(levelStart, GetFoldLevel(lineMaxSubord + 1))) break; - if ((lookLastLine != -1) && (lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) + if ((lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) break; lineMaxSubord++; } |