Skip to content

Commit 0c69cca

Browse files
committed
focus
1 parent 807dcb2 commit 0c69cca

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

chadtree/client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from logging import DEBUG as DEBUG_LVL
1818
from logging import INFO
1919
from multiprocessing import cpu_count
20-
from pathlib import Path
20+
from pathlib import Path, PurePath
2121
from platform import uname
2222
from string import Template
2323
from sys import executable, exit
@@ -136,7 +136,7 @@ async def _go(loop: AbstractEventLoop, client: RPClient) -> None:
136136
ff = _trans(f)
137137
client.register(ff)
138138

139-
stage_ref = RefCell[Optional[Stage]](None)
139+
focus_ref = RefCell[Optional[PurePath]](None)
140140
event = Event()
141141
lock = Lock()
142142

@@ -146,7 +146,7 @@ async def step(method: Method, params: Sequence[Any]) -> None:
146146
async with lock:
147147
if stage := await handler(state_ref.val, *params):
148148
state_ref.val = stage.state
149-
stage_ref.val = stage
149+
focus_ref.val = stage.focus
150150
event.set()
151151
else:
152152
assert False, (method, params)
@@ -184,22 +184,20 @@ async def c2() -> None:
184184
async def cont() -> None:
185185
nonlocal has_drawn
186186
with suppress_and_log():
187-
if stage := stage_ref.val:
188-
state = stage.state
189-
187+
if state := state_ref.val:
190188
for attempt in range(1, RENDER_RETRIES + 1):
191189
try:
192-
derived = await redraw(state, focus=stage.focus)
190+
derived = await redraw(state, focus=focus_ref.val)
193191
except NvimError as e:
194192
if attempt == RENDER_RETRIES:
195193
log.warning("%s", e)
196194
else:
197195
state_ref.val = replace(
198196
state, node_row_lookup=derived.node_row_lookup
199197
)
198+
focus_ref.val = None
200199
break
201200

202-
203201
if settings.profiling and not has_drawn:
204202
has_drawn = True
205203
await _profile(t1=t1)

0 commit comments

Comments
 (0)