Skip to content

Commit c5edb5d

Browse files
return original text on non-zero exit in external editor
1 parent dd1373f commit c5edb5d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bpython/repl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ def clear_current_line(self):
995995
It prevents autoindentation from occuring after a traceback."""
996996

997997
def send_to_external_editor(self, text, filename=None):
998+
"""Returns modified text from an editor, or the oriignal text if editor exited with non-zero"""
998999
editor = (self.config.editor or
9991000
os.environ.get('VISUAL', os.environ.get('EDITOR', 'vim')))
10001001
editor_args = shlex.split(editor)
@@ -1004,6 +1005,8 @@ def send_to_external_editor(self, text, filename=None):
10041005
if subprocess.call(editor_args + [temp.name]) == 0:
10051006
with open(temp.name) as f:
10061007
return f.read()
1008+
else:
1009+
return text
10071010

10081011

10091012
def next_indentation(line, tab_length):

0 commit comments

Comments
 (0)