Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
fix python outline nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
baverman committed Oct 21, 2010
1 parent 3b6476a commit 0638ede
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions snaked/plugins/python/outline.py
Expand Up @@ -9,24 +9,26 @@
def get_outline(source):
last_start = 0
last_line = 1
cpath = (None,)
cpath = ()
cpath_levels = (0,)
cname = None
clevel = None
for match in matcher.finditer(source):
last_line = last_line + source.count('\n', last_start, match.start())
last_start = match.start()

level, name = match.group('level', 'name')
level = len(level)

if clevel is None or level < clevel:
cpath = cpath[:-1]
elif level > clevel:
if level < cpath_levels[-1]:
while level < cpath_levels[-1]:
cpath = cpath[:-1]
cpath_levels = cpath_levels[:-1]
elif level > cpath_levels[-1]:
cpath += (cname,)

cpath_levels += (level, )

yield cpath, name, last_line

clevel = level
cname = name

class OutlineDialog(BuilderAware):
Expand Down Expand Up @@ -83,7 +85,8 @@ def fill(self):
elif len(top) > len(ptop):
roots = roots + (self.outline.append(roots[-1], (name, '', line)),)
else:
roots = roots[:-2] + (self.outline.append(roots[-3], (name, '', line)),)
delta = len(ptop) - len(top) + 1
roots = roots[:-delta] + (self.outline.append(roots[-delta-1], (name, '', line)),)

ptop = top

Expand Down

0 comments on commit 0638ede

Please sign in to comment.