Skip to content

Commit

Permalink
Merge pull request #45 from ms-jpq/dev
Browse files Browse the repository at this point in the history
refactor for rendering mode
  • Loading branch information
ms-jpq committed Aug 10, 2020
2 parents 0db1cf9 + fb7428b commit c4c3fb2
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 88 deletions.
20 changes: 10 additions & 10 deletions rplugin/python3/chadtree/__init__.py
Expand Up @@ -53,7 +53,7 @@
c_trash,
redraw,
)
from .types import ClickType, State
from .types import ClickType, Stage, State


@plugin
Expand Down Expand Up @@ -101,18 +101,18 @@ async def _curr_state(self) -> State:
return self.state

def _run(
self, fn: Callable[..., Awaitable[Optional[State]]], *args: Any, **kwargs: Any
self, fn: Callable[..., Awaitable[Optional[Stage]]], *args: Any, **kwargs: Any
) -> None:
async def run() -> None:
async with self.lock:
await self._init
state = await self._curr_state()
new_state = await fn(
stage = await fn(
self.nvim, state=state, settings=self.settings, *args, **kwargs
)
if new_state:
self.state = new_state
await redraw(self.nvim, state=new_state)
if stage:
self.state = stage.state
await redraw(self.nvim, state=self.state, focus=stage.focus)

self._submit(run())

Expand Down Expand Up @@ -140,17 +140,17 @@ async def _initialize(self) -> None:

async def _ooda_loop(self) -> None:
update = self.settings.update
async for elapsed in schedule(
async for _ in schedule(
self.ch, min_time=update.min_time, max_time=update.max_time,
):
async with self.lock:
state = await self._curr_state()
try:
new_state = await c_refresh(
stage = await c_refresh(
self.nvim, state=state, settings=self.settings
)
self.state = new_state
await redraw(self.nvim, state=new_state)
self.state = stage.state
await redraw(self.nvim, state=self.state, focus=None)
except NvimError:
self.ch.set()

Expand Down

0 comments on commit c4c3fb2

Please sign in to comment.