diff options
author | Neil <nyamatongwe@gmail.com> | 2023-01-19 13:28:57 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-01-19 13:28:57 +1100 |
commit | 66f54388680a2617144e2bd3b4610f431c37fc02 (patch) | |
tree | 1bae29e1f6e25854fe5916782206a960c129a524 /src/Document.cxx | |
parent | 6039080cfba2b9344fa9cde2ba5688d2db590d66 (diff) | |
download | scintilla-mirror-66f54388680a2617144e2bd3b4610f431c37fc02.tar.gz |
Feature [feature-requests:#1444] Move GetFoldParent from Document to LineLevels
as better modularity. Add LineLevels::GetFoldLevel for better type safety.
Simplify bounds checks in GetLevel and GetFoldLevel.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 95777278c..9d1bf1d3b 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -559,7 +559,7 @@ int SCI_METHOD Document::GetLevel(Sci_Position line) const { } FoldLevel Document::GetFoldLevel(Sci_Position line) const noexcept { - return static_cast<FoldLevel>(Levels()->GetLevel(line)); + return Levels()->GetFoldLevel(line); } void Document::ClearLevels() { @@ -598,14 +598,7 @@ Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional<FoldLevel> } Sci::Line Document::GetFoldParent(Sci::Line line) const noexcept { - const FoldLevel level = LevelNumberPart(GetFoldLevel(line)); - for (Sci::Line lineLook = line - 1; lineLook >= 0; lineLook--) { - const FoldLevel levelTry = GetFoldLevel(lineLook); - if (LevelIsHeader(levelTry) && LevelNumberPart(levelTry) < level) { - return lineLook; - } - } - return -1; + return Levels()->GetFoldParent(line); } void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) { |