Skip to content

Commit a38b816

Browse files
author
Bob Farrell
committed
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" committer: Bob Farrell <bob@keys.(none)>
1 parent c8300a6 commit a38b816

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎bpython.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,11 +1003,16 @@ def get_line( self ):
10031003
idiot)."""
10041004

10051005
self.ts = ''
1006-
indent = self.s.endswith(':') or self.s.startswith('\t')
1006+
n_indent = re.split( '[^\t]', self.s, 1 )[0].count('\t')
1007+
indent = self.s.endswith(':')
10071008
self.s = ''
10081009
self.iy, self.ix = self.scr.getyx()
10091010

1010-
if indent:#self.s_hist and self.s_hist[-1].rstrip().endswith(':'):
1011+
for i in range(n_indent):
1012+
self.c = '\t'
1013+
self.p_key()
1014+
1015+
if indent:
10111016
self.c = '\t'
10121017
self.p_key()
10131018

0 commit comments

Comments
 (0)