Patch #2570 2008-09-29 14:42

xayc

GotoLine folding support
Download
2570-GotoLine_foldi.patch (1.0 KB)
Category
Application::Refinement
Status
Closed
Close date
2008-10-06 19:42
Assigned to
 
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 5236)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -1761,14 +1761,22 @@
 void cbEditor::GotoLine(int line, bool centerOnScreen)
 {
     cbStyledTextCtrl* control = GetControl();
+
+    // Make sure the line is not folded. This is done before moving to that
+    // line because folding may change the lines layout.
+    control->EnsureVisible(line);
+
+    // If the line following is a fold point it will be unfolded, in this way
+    // when the line is a function declaration the body is shown.
+    DoFoldLine(line+1,0);
+
     if (centerOnScreen)
     {
-        int onScreen = control->LinesOnScreen() >> 1;
+        int onScreen = control->LinesOnScreen() / 2;
         control->GotoLine(line - onScreen);
         control->GotoLine(line + onScreen);
     }
     control->GotoLine(line);
-    UnfoldBlockFromLine(line); // make sure it's visible (not folded)
 }
 
 bool cbEditor::AddBreakpoint(int line, bool notifyDebugger)
xayc 2008-09-29 14:44

With this patch most of the GotoLine functions used in CB will work correctly even if the destination line is folded or is a function declaration.

killerbot 2008-10-06 19:42

applied. thanks (rev 5242)