ryuta46 / vscode-multi-command

Visual Studio Code Plugin named multi-command
MIT License
229 stars 14 forks source link

Is it possible to store and subsequently restore a previous state? #25

Closed TryerGit closed 4 years ago

TryerGit commented 4 years ago

Currently I have the following multicommand:

"command": "multiCommand.gotoDebuggerExecutionPoint",
        "sequence": [
            "workbench.debug.action.focusCallStackView",
            "list.clear",
            "list.focusFirst",
            "list.select",
            "workbench.action.toggleSidebarVisibility"
        ]

Execution of this multicommand will always hide the sidebar, regardless of whether the sidebar was open previously or not. Is it possible to store the previous state of the sidebar (visible or hidden) and restore this state subsequently?

Thanks.

ryuta46 commented 4 years ago

@TryerGit I tried. workbench.debug.action.focusCallStackView command shows side bar if it is hidden. So workbench.action.toggleSidebarVisibility command always hides the side bar.

How do you expect the command work when the side bar is hidden ? I think you don't need to add workbench.action.toggleSidebarVisibility` command in sequence.

TryerGit commented 4 years ago

@ryuta46

Case 1: Sidebar hidden, execute above multiCommand. After executing it, sidebar will be hidden as before. Fine. Case 2: Sidebar visible, execute above multiCommand. After executing it, sidebar will be hidden unlike as before. Not Fine.

Now, if we did not have "workbench.action.toggleSidebarVisibility" in the multiCommand, we would have: Case 1: Sidebar hidden, execute modified multiCommand. After executing it, sidebar will be visible unlike as before. Not Fine. Case 2: Sidebar visible, execute modified multiCommand. After executing it, sidebar will be visible as before. Fine.

So, it seems to me that whether we have "workbench.action.toggleSidebarVisibility" or not, it would give the "Not Fine" outcome in one of the cases.

ryuta46 commented 4 years ago

@TryerGit I understood. You don't want to change the visibility of the sidebar before and after executing the multi-command, right?

If you bind a key to the multi-command, how about define two command sequences?

For example, in settings.json

        {
            "command": "multiCommand.gotoDebuggerExecutionPointAndShow",
            "sequence": [
                "workbench.debug.action.focusCallStackView", 
                "list.clear",
                "list.focusFirst",
                "list.select",
            ]
        },
        {
            "command": "multiCommand.gotoDebuggerExecutionPointAndHide",
            "sequence": [
                "workbench.debug.action.focusCallStackView", 
                "list.clear",
                "list.focusFirst",
                "list.select",
                "workbench.action.closeSidebar"
            ]
        }

and in keybindings.json, call a corresponding multi-command depended on side bar visibility.

    {
        "key": "ctrl+alt+v",
        "command": "extension.multiCommand.execute",
        "args": {
            "command": "multiCommand.gotoDebuggerExecutionPointAndShow",
        },
        "when": "sideBarVisible"

    },
    {
        "key": "ctrl+alt+v",
        "command": "extension.multiCommand.execute",
        "args": {
            "command": "multiCommand.gotoDebuggerExecutionPointAndHide",
        },
        "when": "!sideBarVisible"

    },
TryerGit commented 4 years ago

@ryuta46

Thanks! That worked perfectly.