Skip to content

Commit

Permalink
feat: :ReevaluateAllCells command (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas authored Dec 14, 2023
1 parent 1ba4023 commit 6da3d19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rplugin/python3/molten/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,17 @@ def cmd(kernel_id: str):
"""
self.nvim.exec_lua(lua, async_=False)

@pynvim.command("MoltenReevaluateAll", nargs=0, sync=True) # type: ignore
@nvimui # type: ignore
def command_reevaluate_all(self) -> None:
self._initialize_if_necessary()

molten_kernels = self._get_current_buf_kernels(True)
assert molten_kernels is not None

for kernel in molten_kernels:
kernel.reevaluate_all()

@pynvim.command("MoltenReevaluateCell", nargs=0, sync=True) # type: ignore
@nvimui # type: ignore
def command_evaluate_cell(self) -> None:
Expand Down
5 changes: 5 additions & 0 deletions rplugin/python3/molten/moltenbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def run_code(self, code: str, span: CodeCell) -> None:

self._check_if_done_running()

def reevaluate_all(self) -> None:
for span in sorted(self.outputs.keys(), key=lambda s: s.begin):
code = span.get_text(self.nvim)
self.run_code(code, span)

def reevaluate_cell(self) -> bool:
self.selected_cell = self._get_selected_span()
if self.selected_cell is None:
Expand Down

0 comments on commit 6da3d19

Please sign in to comment.