diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 5 | ||||
| -rw-r--r-- | src/Editor.cxx | 4 | ||||
| -rw-r--r-- | src/Editor.h | 7 | 
3 files changed, 11 insertions, 5 deletions
| 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; | 
