2
2
from prompt_toolkit .application .current import get_app
3
3
from prompt_toolkit .buffer import Buffer
4
4
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
6
6
7
7
from pyvim .completion import DocumentCompleter
8
8
from pyvim .reporting import report
12
12
import os
13
13
import weakref
14
14
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
+
15
22
__all__ = (
16
23
'EditorBuffer' ,
17
24
)
@@ -180,6 +187,9 @@ def run_reporter(self):
180
187
# Better not to access the document in an executor.
181
188
document = self .buffer .document
182
189
190
+ if PTK3 :
191
+ loop = get_event_loop ()
192
+
183
193
def in_executor ():
184
194
# Call reporter
185
195
report_errors = report (self .location , document )
@@ -196,5 +206,12 @@ def ready():
196
206
# Restart reporter when the text was changed.
197
207
self .run_reporter ()
198
208
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 )
0 commit comments