From b7315c392871baaa548188789cf2bac5dea097e4 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Mon, 28 Apr 2008 16:34:23 +0100 Subject: [PATCH] Improved the autoindent stuff The autoindent should work now with multiple levels of indenting. e.g.: def foo(): def bar(): def baz(): print "hi" print "ho" --- bpython.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bpython.py b/bpython.py index e08f468..c93be35 100644 --- a/bpython.py +++ b/bpython.py @@ -1003,11 +1003,16 @@ class Repl: idiot).""" self.ts = '' - indent = self.s.endswith(':') or self.s.startswith('\t') + n_indent = re.split( '[^\t]', self.s, 1 )[0].count('\t') + indent = self.s.endswith(':') self.s = '' self.iy, self.ix = self.scr.getyx() - if indent:#self.s_hist and self.s_hist[-1].rstrip().endswith(':'): + for i in range(n_indent): + self.c = '\t' + self.p_key() + + if indent: self.c = '\t' self.p_key()