From 204d42124a3125be6f84ac66e462a1906585d549 Mon Sep 17 00:00:00 2001 From: Gerald Schmidt Date: Sun, 25 Nov 2007 22:56:21 +0000 Subject: [PATCH] Updated toggle fold so it works if cursor isn't in head line (feature request 1824940). --- src/xmlctrl.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/xmlctrl.cpp b/src/xmlctrl.cpp index 0325823..6d8b5eb 100755 --- a/src/xmlctrl.cpp +++ b/src/xmlctrl.cpp @@ -1728,8 +1728,25 @@ void XmlCtrl::toggleFold() return; line = LineFromPosition ( pos ); level = GetFoldLevel ( line ); - if ( XMLCTRL_HASBIT ( level, wxSTC_FOLDLEVELHEADERFLAG ) ) - ToggleFold ( line ); + + for ( int iterator = line; iterator > 0; iterator--) + { + if (iterator != line) + { + GotoLine ( iterator ); + level = GetFoldLevel ( iterator ); + } + + if ( XMLCTRL_HASBIT ( level, wxSTC_FOLDLEVELHEADERFLAG ) ) + { + ToggleFold ( iterator ); + break; + } + } + +// was previously (changed so cursor doesn't have to be in headline): +// if ( XMLCTRL_HASBIT ( level, wxSTC_FOLDLEVELHEADERFLAG ) ) +// ToggleFold ( line ); } // adapted from wxSTEdit (c) 2005 John Labenski, Otto Wyss