If alwaysUseActiveTerminal is False and the current active terminal isn't named ['R', 'R Interactive'] then nothing happens (not even so much as a warning).
Would it not make more sense to switch to the first terminal named ['R', 'R Interactive'] ? At the very least perhaps a message to suggest to the user to open a terminal (or I guess could implement the suggestion in #291 )
(for reference this is how Rstudio handles it if you have the terminal open and you try to run R code, it will flick to the R console)
If alwaysUseActiveTerminal is False and the current active terminal isn't named ['R', 'R Interactive'] then nothing happens (not even so much as a warning).
Hi @gowerc, in this case if I use R: Run Selection/Line a new R terminal called 'R Interactive' is created.
Is your suggestion that, if there is already a terminal called 'R' or 'R Interactive' that is not the active terminal, then it should switch to that terminal instead of creating a new terminal?
I think this could be related to #200. R: Create R terminal allows user to create multiple terminals. Each time the active terminal is set to the last created one. If the last one is closed, then active terminal is invalid and previously created terminals are no longer tracked.
In the case where multiple terminals are created as I mentioned, should we find the terminal with wanted name and set it to be the active terminal?
@renkun-ken That sounds like a good approach. I would suggest we find the most recent (highest numbered) terminal with wanted name.
Hi @gowerc, in this case if I use
R: Run Selection/Linea new R terminal called 'R Interactive' is created.
O weird I wasn't seeing this behaviour, will double check to make sure I've set mine up correctly
Is your suggestion that, if there is already a terminal called 'R' or 'R Interactive' that is not the active terminal, then it should switch to that terminal instead of creating a new terminal?
Yes that is right. For example I quite often have 3 or more terminals open (R / Bash / Python / etc) and have to manually flick between them, having the submited code automatically switch to the existing R console would be a nice usability improvement :)
In the case where multiple terminals are created as I mentioned, should we find the terminal with wanted name and set it to be the active terminal?
@renkun-ken - When you say most recent, do you mean the most recently created? or the most recently used ?
Most recently created sounds good to me. I guess we cannot know which is recently used?
@renkun-ken - You are right, I was hoping there might be some metadata available that gave a timestamp for when the terminal was last looked at but reading the API I can't anything that we could use for that.
Likewise is there a proper way to know the order the terminals were created ? At the moment I am just assuming they are correctly ordered in windows.terminal I've updated the PR to simply loop through them in reverse order to select the first one which meets the name criteria
I believe your latest implementation is good enough for most cases.
I think this can be closed now :)