nteract / hydrogen

:atom: Run code interactively, inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor.
https://nteract.gitbooks.io/hydrogen/
MIT License
3.92k stars 334 forks source link

Feature request: Run multiple selections by cursors #1194

Open kylebarron opened 6 years ago

kylebarron commented 6 years ago

If multiple selections are highlighted, run each of them sequentially. I.e. instead of:

image

It would be: image

kylebarron commented 6 years ago

If I were to submit a PR for this, would this be considered? Or is this behavior not desired?

BenRussert commented 6 years ago

Hi @kylebarron, sorry for the late response.

I just realized it looks like you have multiple cursors in your screenshot, something we don't currently handle. If this is something you would like to improve, I would be interested in a way to handle that if you sent a PR.

Otherwise, my take is that for individual cursor selections the way things work now are consistent with Jupyter platforms that separate output by cells. The intended way to get multiple outputs in hydrogen is to include cell markup in your code file.

https://nteract.gitbooks.io/hydrogen/docs/Usage/GettingStarted.html#hydrogen-run-cell

kylebarron commented 6 years ago

@BenRussert As an example, I often want to debug functions for which I have default values, and my ideal way of initially defining those values would be like this:

peek 2018-07-16 16-41

This isn't really a situation where run-cell would be useful, because only occasionally do I want to run the multiple selections, and it would seem that run-cell would run the entire function, not the localized selections.

I'm guessing that the best way to implement this would be by changing codeManager.findCodeBlock()? https://github.com/nteract/hydrogen/blob/9d595258c9619b3b106b796c7b1305e3109bcf9e/lib/code-manager.js#L301-L312