diff options
author | Zufu Liu <unknown> | 2021-06-04 20:27:18 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-06-04 20:27:18 +1000 |
commit | 879f0c4c60bd3ba9c75a0f83495eebc7aee66860 (patch) | |
tree | 7aa7a1d1485a0ccd131c428d28400a1f4b2dabe0 | |
parent | b88a820dee352c68e1bf9616d54c1804bf8a15a0 (diff) | |
download | scintilla-mirror-879f0c4c60bd3ba9c75a0f83495eebc7aee66860.tar.gz |
Bug [#2260]. Fix bug with SCI_GETLASTCHILD when lParam is -1.
Fixed cast on SCI_FOLDCHILDREN to use correct type.
-rw-r--r-- | doc/ScintillaHistory.html | 12 | ||||
-rw-r--r-- | src/Document.cxx | 5 | ||||
-rw-r--r-- | src/Editor.cxx | 4 | ||||
-rw-r--r-- | src/Editor.h | 7 |
4 files changed, 23 insertions, 5 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6ef9b2b66..411714498 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -574,6 +574,18 @@ </ul> <h2>Releases</h2> <h3> + <a href="https://www.scintilla.org/scintilla504.zip">Release 5.0.4</a> + </h3> + <ul> + <li> + Released 2 June 2021. + </li> + <li> + Fixed bug with SCI_GETLASTCHILD. + <a href="https://sourceforge.net/p/scintilla/bugs/2260/">Bug #2260</a>. + </li> + </ul> + <h3> <a href="https://www.scintilla.org/scintilla503.zip">Release 5.0.3</a> </h3> <ul> diff --git a/src/Document.cxx b/src/Document.cxx index 74701bd8c..6531ad264 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -525,14 +525,13 @@ static bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept { } Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional<FoldLevel> level, Sci::Line lastLine) { - if (!level) - level = LevelNumberPart(GetFoldLevel(lineParent)); + const FoldLevel levelStart = level.value_or(LevelNumberPart(GetFoldLevel(lineParent))); const Sci::Line maxLine = LinesTotal(); const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1; Sci::Line lineMaxSubord = lineParent; while (lineMaxSubord < maxLine - 1) { EnsureStyledTo(LineStart(lineMaxSubord + 2)); - if (!IsSubordinate(*level, GetFoldLevel(lineMaxSubord + 1))) + if (!IsSubordinate(levelStart, GetFoldLevel(lineMaxSubord + 1))) break; if ((lookLastLine != -1) && (lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) break; diff --git a/src/Editor.cxx b/src/Editor.cxx index e208260ab..f59eb5785 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7363,7 +7363,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->GetLevel(static_cast<Sci::Line>(wParam)); case Message::GetLastChild: - return pdoc->GetLastChild(static_cast<Sci::Line>(wParam), static_cast<FoldLevel>(lParam)); + return pdoc->GetLastChild(static_cast<Sci::Line>(wParam), OptionalFoldLevel(lParam)); case Message::GetFoldParent: return pdoc->GetFoldParent(static_cast<Sci::Line>(wParam)); @@ -7436,7 +7436,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { break; case Message::FoldChildren: - FoldExpand(static_cast<Sci::Line>(wParam), static_cast<FoldAction>(lParam), pdoc->GetFoldLevel(static_cast<int>(wParam))); + FoldExpand(static_cast<Sci::Line>(wParam), static_cast<FoldAction>(lParam), pdoc->GetFoldLevel(static_cast<Sci::Line>(wParam))); break; case Message::FoldAll: diff --git a/src/Editor.h b/src/Editor.h index 08e7d134b..9af2add43 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -624,6 +624,13 @@ protected: // ScintillaBase subclass needs access to much of Editor return static_cast<const char *>(PtrFromUPtr(wParam)); } + constexpr std::optional<FoldLevel> OptionalFoldLevel(Scintilla::sptr_t lParam) { + if (lParam >= 0) { + return static_cast<FoldLevel>(lParam); + } + return std::nullopt; + } + static Scintilla::sptr_t StringResult(Scintilla::sptr_t lParam, const char *val) noexcept; static Scintilla::sptr_t BytesResult(Scintilla::sptr_t lParam, const unsigned char *val, size_t len) noexcept; |