Improving interactive coding in Theia

I have been using RStudio and Jupyter Notebooks for a long time, working primarily in the data science field. One feature in RStudio that has huge impact on development time is the ability to execute code chunks instead of simply running the entire file. In RStudio, this capability is implemented by having a menu option (with keyboard shortcut) to “Run selected line(s)” which basically copy/pastes the text over to an active R session in the terminal and executes the lines.

Adding a similar menu option seems quite straight forward but I wanted to get other’s thoughts. In Theia, for a scripting language like python someone would just start a python session in the terminal and highlight lines in a file to “Run selected line(s)”.

I was going to create a feature request on github. I see this feature primarily being used for scripting languages, not necessarily compiled languages. Which component of Theia would this be added to? What thoughts do others have about this request?

[original thread by Josh Bradley]

I remember @svenefftinge showed me VS Code extension for it once. Maybe you could just install it.

As an external Theia extension would be fine with me as well.

[Josh Bradley]

I created an issue to track this request. It turns out VS Code already has a similar functionality under the Terminal menu called “Run Selected Text”.

Adding this to the task package seems most appropriate if we want to reflect similar menu options as VS code.

[Josh Bradley]

I’m new to Typescript but I made a first åttempt at a solution here after reading through the codebase. Haven’t yet figured out how to retrieve highlighted lines and identify the terminal instance to sendText to. Any tips would be appreciated.

you can use EditorManager.currentEditor.getValue(selection)

there should be some kind of logic mapping language to executable i assume

Could you check out what VS Code does? The code is opened

[Ariel Balter]

@jgbradley1 How is this coming along? Can I help?

We do have Run Selected Test by now. was resolved.

[Ariel Balter]

Thumbs up emoji!