aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ContractionState.cxx26
-rw-r--r--src/ContractionState.h1
-rw-r--r--src/Editor.cxx13
3 files changed, 29 insertions, 11 deletions
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index 8b4babb2e..eacda2ce2 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -80,6 +80,7 @@ public:
bool GetExpanded(Sci::Line lineDoc) const noexcept override;
bool SetExpanded(Sci::Line lineDoc, bool isExpanded) override;
+ bool ExpandAll() override;
Sci::Line ContractedNext(Sci::Line lineDocStart) const noexcept override;
int GetHeight(Sci::Line lineDoc) const noexcept override;
@@ -248,23 +249,26 @@ bool ContractionState<LINE>::SetVisible(Sci::Line lineDocStart, Sci::Line lineDo
return false;
} else {
EnsureData();
- Sci::Line delta = 0;
Check();
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
+ bool changed = false;
for (Sci::Line line = lineDocStart; line <= lineDocEnd; line++) {
if (GetVisible(line) != isVisible) {
+ changed = true;
const int heightLine = heights->ValueAt(static_cast<LINE>(line));
const int difference = isVisible ? heightLine : -heightLine;
- visible->SetValueAt(static_cast<LINE>(line), isVisible ? 1 : 0);
displayLines->InsertText(static_cast<LINE>(line), difference);
- delta += difference;
}
}
+ if (changed) {
+ visible->FillRange(static_cast<LINE>(lineDocStart), isVisible ? 1 : 0,
+ static_cast<LINE>(lineDocEnd - lineDocStart) + 1);
+ }
+ Check();
+ return changed;
} else {
return false;
}
- Check();
- return delta != 0;
}
}
@@ -326,6 +330,18 @@ bool ContractionState<LINE>::SetExpanded(Sci::Line lineDoc, bool isExpanded) {
}
template <typename LINE>
+bool ContractionState<LINE>::ExpandAll() {
+ if (OneToOne()) {
+ return false;
+ } else {
+ const LINE lines = expanded->Length();
+ const bool changed = expanded->FillRange(0, 1, lines).changed;
+ Check();
+ return changed;
+ }
+}
+
+template <typename LINE>
Sci::Line ContractionState<LINE>::ContractedNext(Sci::Line lineDocStart) const noexcept {
if (OneToOne()) {
return -1;
diff --git a/src/ContractionState.h b/src/ContractionState.h
index 55c390c55..ae753f8d1 100644
--- a/src/ContractionState.h
+++ b/src/ContractionState.h
@@ -36,6 +36,7 @@ public:
virtual bool GetExpanded(Sci::Line lineDoc) const noexcept=0;
virtual bool SetExpanded(Sci::Line lineDoc, bool isExpanded)=0;
+ virtual bool ExpandAll()=0;
virtual Sci::Line ContractedNext(Sci::Line lineDocStart) const noexcept =0;
virtual int GetHeight(Sci::Line lineDoc) const noexcept=0;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 5b0486be0..a4e2cc732 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5414,18 +5414,23 @@ void Editor::SetEOLAnnotationVisible(EOLAnnotationVisible visible) {
Sci::Line Editor::ExpandLine(Sci::Line line) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
line++;
+ Sci::Line lineStart = line;
while (line <= lineMaxSubord) {
- pcs->SetVisible(line, line, true);
const FoldLevel level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level)) {
+ pcs->SetVisible(lineStart, line, true);
if (pcs->GetExpanded(line)) {
line = ExpandLine(line);
} else {
line = pdoc->GetLastChild(line);
}
+ lineStart = line + 1;
}
line++;
}
+ if (lineStart <= lineMaxSubord) {
+ pcs->SetVisible(lineStart, lineMaxSubord, true);
+ }
return lineMaxSubord;
}
@@ -5588,11 +5593,7 @@ void Editor::FoldAll(FoldAction action) {
}
if (expanding) {
pcs->SetVisible(0, maxLine-1, true);
- for (Sci::Line line = 0; line < maxLine; line++) {
- if (!pcs->GetExpanded(line)) {
- SetFoldExpanded(line, true);
- }
- }
+ pcs->ExpandAll();
} else {
for (Sci::Line line = 0; line < maxLine; line++) {
const FoldLevel level = pdoc->GetFoldLevel(line);