Skip to content

Commit 5d713fa

Browse files
editor fixes
1 parent c5edb5d commit 5d713fa

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

bpython/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def loadini(struct, configfile):
7373
'pastebin_show_url': 'http://bpaste.net/show/$paste_id/',
7474
'pastebin_helper': '',
7575
'save_append_py': False,
76-
'editor': 'vi',
76+
'editor': os.environ.get('VISUAL', os.environ.get('EDITOR', 'vi'))
7777
},
7878
'keyboard': {
7979
'clear_line': 'C-u',

bpython/curtsiesfrontend/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def send_session_to_external_editor(self, filename=None):
866866
for_editor += ('\n'.join(line[4:] if line[:4] in ('... ', '>>> ') else '### '+line
867867
for line in self.getstdout().split('\n')).encode('utf8'))
868868
text = self.send_to_external_editor(for_editor)
869-
lines = open(text).split('\n')
869+
lines = text.split('\n')
870870
self.history = [line for line in lines if line[:4] != '### ']
871871
self.reevaluate(insert_into_history=True)
872872
self._current_line = lines[-1][4:]
@@ -888,7 +888,7 @@ def clear_current_block(self):
888888
def send_current_block_to_external_editor(self, filename=None):
889889
text = self.send_to_external_editor(self.get_current_block())
890890
lines = [line for line in text.split('\n')]
891-
while not lines[-1].split():
891+
while lines and not lines[-1].split():
892892
lines.pop()
893893
events = '\n'.join(lines + ([''] if len(lines) == 1 else ['', '']))
894894
self.clear_current_block()

bpython/repl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,7 @@ def clear_current_line(self):
996996

997997
def send_to_external_editor(self, text, filename=None):
998998
"""Returns modified text from an editor, or the oriignal text if editor exited with non-zero"""
999-
editor = (self.config.editor or
1000-
os.environ.get('VISUAL', os.environ.get('EDITOR', 'vim')))
1001-
editor_args = shlex.split(editor)
999+
editor_args = shlex.split(self.config.editor)
10021000
with tempfile.NamedTemporaryFile(suffix='.py') as temp:
10031001
temp.write(text)
10041002
temp.flush()

0 commit comments

Comments
 (0)