AREPL-vscode icon indicating copy to clipboard operation
AREPL-vscode copied to clipboard

smarter restart

Open Almenon opened this issue 7 years ago • 2 comments

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 avatar Nov 26 '17 04:11 Almenon

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

Almenon avatar Dec 22 '19 20:12 Almenon

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

goyalyashpal avatar Apr 13 '23 12:04 goyalyashpal