Skip to content

Add setting to change the cwd of the Powershell Integrated Console #2796

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

Merged
merged 3 commits into from
Jul 8, 2020

Conversation

jwfx
Copy link
Contributor

@jwfx jwfx commented Jul 5, 2020

PR Summary

This adds a new setting that will allow users to set the current working directory for the Powershell Integrated Console

Resolves #2227

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • NA PR has tests
  • This PR is ready to merge and is not work in progress

@ghost ghost added Area-Extension Terminal Issue-Enhancement A feature request (enhancement). labels Jul 5, 2020
@ghost
Copy link

ghost commented Jul 5, 2020

CLA assistant check
All CLA requirements met.

Copy link
Contributor

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will set the process CWD, but I don't think it will set the integrated console location on start, which I believe is currently the workspace root. I may be wrong about this though.

Today, the two can be managed separately from the integrated console with Set-Location and [System.Environment]::CurrentDirectory = .... So I think the value would be in customising the startup location for both -- otherwise I imagine we will get error reports about the CWD setting not setting the integrated console's startup location. For this we would need changes in PSES though.

@jwfx
Copy link
Contributor Author

jwfx commented Jul 6, 2020

I configured the new setting like so:
image

After opening a .ps1 file in a different location the Integrated Console presented itself like this:
image

Additionally I checked the current directory of the pwsh process:
image

Does this meet the expectations and I can proceed with relocating the setting to powershell.cwd?

@TylerLeonhardt
Copy link
Member

@jwfx when you open vscode, do you have a folder opened or does it say:

image

@jwfx
Copy link
Contributor Author

jwfx commented Jul 6, 2020

@TylerLeonhardt

I have no folder open. As soon as I have an open folder, the folder path takes precedence and the Integrated Console is launched in that opened folder, no matter where the .ps1 is located I'm trying to open.

Maybe that behavior could be mentioned in the setting description?

@rjmholt
Copy link
Contributor

rjmholt commented Jul 6, 2020

Maybe that behavior could be mentioned in the setting description?

I think we would want to change the behaviour to make cwd override it

@rjmholt
Copy link
Contributor

rjmholt commented Jul 6, 2020

The integrated console's location is set here. Changing the behaviour needs to pull the setting from the configuration service and if it's not-null, use that

@jwfx
Copy link
Contributor Author

jwfx commented Jul 6, 2020

It seems like open workspace folders seem to override the location that is passed into createTerminal(). The process cwd is still applied though.

I've changed the PR so that it is at least consistent for now. The powershell.cwd setting is only applied if no folders are open.

I'd be thankful for pointers how to make the cwd setting also work for open workspace folders. I'm not sure if this even in the scope of this extension? Just guessing here.. I am new to this.

**edit

Thanks, you are faster than me ;)

@jwfx
Copy link
Contributor Author

jwfx commented Jul 7, 2020

@rjmholt

Ok, I think I got it.

I couldn't make the required changes here, because the configuration values are not available at this point.

Should I turn this into a PR on the PSES repo?
jwfx/PowerShellEditorServices@63f5c0d

@TylerLeonhardt
Copy link
Member

@jwfx you need changes in both to make this all come together. This makes sense because vscode-powershell and PSES work together.

@jwfx
Copy link
Contributor Author

jwfx commented Jul 8, 2020

Not sure if I can do anything about those failed checks..?

@rjmholt
Copy link
Contributor

rjmholt commented Jul 8, 2020

Not sure if I can do anything about those failed checks..?

They're bugs in PowerShell, being addressed there. Hopefully we can merge that soon and get the checks passing

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TylerLeonhardt TylerLeonhardt merged commit aa1c300 into PowerShell:master Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extension Terminal Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set start path
3 participants