From bf12d0949d8a184fd42233730118c2dabdae27e7 Mon Sep 17 00:00:00 2001 From: Jonathan Slenders Date: Sat, 27 Jan 2018 15:40:26 +0100 Subject: [PATCH] Fixed history browser. --- ptpython/history_browser.py | 2 +- ptpython/python_input.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ptpython/history_browser.py b/ptpython/history_browser.py index 5149359a..1b35015e 100644 --- a/ptpython/history_browser.py +++ b/ptpython/history_browser.py @@ -506,7 +506,7 @@ def _(event): @handle('enter', filter=main_buffer_focussed) def _(event): " Accept input. " - event.app.set_return_value(history.default_buffer.document) + event.app.set_return_value(history.default_buffer.text) enable_system_bindings = Condition(lambda: python_input.enable_system_bindings) diff --git a/ptpython/python_input.py b/ptpython/python_input.py index 80ae4e96..1adc2e61 100644 --- a/ptpython/python_input.py +++ b/ptpython/python_input.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals from prompt_toolkit.application import Application, get_app +from prompt_toolkit.application.run_in_terminal import run_coroutine_in_terminal from prompt_toolkit.auto_suggest import AutoSuggestFromHistory, ConditionalAutoSuggest, ThreadedAutoSuggest from prompt_toolkit.buffer import Buffer from prompt_toolkit.completion import ThreadedCompleter @@ -644,12 +645,13 @@ def enter_history(self): def done(f): result = f.result() + assert isinstance(result, str), 'got %r' % (result, ) if result is not None: - self.default_buffer.document = result + self.default_buffer.text = result app.vi_state.input_mode = InputMode.INSERT history = History(self, self.default_buffer.document) - future = app.run_in_terminal_async(history.app.run_async) + future = run_coroutine_in_terminal(history.app.run_async) future.add_done_callback(done)