Skip to content

Set current directory to workspace path when EditorSession is created #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daviwil opened this issue May 19, 2016 · 9 comments
Closed
Labels
Issue-Enhancement A feature request (enhancement).
Milestone

Comments

@daviwil
Copy link
Contributor

daviwil commented May 19, 2016

Currently when a workspace is opened in VS Code the working directory of the PowerShell session is c:\Program Files (x86)\Microsoft VS Code. We should set the current directory to the workspace path so that executed commands will be relative to the expected path.

@daviwil daviwil added the Issue-Enhancement A feature request (enhancement). label May 19, 2016
@daviwil daviwil added this to the 0.7.0 milestone May 19, 2016
@lucdekens
Copy link

That would be a good default.

But could we also have a settings.json entry if we want to point to another folder ?
For example, when I'm writing scripts to produce reports, I prefer the resulting reports in a dedicated folder, not between my script folders.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2016

Great idea! What should the setting be called for that? Ideas:

  • initialSessionPath/Directory
  • initialWorkingPath/Directory

@lucdekens
Copy link

InitialWorkingDirectory sounds good, but I can live with either of these.

@rkeithhill
Copy link
Contributor

@daviwil Could this be an extension setting like powershell.developer.editorServicesInitialWorkingDirectory that defaults to workspaceRoot? Or should we just slam it and not make it configurable? Not really sure if it would be useful to set to something else.

This could also be something somebody could change via their VSCode_profile. You'd need to decide whether to set this before or after profile processing - considering that the profile could change the working dir.

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2016

@rkeithhill good point on doing it before profile processing, hadn't thought about that. I think having a setting is kindof nice because it makes it clear that this is a configurable option. However, it's kindof moot if the user can just do this in their profile or workspace startup script.

What do you think, should we just simplify and allow configuring of starting path via profile? We'd still set it to workspaceRoot by default before profiles get loaded.

@rkeithhill
Copy link
Contributor

rkeithhill commented May 19, 2016

Probably better to start "simplified". You could always add a setting later if folks really need it. Certainly the default working directory is pretty useless.

One other thing to think about, is if we ever get a edit time REPL console in VSCode. Would we set that to start in workspaceRoot or $home? Does that have to be the same as the editor host's working dir or can it be set differently?

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2016

That's basically the scenario I filed this for. When I hit F8 in the editor currently, the working directory by default is the VS Code bin path in Program Files. I'd prefer if the path is initialized to be the workspace path so that relative paths in dot source references, etc will resolve correctly when I'm hitting F8 in a script in the workspace.

@rkeithhill
Copy link
Contributor

rkeithhill commented May 19, 2016

relative paths in dot source references, etc will resolve correctly when I'm hitting F8 in a script

I think that depends on the directory structure though. That would certainly work for the module folder structure we've been showing in the VSCode-Powershell Examples folder and what Plaster generates with the NewModuleTemplate example. But some folks have been saying they'd put their module source a level down in a subfolder e.g. . In that scenario, the relative paths in script are mean to be relative to ${workspaceRoot}\<ModuleName>.

Now maybe I misinterpreted this request but even if I did, there's probably going to be folks that don't have their script running from workspaceRoot. Perhaps their script gets put under src or something? I guess for those folks, they can always set the current dir in the workspace init script or VSCode profile script. Sorry, just thinking out loud here. :-)

@daviwil
Copy link
Contributor Author

daviwil commented May 19, 2016

Yep, I'm just thinking about the common case where someone opens a folder and wants to start working on files in that folder. I'd definitely say anyone who wants the working path to be something else should use a profile or workspace init script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

3 participants