Skip to content

Commit b6e82d9

Browse files
Support prompt_toolkit 3.0.
1 parent 5928b53 commit b6e82d9

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

pyvim/editor_buffer.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from prompt_toolkit.application.current import get_app
33
from prompt_toolkit.buffer import Buffer
44
from prompt_toolkit.document import Document
5-
from prompt_toolkit.eventloop import call_from_executor, run_in_executor
5+
from prompt_toolkit import __version__ as ptk_version
66

77
from pyvim.completion import DocumentCompleter
88
from pyvim.reporting import report
@@ -12,6 +12,13 @@
1212
import os
1313
import weakref
1414

15+
PTK3 = ptk_version.startswith('3.')
16+
17+
if PTK3:
18+
from asyncio import get_event_loop
19+
else:
20+
from prompt_toolkit.eventloop import call_from_executor, run_in_executor
21+
1522
__all__ = (
1623
'EditorBuffer',
1724
)
@@ -180,6 +187,9 @@ def run_reporter(self):
180187
# Better not to access the document in an executor.
181188
document = self.buffer.document
182189

190+
if PTK3:
191+
loop = get_event_loop()
192+
183193
def in_executor():
184194
# Call reporter
185195
report_errors = report(self.location, document)
@@ -196,5 +206,12 @@ def ready():
196206
# Restart reporter when the text was changed.
197207
self.run_reporter()
198208

199-
call_from_executor(ready)
200-
run_in_executor(in_executor)
209+
if PTK3:
210+
loop.call_soon_threadsafe(ready)
211+
else:
212+
call_from_executor(ready)
213+
214+
if PTK3:
215+
loop.run_in_executor(None, in_executor)
216+
else:
217+
run_in_executor(in_executor)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
long_description=long_description,
1818
packages=find_packages('.'),
1919
install_requires = [
20-
'prompt_toolkit>=2.0.0,<2.1.0',
20+
'prompt_toolkit>=2.0.0,<3.1.0',
2121
'pyflakes', # For Python error reporting.
2222
'pygments', # For the syntax highlighting.
2323
'docopt', # For command line arguments.

0 commit comments

Comments
 (0)