benlubas / molten-nvim

A neovim plugin for interactively running code with the jupyter kernel. Fork of magma-nvim with improvements in image rendering, performance, and more
GNU General Public License v3.0
596 stars 32 forks source link

[Bug] Running a cell again before it finishes #71

Closed benlubas closed 11 months ago

benlubas commented 11 months ago

Description

Specifically by overwriting the cell with a new one in the same place.

This causes:

Reproduction Steps

Run a cell like:

import time
for _ in range(100):
  print("-", end="")
  time.sleep(0.1)

and while it's still running, run it again by running the same code, so that it creates an overlapping cell (and therefore deleting the old one). Then run a new cell with different output, and see the same output from before.

Expected Behavior

Not that

benlubas commented 11 months ago

I think the best way to prevent this would be to error (notify the user) when trying to create a cell that overlaps a currently running cell.

The alternative is interrupting the cell which might be painful for people that accidentally press their run binds, or don't realize that a cell has been running.

Additionally, some kernels can't be interrupted (ie. rust's evcxr. though this might be the only one), so any solution that involves interrupting kernels won't work in all cases.