Add Shell missing keywords

Add the keyword 'finally' in Execute, to fix miss-indentation
when pasting the following code:
try:
    1
    finally: <-- indent error
        0

Add the keyword 'with' to fix mis-indentation when typing:
with xxx:
| <-- incorrect auto-indentation in the next line
This commit is contained in:
komoto
2021-06-26 04:55:42 +09:00
parent 64e5d863f7
commit 7ff7d46a7e

View File

@@ -1087,7 +1087,7 @@ class Shell(editwindow.EditWindow):
else:
indent=previousLine[:(len(previousLine)-len(lstrip))]
if pstrip[-1]==':' and \
first_word in ['if','else','elif','for','while',
first_word in ['if','else','elif','for','while','with',
'def','class','try','except','finally']:
indent+=' '*4
@@ -1416,7 +1416,8 @@ class Shell(editwindow.EditWindow):
lstrip = line.lstrip()
if line.strip() != '' and lstrip == line and \
lstrip[:4] not in ['else','elif'] and \
lstrip[:6] != 'except':
lstrip[:6] != 'except' and \
lstrip[:7] != 'finally':
# New command.
if command:
# Add the previous command to the list.