Search code examples
pythonpowershellvisual-studio-code

In VSCode with python extension why does a powershell of terminal prompt not show the folder I open?


I found the same problem which is with a path containg brackets.

When the path contains square brackets, spawning a new terminal using powershell and "terminal.integrated.cwd" does not function properly

$PSVersionTable

version:

Name                           Value
----                           -----
PSVersion                      5.1.19041.5486
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.5486
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I open two folders with VSCode.

One folder hello to the right with a powershell of terminal panel by default showing current working directory where hello is.

The other folder to the left with a powershell terminal panel by default showing a folder under

C:\WINDOWS\System32\WindowsPowerShell

instead of the folder I open.

enter image description here

I tried to use cd command to change the cwd shown in the powershell terminal of panel and restarted my VSCode.

But it does not work.

Here is the settings.json which only contains

{

"workbench.iconTheme": "vscode-icons",

"workbench.colorTheme": "Solarized Light",

"python.terminal.executeInFileDir": true

}

but the powershell of terminal panel to the left VSCode still shows a folder under

C:\WINDOWS\System32\WindowsPowerShell.

enter image description here

I also tried to check

prython > terminal: execute in file dir

in the setting of VSCode.

It does not work.

How do I set each folder I open in VSCode and then poweshell of terminal panel shows corresponding folder I actually open instead of the same folder under

C:\WINDOWS\System32\WindowsPowerShell?

It seem only the folder to the left occurs this situation.


Solution

  • The problem is caused by your folder name with [ and ]. enter image description here