zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.2k stars 2.98k forks source link

Multiple commands in one key stroke seems to happen in wrong order #15932

Open troncoso opened 2 months ago

troncoso commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I want a keystroke that runs a task, focuses on the terminal, then zooms in on the terminal. However, there is a flash where the main editor is zoomed for a second, then returns to normal before open the new terminal, but not zoomed in. This is my key binding:

[
    {
        "context": "Workspace",
        "bindings": {
            "ctrl-z": "workspace::ToggleZoom",
            "ctrl-cmd-shift-g": ["task::Spawn", { "task_name": "Lazygit" }],
            "ctrl-cmd-g": [
                "workspace::SendKeystrokes",
            "ctrl-cmd-shift-g ctrl-z"
            ]
        }
    }
]

This is my task:

[
    {
        "label": "Lazygit",
        "command": "lazygit",
        "use_new_terminal": true,
        "allow_concurrent_runs": false,
        "reveal": "always"
    }
]

Environment

Zed: v0.147.2 (Zed) OS: macOS 14.5.0 Memory: 64 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Here is a video demonstrating the problem:

https://github.com/user-attachments/assets/7cfec8f2-cb97-4279-8f49-50da375fcfa0

If applicable, attach your Zed.log file to this issue.

Zed.log


notpeter commented 2 months ago

I don't think it's happening in the "wrong order" per se, it's that spawning your task is an async action so SendKeystrokes can't "wait" until it's completed before performing the next action. The

I think this behavior is documented as a limitation of workspace::SendKeystrokes with async things. From the zed keybinding docs

Screenshot 2024-08-09 at 14 34 43