-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Implement ConEmu's OSC 9;9 to set the CWD #8330
Conversation
So this is basically a reborn version of #7668 . Thanks to prior work of @PankajBhojwani, this PR is even smaller than #7688 . Based on previous thread like #3158 and #8214, I'd like to implement OSC 9;9 as a "Windows-first" sequence that will assume users will set Windows path . This can be seen as a starter towards a more comprehensive implementation of OSC 7, which will handle all kinds of paths based on the profile used. As for this PR, it gives users the ability to make use the of the CWD when duplicating the current active tab. I don't really know how to handle splitting panes so I left it unchanged. I'd like to hear you guys opinions. |
@@ -1015,6 +1015,13 @@ namespace winrt::TerminalApp::implementation | |||
if (profileGuid.has_value()) | |||
{ | |||
const auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid.value(), *_bindings) }; | |||
const auto workingDirectory = terminalTab->GetActiveTerminalControl().WorkingDirectory(); | |||
const auto validWorkingDirectory = !workingDirectory.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I relaxed the validation per the comments by @zadjii-msft in #8166 (comment)
I'm not sure how we handle wt -d c:\some\invalid\path
nowadays. Could use some help here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So currently, wt -d c:\some\invalid\path
will do this:
That's not a super useful error, ERROR_DIRECTORY
- I guess that makes sense, though not totally obvious what's wrong here.
I'm okay with us leaving this for now. We do some validation of the startingDirectory
on settings load, but nothing for directories passed as commandline args, and I think that's fine.
If we did want to try and pre-validate, we could pull Profile::EvaluateStartingDirectory
into a helper, and only use the control's directory if it's valid. That's actually probably a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks pretty good. No major concerns - but I'm on the fence about validating the paths ahead of time. I want this to land, but maybe we should validate ahead of time.
I'll block for the discussion, but it's otherwise a fine PR
EDIT: I'm also blocking over the pane duplicating. We should probably do that.
@@ -1015,6 +1015,13 @@ namespace winrt::TerminalApp::implementation | |||
if (profileGuid.has_value()) | |||
{ | |||
const auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid.value(), *_bindings) }; | |||
const auto workingDirectory = terminalTab->GetActiveTerminalControl().WorkingDirectory(); | |||
const auto validWorkingDirectory = !workingDirectory.empty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So currently, wt -d c:\some\invalid\path
will do this:
That's not a super useful error, ERROR_DIRECTORY
- I guess that makes sense, though not totally obvious what's wrong here.
I'm okay with us leaving this for now. We do some validation of the startingDirectory
on settings load, but nothing for directories passed as commandline args, and I think that's fine.
If we did want to try and pre-validate, we could pull Profile::EvaluateStartingDirectory
into a helper, and only use the control's directory if it's valid. That's actually probably a good idea.
As far as pane duplicating goes, that's down in if (splitMode == SplitType::Duplicate)
{
std::optional<GUID> current_guid = focusedTab->GetFocusedProfile();
if (current_guid)
{
profileFound = true;
controlSettings = { winrt::make<TerminalSettings>(_settings, current_guid.value(), *_bindings) };
realGuid = current_guid.value();
} |
Another thing that I'm not so sure: in #7668 I make both |
I'd say let's just start with the |
I've been thinking about the path validation, then it occurs to me that the OSC 9;9 feature is currently a super opt-in kind of things. Users will need to modify their shell script in order to even get this up and running. So I guess even if they have wrongly configured the path and be frustrated by the |
Yea I'm fine with not path validating as well. Can we get this added to duplicating panes though too 😄? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a derp, this does work with pane splitting too. So let's do this
Hello @carlos-zamora! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR implement the OSC 9;9 |Sequence|Descriptoin| | :------------- | :----------: | |ESC ] 9 ; 9 ; “cwd” ST | Inform ConEmu about shell current working directory.| <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References microsoft#8214 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes microsoft#8166 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
I can't use this in todays releases anymore(both stable and preview). Something changed? |
@tavrez No nothing changed I believe. Are you positive that you are using the "duplicate tab"(ctrl + shift + d) instead of "creating new tab" (ctrl + shift + t) ? If you have a consistent repro, feel free to open a new issue. |
Yes I'm using duplicate tab(with keyboard shortcut and from command pallete), It doesn't work, it goes back to starting directory. If you are not having this problem(simply open a new terminal, change directory, press duplicate tab) probably I'm doing something wrong(but this procedure worked for me in prev version it introduced in Terminal Preview) |
@tavrez It's working for me. Sorry I guess you'll need to check the shell configuration you're using. |
This does not work for me either in latest preview, or in latest Windows Terminal, when using duplicate tab (ctrl + shift + d). Am I missing something? Is there a setting that needs to be enabled? |
@LeaveTheCapital just to make sure, do you send the sequence code (ESC ] 9 ; 9 ; “cwd” ST) before duplicating? If yes, you probably has a weird problem like me, I can't use this only on my personal PC |
I did try this, however I must have been doing something wrong - perhaps someone could help with an idiots guide, or a link to similar? Thank you |
@LeaveTheCapital You can try the gist to see if it helps. Make sure you are using "Duplicate Tab" (Ctrl+Shift+d, by default) and not "New Tab" (Ctrl + T) |
Summary of the Pull Request
This PR implement the OSC 9;9
References
#8214
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed