-
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
Feature Request - Restore closed tab #960
Comments
So tracking the most recently closed tab wouldn't be that hard. We could keep a stack of profiles as we close them, and just pop from that stack when we want to reopen one. That's not too hard. What is hard is restoring state. Even restoring the path of the executable that was running might be incredibly tricky - can we get the cwd of an arbitrary executable? What if the executable was ssh, which in some directory in a remote machine? We certainly wouldn't be able to restore that connection. What if the path no longer exists? If we CreateProcess a process in a directory that doesn't exist, what happens? Do we just default to the profile's default? What if your cmd.exe profile was running powershell, and powershell had changed to some other directory? We can't restore the process tree, and because this is Windows, there isn't the concept of a "foreground" process attached to a conpty, so we'd have to default to using the state from the executable at the root of the process tree. Just some thoughts off the top of my head. I'm sure @malxau actually has a lot more on this if I remember my email inbox correctly. I want to make sure that this issue specifically tracks "restoring the last closed tab's profile" and not "restore it's state" because the former is easy and the latter is hard. We should probably have more discussion of the latter in a new issue, #961. Actually now that I've typed #961 up, I had an idea. This might have to be something that the user opts in to, but we could theoretically just keep the TermControls from the N most recently closed
|
I don't think restoring state is a good idea, especially from a security perspective. If I'm a bad actor and try to run terminal that restores state, it's like opening a box of surprises, which might make my work easier. |
In light of the changes for #766 the version of this which is just re-opening the profile should be relatively easy
|
The implementation I had considered was simply hanging on to the last N TermControls when they get closed, to allow someone to fully restore that many panes. That way, if someone accidentally closed a long running command, then the whole command would come back with it. Now, that of course had the downside that closing a pane wouldn't necessarily terminate the process in it. So your way is probably good even in addition to the active command restore |
<!-- 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 Add an action to restore the last closed pane or tab. When all you have is restoring last sessions everything looks like a `std::vector<ActionAndArgs>`. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #9800 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Partially closes #960 * [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 * [x] 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 - Keep a buffer of panes/tabs that were closed recently in the form of a list of actions to remake it. - To restore the pane or tab just run the list of actions. - This (deliberately) does not restore the exact visual state as focus could have changed / new panes might have been created in the mean time. Mostly this means that restoring a pane will just attach to the currently focused pane instead of whatever its old neighbor was. - Buffer is limited to 100 entries which might as well be "infinite" by most reasonable standards, but prevents complaints about there being memory leaks in long running instances. - The action name could be potentially changed, but it felt unwieldy as "restoreLastClosedPaneOrTab". - This does not handle restoring the actual running contents of a pane. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
When we market this feature, we should be very clear on what it does. If I recall correctly: This does not restore the application running in the closed tab. The restore action restores a facsimilie of the closed session, but the application that was running in it doesn't keep running. |
🎉This issue was addressed in #11471, which has now been successfully released as Handy links: |
Aun existe un loop al iniciar el terminal. ocurre despues de guardar los cambios del terminal y poner el perfil que inicie como administrador y al abrirlo de nuevo. queda abriendo y cerrando el proceso pero nunca lo muestra. |
The problem with this is the tab position is not restored, if tab closed is first one, the restored tab is the last one. |
Hello,
I'd suggest a restore tag feature like in internet browser. For example, you close a tab and press [CTRL] + [SHIFT] + [T] and that will restore the latest tab closed.
May be without the context in the first step but with the latest path.
P.S. : Thank you for your awesome project,, I'm very excited to use the final preview version with the new font.
The text was updated successfully, but these errors were encountered: