Skip to content

Missing option for disabling terminal restoration #39137

Closed

Description

Whenever I open a project, chances are that a terminal will automatically open because the previous time I opened that project, its window had 1 or more terminals. This doesn't work for me:

  1. This "feature" is unpredictable. I may open a project 1 week or month later, who remembers if that window had a terminal?
  2. It's useless. If I want a terminal I'm a shortcut away from it. If I don't need it however, I have to focus to it and close it.
  3. I use my Terminals extension for managing terminals, I absolutely never need an empty terminal automatically open at startup.

What about a terminal.restoreTerminal: boolean option for disabling this?

Activity

  1. added
    terminal
    on Nov 25, 2017
  2. Tyriar commented on Dec 11, 2017

    @Tyriar
    Contributor

    The reason the terminal is automatically created is because the panel gets restored, which triggers the terminal being created.

    Isidor Nikolic (@isidorn) ever considered the ability to never restore a panel? This request has come before from the Powershell team.

  3. added
    info-needed
    on Dec 11, 2017
  4. isidorn commented on Dec 12, 2017

    @isidorn

    Daniel Imms (@Tyriar) no. We always restore all our ux as it was in a previous session.
    I do not see why the panel is a sepcial case when compared to the sidebar, activity bar, editor state and so on.

  5. fabiospampinato commented on Dec 12, 2017

    @fabiospampinato
    ContributorAuthor

    We always restore all our ux as it was in a previous session.

    I don't think so.

    You don't restore: the activity bar (global, non session-specific), status bar (global, non session specific), active activity bar section (it's always "explorer"), the "replace" input field always starts hidden (#30250) and probably other things as well.

    I do not see why the panel is a sepcial case when compared to the sidebar, activity bar, editor state and so on.

    The editor state and sidebar are useful, so it may be the activity bar for some people, but what use does it have a "debug" panel automatically open at startup? Or an empty terminal that automatically opens because when 2 months ago I closed that window it had a terminal visible?

  6. Tyriar commented on Dec 12, 2017

    @Tyriar
    Contributor

    Isidor Nikolic (@isidorn) the special case is to avoid creating terminal sessions when the terminal panel is restored as some extensions want to prevent the initial terminal being created.

    Allowing an empty terminal is another way to workaround the same issue, it's a pretty big change in thinking though.

  7. vscodebot commented on Dec 19, 2017

    @vscodebot

    This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

    Happy Coding!

  8. fabiospampinato commented on Dec 19, 2017

    @fabiospampinato
    ContributorAuthor

    Daniel Imms (@Tyriar) could you reopen this please? What kind of "more info" is needed?

  9. added
    under-discussion
    and removed
    info-needed
    on Dec 27, 2017
  10. fabiospampinato commented on Mar 14, 2018

    @fabiospampinato
    ContributorAuthor

    I've tried to fix this in an extension, it didn't work. This is what I've tried:

    • Running vscode.commands.executeCommand ( 'workbench.action.terminal.kill' ); inside the activate function.
      • There's no way of knowing if there's actually a terminal open (Allow extensions to access all terminals via API #13267).
      • Maybe there's another extension that opens a terminal at startup, we shouldn't just kill it.
      • There's a noticeable delay between the restored terminal opening and then closing. Maybe I could uninstall all my other extensions, or maybe I could rename my extension to "000", or something, ensuring that it's activate function will be called as soon as possible, but this is not really a solution.
    • Killing all terminals upon shutdown, so that none will be restored the next time that window gets opened
      • It would actually produce the desired effect only after the second opening of that window, unless that's a completely new window.
      • I couldn't find a way to hook into the "shutdown" event, there's the deactivate function, but I believe that gets triggered after the actual window is closed, so there's no terminal to kill anymore. Even if there was a way of doing this there's no way of knowing how many terminals are open, if any (Allow extensions to access all terminals via API #13267).
    • Injecting custom JS with this ensuring that the workbench.action.terminal.kill gets executed as soon as possible
      • I couldn't find a way to do it, is VSC actually exporting something to the global namespace that I can use to execute commands?

    This is a bit annoying to me, and I couldn't find a way of fixing it without patching VSC itself.

    Is there any update on this? Maybe an option for this could be added as part of #44302?

  11. fabiospampinato commented on Aug 19, 2018

    @fabiospampinato
    ContributorAuthor

    If anybody else finds those restored terminals annoying, this is what I'm currently doing for killing them:

    1. Use Custom CSS and JS Loader, needed for injecting some code into VSC.
    2. Use Fix VSCode Checksum to remove the [Unsupported] thing from the titlebar.
    3. Add the following to your settings:
      "vscode_custom_css.imports": [
        "file:///path/to/my/vsc_custom.js"
      ]
    1. Add the following code to your /path/to/my/vsc_custom.js file:
    /* CLOSE RESTORED PANEL */
    
    (function () {
    
      function hasEvent ( event ) {
    
        return _performanceEntries.includes ( event );
    
      }
    
      function close () {
    
        const kill = document.querySelector ( '.terminal-action.kill' );
    
        if ( kill ) kill.click ();
    
        const hide = document.querySelector ( '.panel .hide-panel-action' );
    
        if ( hide ) hide.click ();
    
        return !!kill || !!hide;
    
      }
    
      function loop () {
    
        if ( hasEvent ( 'extensionHostReady' ) || close () ) return;
    
        requestAnimationFrame ( loop );
    
      }
    
      loop ();
    
    })();
  12. 41 remaining items

  13. added
    terminal-persistence
    and removed
    under-discussion
    on Jul 29, 2023
  14. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Jul 29, 2023
  15. added
    verification-needed
    on Aug 28, 2023
  16. locked and limited conversation to collaborators on Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestinsiders-releasedterminal-persistenceterminal-processverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions