-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Terminal locks its starting directory; perhaps it shouldn't do that? #5506
Comments
@MikePanitz-CCC If you tried doing the same thing in the legacy console (opening in a specific directory, navigating the shell away from that directory, then removing that directory), does the same thing happen? I'd think that this would be the same behavior for all applications, where you can't remove the directory when a running process has that directory as it's current working directory, but I'm not 100% sure on that |
Locking the dir that a shell is currently using be is reasonable. Keeping the wt starting dir locked as long as wt is running is awkward
Xonsh in particular allows you to keep the dir unlocked.
Get Outlook for Android<https://aka.ms/ghei36>
|
I don't disagree, but I do somewhat wonder how this'll interact with future uses of profiles with Then, at least those new tabs would error out ("can't find directory") instead of pointing at the wrong directory ... |
That sounds completely reasonable to me. |
FWIW: powershell does lock the directory (I created a new dir is PS, bash (from Git Bash - MinGW64) does not lock the current directory. At least, I was able to start a new bash process in the background ( What was really weird is that the child bash kept it's current working directory as being the folder I'd just deleted. When I asked it to do an 'ls' it reasonably said |
I'm throwing this one on the backlog as a "Help Wanted" bug; We need to figure out the right thing to do here and how that plays with the user's profile settings and what an appropriate fallback looks like. |
I may try to look at this myself. Obviously anyone else who's interested feel free to jump in. Especially since I'm pretty busy until, like, August :) Thanks for looking at this @DHowett-MSFT! |
You know what, there's actually another issue on the repo that's effectively the same thing: #10849. Both threads have great discussion. |
In the dirtiest way possible, this seems to work for most "start with this CWD" scenarios.
@DHowett I know you're out this week, but I know you're still uncontrollably checking github 😝 I'm pulling this into 1.18, because "Use parent process directory" pretty much instantly stops working as expected once all windows are in one process.
This feels extra dangerous to be yolo'ing in this late in the cycle, so thoughts might be helpful |
Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed `startingDirectory: .` to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the _first_ terminal opened. This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in `system32`. This also will prevent the Terminal from locking the directory it was originally opened in. * Closes #5506 * There wasn't a 1.18 issue for "Use parent process directory is broken" yet, presumably selfhosters aren't using that feature * Related to #14957 Many more notes on this topic in #4637 (comment) > **Warning** > ## Breaking change‼️ This will break a profile like ```json { "commandline": "media-test.exe", "name": "Use CWD for media-test", "startingDirectory": "." }, ``` if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for `commandline`s were already dangerous and should have been avoided.
Before process model v3, each Terminal window was running in its own process, each with its own CWD. This allowed `startingDirectory: .` to work relative to the terminal's own CWD. However, now all windows share the same process, so there can only be one CWD. That's not great - folks who right-click "open in terminal", then "Use parent process directory" are only ever going to be able to use the CWD of the _first_ terminal opened. This PR remedies this issue, with a theory we had for another issue. Essentially, we'll give each Terminal window a "virtual" CWD. The Terminal isn't actually in that CWD, the terminal is in `system32`. This also will prevent the Terminal from locking the directory it was originally opened in. * Closes #5506 * There wasn't a 1.18 issue for "Use parent process directory is broken" yet, presumably selfhosters aren't using that feature * Related to #14957 Many more notes on this topic in #4637 (comment) > **Warning** > ## Breaking change‼️ This will break a profile like ```json { "commandline": "media-test.exe", "name": "Use CWD for media-test", "startingDirectory": "." }, ``` if the user right-clicks "open in terminal", then attempts to open that profile. There's some theoretical work we could do in a follow up to fix this, but I'm inclined to say that relative paths for `commandline`s were already dangerous and should have been avoided. (cherry picked from commit 5c08a86) Service-Card-Id: 89180224 Service-Version: 1.18
Adds an action to display a toast containing the Terminal's "virtual" CWD. As described in #4637 (comment). Useful for debugging #5506 et. al. I almost left it as a debug-only feature, but figured it would be helpful for others in the #4637 landscape of things.
Description of the new feature/enhancement
The directory that Windows Terminal starts up in can't be deleted (in Windows Explorer / Directory Opus / etc). It would be nice if I could delete the folder without exiting wt first.
Use case:
When you configure a profile to include this:
"startingDirectory" : ".",
and then set up the right-click "Start Windows Terminal Here" functionality in Windows Explorer to start a wt instance in any folder you get to create Terminal instances quickly and conveniently.
But, if you get done with that folder and want to delete it then you need to close wt first.
It would be convenient to delete the folder without closing wt first.
What's weird is that this behavior (keeping the starting dir locked so you can't delete it) continues to happen even if you navigate away from that dir in the command line.
(Which makes sense - wt creates new tabs in that same dir so preventing it from disappearing is understandable)
Proposed technical implementation details (optional)
maintainer edit:
Also using to track the thing where
wt
needs to tell the existing window about the current CWD, for running actions in an existing window (which may have a different CWD), see #13430The text was updated successfully, but these errors were encountered: