Almenon / AREPL-vscode

Program python in real-time
MIT License
263 stars 31 forks source link

smarter restart #236

Open Almenon opened 6 years ago

Almenon commented 6 years ago

next step: check if the code is actually different before restarting.

For example, adding a space (in most scenarios) will not change the logic of the code, yet AREPL will still think that's an actual change and restart the evaluation. To avoid this I can parse the syntax of the new and old code and check if the syntax trees are the same.

Sample code:

def is_same(code1, code2):
  tree = ast.parse(code1)
  tree2 = ast.parse(code2)
  return ast.dump(tree) == ast.dump(tree2))

Avoiding restart is not a big deal with simple programs but with GUI-based on long-running programs it is important.

Almenon commented 4 years ago

One problem with this is that I like to be able to simply add a space to trigger a new run of arepl (for code that changes between runs for whatever reason). There is a hotkey to trigger a new run (control-shift-;) but I don't want to have to remember a seldom used hotkey. I suppose implementing this issue would be okay if there was a run button somewhere.

Unfortunately not sure where to put the run button and a run button means there would also need to be a "running" indicator and a stop button and I need to think about how it would work in inline mode too ..... ugg

goyalyashpal commented 1 year ago

There is a hotkey to trigger a new run (control-shift-;) but I don't want to have to remember a seldom used hotkey.

yeah, restarting arepl is a pain especially because of the need to require an edit on ctrl-shift-a