tab errors

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-10-22 22:25:45 +00:00
parent 49cd3e5974
commit 6a3002fa6c
2 changed files with 14 additions and 1 deletions

View File

@ -179,7 +179,7 @@ class PythonTabber(tab.StackTabber):
self._append(token.string, currlvl + w)
elif token.string in ('elif', 'else') and self.is_leftmost_token(y, i):
# we know we'll unindent at least to the first if/elif
if not self.popped and not self.last_popped:
if not self.popped and not self.last_popped and self._peek_until('if', 'elif'):
self._pop_until('if', 'elif')
currlvl = self.get_curr_level()
self._append(token.string, currlvl + w)

13
tab.py
View File

@ -188,6 +188,13 @@ class StackTabber(Tabber):
return self.markers[-1]
else:
return None
def _peek_until(self, *names):
for i in range(1, len(self.markers) + 1):
x = self.markers[-i]
if x.name in names:
return x
return None
def _peek_name(self):
if self.markers:
return self.markers[-1].name
@ -310,6 +317,12 @@ class StackTabber2(Tabber):
return self.stack[-1]
else:
return None
def _peek_until(self, *names):
for i in range(1, len(self.stack) + 1):
x = self.stack[-i]
if x.name in names:
return x
return None
def _get_tokens(self, y):
return self.mode.window.buffer.highlights[self.name].tokens[y]