aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2004-01-18 07:15:12 +0000
committernyamatongwe <unknown>2004-01-18 07:15:12 +0000
commit7363f3ce9a5068c9c23f948a7e11541f4f9e50d0 (patch)
treeefa32b81b9232cc5feffc2b191b09f6824d95d06
parentc30a000dcbef83732bea3605f5ca94ae8e996f3f (diff)
downloadscintilla-mirror-7363f3ce9a5068c9c23f948a7e11541f4f9e50d0.tar.gz
Patch from Bruce Dodson to ensure correct folding.
When toggling fold on line that is not a fold header line, toggle the previous fold header line.
-rw-r--r--src/Editor.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f02ce2b6a..f9d20aa47 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5276,16 +5276,34 @@ void Editor::Expand(int &line, bool doExpand) {
}
void Editor::ToggleContraction(int line) {
- if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
+ if (line >= 0) {
+ if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) {
+ line = pdoc->GetFoldParent(line);
+ if (line < 0)
+ return;
+ }
+
if (cs.GetExpanded(line)) {
int lineMaxSubord = pdoc->GetLastChild(line);
cs.SetExpanded(line, 0);
if (lineMaxSubord > line) {
cs.SetVisible(line + 1, lineMaxSubord, false);
+
+ int lineCurrent = pdoc->LineFromPosition(currentPos);
+ if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
+ // This does not re-expand the fold
+ EnsureCaretVisible();
+ }
+
SetScrollBars();
Redraw();
}
+
} else {
+ if (!(cs.GetVisible(line))) {
+ EnsureLineVisible(line, false);
+ GoToLine(line);
+ }
cs.SetExpanded(line, 1);
Expand(line, true);
SetScrollBars();