vscode-R
vscode-R copied to clipboard
Prompt which "working directory" when in multiple projects workspace
Is your feature request related to a problem? Please describe. VSCode allows to create workspaces that are not single project/folder. For example, you want the workspace to have "project_a" and "project_b" opened together for some reason.
{
"folders": [
{
"path": "project_a"
},
{
"path": "project_b"
}
]
}
When opening a new terminal, there is a prompt to set the working directory of the terminal:

vscode-R does not ask and use the first (in alphabetical order) as working directory.

Describe the solution you'd like The feature would ask the user to set the working directory as it is currently done for new terminals.
Which of the following behavior do you think makes more sense in a multi-root workspace:
- Always ask user which workspace folder should be used
- Use the workspace folder that contains the current active document in editor. If the document is undefined, untitled or outside any workspace folder, then ask user which workspace folder should be used.
~~I would go for the explicit behaviour ("Always ask user which workspace folder should be used" only in a multiple project workspace) which is the one used by VSCode.~~
With the second behaviour, even if it is handy for the user, without anything that prompt the working directory (edit: it is highlighted or kind of), the user could be mislead due to wrong document focus, etc.
For short, the second option makes sense only if the user is told were the R terminal was started (getwd() call in a message/warning ?)
Chiming in here because I have been using VSCode-R with multi-project workspaces solidly for the last few months.
The current behaviour which is to open a terminal in the workspace of the active editor is really appreciated 👍
I'm not a fan of the way regular terminals force you to choose the working directory, when the active editor is an obvious default and the cost of the default being wrong is a simple cd command.
With respect to identifying terminals I find the {prompt} package quite useful, you can set yourself a nice looking R prompt that contains the working directory and other useful context.
{prompt} link: https://github.com/gaborcsardi/prompt
One have to know the working directory is set based on the editor focus. And still what is the working directory when there is nothing in the editor or it's "untitled"? (this is the actual point here).
I'm not a fan of the way regular terminals force you to choose the working directory, when the active editor is an obvious default and the cost of the default being wrong is a simple cd command.
I can understand that, although "obvious" seems highly opiniated. One way, could be to add a setting to vscode-R to either "ask" (as default, in my humble opinion to avoid issues from less experienced users) or "guess" (as it currently does when there is an active editor document, otherwise "ask").
With respect to identifying terminals I find the {prompt} package quite useful, you can set yourself a nice looking R prompt that contains the working directory and other useful context.
I do not think that expecting all users to be aware of {prompt} an external extension (to vscode-R), which requires to be configured properly to highlight the working directory is the right way to go.
To note: I am using it since the early development on GitHub, mostly to highlight git branch.
In addition, after checking the behaviour on Debian, the same setup shows in which "project" the "R interactive" terminal was started.
That is not the case on Windows 10 (at least).

I think having a selection dialogue when there is no active editior from which to derive a working directory is a reasonable fallback. I just wouldn't want to see that become the behaviour at all times.
The current behaviour is consistent with Emacs Speaks Statistics for what that's worth.
On the last point I believe there is a VSCode setting that controls the way terminals are named, so you may be able to get that Debian behaviour on windows also.
I agree about having it all times would be really annoying, as #965 currently is by continuously and repeatedly prompting to install languageserver (see #1037).
About terminal naming, it is named from the working directory for powershell, only R terminal does not have it on Windows. I'll double check the settings (which are mostly synced across OSs).
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
In VScode , the CWD for the integrated terminal is configurable, so you can have all terminals to open your project directory, or change it to open the directory of the focused file by setting the CWD to ${fileDirname}. I think this is an adequate solution for the comments above, sadly the integrated R terminal does not seem to follow the VScode configured CWD.