17
17
from logging import DEBUG as DEBUG_LVL
18
18
from logging import INFO
19
19
from multiprocessing import cpu_count
20
- from pathlib import Path
20
+ from pathlib import Path , PurePath
21
21
from platform import uname
22
22
from string import Template
23
23
from sys import executable , exit
@@ -136,7 +136,7 @@ async def _go(loop: AbstractEventLoop, client: RPClient) -> None:
136
136
ff = _trans (f )
137
137
client .register (ff )
138
138
139
- stage_ref = RefCell [Optional [Stage ]](None )
139
+ focus_ref = RefCell [Optional [PurePath ]](None )
140
140
event = Event ()
141
141
lock = Lock ()
142
142
@@ -146,7 +146,7 @@ async def step(method: Method, params: Sequence[Any]) -> None:
146
146
async with lock :
147
147
if stage := await handler (state_ref .val , * params ):
148
148
state_ref .val = stage .state
149
- stage_ref .val = stage
149
+ focus_ref .val = stage . focus
150
150
event .set ()
151
151
else :
152
152
assert False , (method , params )
@@ -184,22 +184,20 @@ async def c2() -> None:
184
184
async def cont () -> None :
185
185
nonlocal has_drawn
186
186
with suppress_and_log ():
187
- if stage := stage_ref .val :
188
- state = stage .state
189
-
187
+ if state := state_ref .val :
190
188
for attempt in range (1 , RENDER_RETRIES + 1 ):
191
189
try :
192
- derived = await redraw (state , focus = stage . focus )
190
+ derived = await redraw (state , focus = focus_ref . val )
193
191
except NvimError as e :
194
192
if attempt == RENDER_RETRIES :
195
193
log .warning ("%s" , e )
196
194
else :
197
195
state_ref .val = replace (
198
196
state , node_row_lookup = derived .node_row_lookup
199
197
)
198
+ focus_ref .val = None
200
199
break
201
200
202
-
203
201
if settings .profiling and not has_drawn :
204
202
has_drawn = True
205
203
await _profile (t1 = t1 )
0 commit comments