@@ -1571,7 +1571,7 @@ def reindent_to(self, column):
15711571 # blocks are found).
15721572
15731573 def guess_indent (self ):
1574- opener , indented = IndentSearcher (self .text , self . tabwidth ).run ()
1574+ opener , indented = IndentSearcher (self .text ).run ()
15751575 if opener and indented :
15761576 raw , indentsmall = get_line_indent (opener , self .tabwidth )
15771577 raw , indentlarge = get_line_indent (indented , self .tabwidth )
@@ -1609,15 +1609,10 @@ def get_line_indent(line, tabwidth):
16091609
16101610
16111611class IndentSearcher :
1612+ "Manage initial indent guess, returned by run method."
16121613
1613- # .run() chews over the Text widget, looking for a block opener
1614- # and the stmt following it. Returns a pair,
1615- # (line containing block opener, line containing stmt)
1616- # Either or both may be None.
1617-
1618- def __init__ (self , text , tabwidth ):
1614+ def __init__ (self , text ):
16191615 self .text = text
1620- self .tabwidth = tabwidth
16211616 self .i = self .finished = 0
16221617 self .blkopenline = self .indentedline = None
16231618
@@ -1633,7 +1628,8 @@ def readline(self):
16331628 def tokeneater (self , type , token , start , end , line ,
16341629 INDENT = tokenize .INDENT ,
16351630 NAME = tokenize .NAME ,
1636- OPENERS = ('class' , 'def' , 'for' , 'if' , 'try' , 'while' )):
1631+ OPENERS = ('class' , 'def' , 'for' , 'if' , 'match' , 'try' ,
1632+ 'while' , 'with' )):
16371633 if self .finished :
16381634 pass
16391635 elif type == NAME and token in OPENERS :
@@ -1643,6 +1639,10 @@ def tokeneater(self, type, token, start, end, line,
16431639 self .finished = 1
16441640
16451641 def run (self ):
1642+ """Return 2 lines containing block opener and and indent.
1643+
1644+ Either the indent line or both may be None.
1645+ """
16461646 try :
16471647 tokens = tokenize .generate_tokens (self .readline )
16481648 for token in tokens :
@@ -1654,6 +1654,7 @@ def run(self):
16541654
16551655### end autoindent code ###
16561656
1657+
16571658def prepstr (s ):
16581659 """Extract the underscore from a string.
16591660
0 commit comments