Skip to content

Commit 660fbd3

Browse files
committed
significant refactor
1 parent 83bafff commit 660fbd3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Lib/idlelib/editor.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,11 +1368,18 @@ def smart_backspace_event(self, event):
13681368

13691369
# Debug prompt is multilined....
13701370
ncharsdeleted = 0
1371+
have = len(chars.expandtabs(tabwidth))
13711372
for i in range(len(chars) - 1, -1, -1):
1372-
have = len(chars.expandtabs(tabwidth))
1373-
if have <= want or chars[i] not in " \t":
1374-
break
1373+
# ``Delete'' chars[i], and subtract count
1374+
# (since redoing expandtabs is O(n))
13751375
ncharsdeleted += 1
1376+
if chars[i] == '\t':
1377+
have -= tabwidth
1378+
else:
1379+
have -= 1
1380+
if have <= want or chars[i-1] not in " \t":
1381+
break
1382+
# Perform the actual removal
13761383
chars = chars[:len(chars) - ncharsdeleted]
13771384

13781385
text.undo_block_start()

0 commit comments

Comments
 (0)