Open rasimuddinvs opened 3 years ago
To fix this, make the following changes:
New import at the top:
from prompt_toolkit.application import run_in_terminal
Changes to the function that F9 binds to:
@editor.add_key_binding(Keys.F9)
def save_and_execute_python_file(event):
"""
F9: Execute the current Python file.
"""
# Save buffer first.
editor_buffer = editor.current_editor_buffer
if editor_buffer is not None:
if editor_buffer.location is None:
editor.show_message("File doesn't have a filename. Please save first.")
return
else:
editor_buffer.write()
# Now run the Python interpreter. But use
# `CommandLineInterface.run_in_terminal` to go to the background and
# not destroy the window layout.
def execute():
call(['python3', editor_buffer.location])
six.moves.input('Press enter to continue...')
run_in_terminal(execute)
File "/Users/xxxx/Library/Python/2.7/lib/python/site-packages/prompt_toolkit/key_binding/key_processor.py", line 275, in process_keys self._process_coroutine.send(key_press) File "/Users/xxxx/Library/Python/2.7/lib/python/site-packages/prompt_toolkit/key_binding/key_processor.py", line 182, in _process self._call_handler(matches[-1], key_sequence=buffer[:]) File "/Users/xxxx/Library/Python/2.7/lib/python/site-packages/prompt_toolkit/key_binding/key_processor.py", line 325, in _call_handler handler.call(event) File "/Users/xxxx/Library/Python/2.7/lib/python/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 79, in call return self.handler(event) File "/Users/xxxx/.pyvimrc", line 67, in save_and_execute_python_file if editor_buffer.filename is None: