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

Improve project detection

Open sfsaccone opened this issue 4 years ago • 4 comments

Problem

Often when I run "Terminals:Run" I get the error "No terminals defined, edit the configuration". Unfortunately, I can't consistently reproduce this. The workaround below can persist after restart.

Workaround

Open the configuration file (code .vscode/terminals.json in Linux) then run "Terminals: Run" while the file is open in the editor. Then it works. And, sometimes at least, it continues to work after I restart VS Code.

Environment

VS Code: 1.47.2 running on Windows 10 Remote OS: Ubuntu Server 20.04 Terminals Manager: 1.12.9

sfsaccone avatar Jul 20 '20 14:07 sfsaccone

I think the issue is that the current active project is inferred depending on what file is currently active, so if you open the settings for example the whole thing falls apart.

fabiospampinato avatar Aug 01 '20 16:08 fabiospampinato

Yup, that sounds right. The error seems to occur if and only if the current editor is a file outside the workspace folder. Thanks!

sfsaccone avatar Aug 01 '20 17:08 sfsaccone

This is causing me problems as well. I can't reliably use relative paths in the cwd in a workspace with multiple folders, since they are always relative to the folder of the open file.

I expected to be able to use [workspaceFolder] to work around this. But it's not pointing to the workspace folder (the folder containing the workspace file), but rather the root folder of the active file.

It probably too late to fix [workspaceFolder]. But maybe another variable could be introduced that always points to the location of the workspace file. Alternatively, being able to specify the specific folder [folder:name] would work as well.

ben-page avatar Jun 21 '22 17:06 ben-page

@fabiospampinato any improvements on this thread? Commands which uses relative path fails on multiroot workspaces. Suggestion: commands should always run relative to the terminals.json / .code-workspace.json file irrespective of where the recently opened folders / files (in case of multiroot workspace).

I was trying to find a workaround for this issue by consuming [workSpaceFolder] and accumlating the relative directory as said by @ben-page like this

{
        "name": "Git pull origin main",
        "commands": [
          "rootDir=$(echo [workspaceFolder] | sed s/cv-workspaces\\\\/cv-frontend//g)",
          "echo $rootDir",
          "git -C $rootDir/cv-workspaces pull origin main",
          "git -C $rootDir/fluid-ui pull origin main",
          "git -C $rootDir/creators-studio pull origin main"
        ],
        "onlySingle": true,
        "open": true
}

Since [workSpaceFolder] is not static, it changes relative to the current editor bench focused files/directory, the above workaround fails

UPDATE: Here is the forked implementation, where the above mentioned issue has been resolved - Terminals Manager Pro , BTW sorry for re-implementation, it seems like there is no activity in this project recently, so I forked and published my own version of terminals manager instead raising PR for this fix.

ThayalanGR avatar Jul 04 '22 11:07 ThayalanGR