PythonWin/Scintilla aggressive folding...
Olivier Dagenais
olivierS.dagenaisP at canadaA.comM
Tue Jul 25 22:39:57 EDT 2000
If you don't mind, I opened a bug to track the issue:
https://sourceforge.net/bugs/?func=detailbug&bug_id=110240&group_id=2439
It's not a big rush for me to have this feature (dang, I should have opened
it as a "Feature Request"), but I would appreciate it as much as (or more
than) Mark and others.
I would, on the other hand, comment your example as follows (so as to keep
the code looking consistent):
def z(y):
x = 1
# x = sin(y)
return x*2
If you assumed that comments were not "level neutral", would that fix it for
me? Maybe this could be an option, a flag of somesort called
"LevelNeutralComments"??? Is this a work-around-patch-fix that would
satisfy more than me? Would a different type of comment (like a double or
triple sharp?) also help?
There's still the issue of blank lines after a fold. I've noticed that
strings on a line don't seem to execute anything, so if you change my
comment in the example with a string:
class ztApp ( wxApp ) :
def OnInit ( self ) :
frame = ztLoader ( )
frame.Show ( true )
self.SetTopWindow ( frame )
return true
""" Main code """
pngHandler = wxPNGHandler ( )
wxImage_AddHandler ( pngHandler )
app = ztApp ( 0 )
app.MainLoop ( )
...the string isn't folded in with the class... And since a triple-quote
string can also span multiple lines...
"""
<blank lines>
Main code
<blank lines>
"""
...I'm cool with that... But I have a feeling that I might have a memory or
performance issue if I start sprinkling "triple-quote comments" all over the
place like that. Is this the case? Maybe the triple-sharp comment idea
would be better??
--
----------------------------------------------------------------------
Olivier A. Dagenais - Carleton University - Computer Science III
"Neil Hodgson" <neilh at scintilla.org> wrote in message
news:2trf5.12076$4p3.93728 at news-server.bigpond.net.au...
> [PythonWin / Scintilla folds away comments that belong to next
> definition]
>
> Mark's comments are correct but I'd like to explain a little more.
>
> Scintilla uses a simple fold discovery algorithm that relies mostly on
> indentation and only looks at a narrow window of lines. Often, comments
are
> not indented with the executable code so are treated by the folder as
having
> a 'neutral' indentation level which will bind to the indentation level of
a
> nearby piece of executable code. Blank lines also have neutral indentation
> level as they are often sprinkled within a function. This allows a
function
> like
>
> def z(y):
> x = 1
> # x = sin(y)
>
> return x*2
>
> to fold correctly. It has the downside of binding the top level comment
> in your example to the preceding definition.
>
> This could be fixed by doing a much better job of parsing the Python
code
> or by doing some more tweaks such as detecting this particular common
case.
> The argument against a really good parser is the need for performance as
the
> folding structure is being continuously recalculated as editing occurs.
>
> Eventually I'll do some more work on the code folder but haven't yet
> found a good alternative. It'd be great if someone else was interested in
> working on this.
>
> Neil
>
>
>
More information about the Python-list
mailing list