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.55k stars 3.03k forks source link

Be able to split terminal panel #4351

Open Tom-Boscher opened 11 months ago

Tom-Boscher commented 11 months ago

Check for existing issues

Describe the feature

It would be great if (like in VSCode) we could divide terminal panel in several pane. Currently we have to use tabs but we can’t display tabs in several splitted pane in terminal panel.

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

No response

JosephTLyons commented 11 months ago

For sure @Tom-Boscher, this is an inconsistency between how the center workspace and terminal panel work, and we should fix it.

jackTabsCode commented 7 months ago

What kind of work would need to be done to move this forward @JosephTLyons? What do the terminal and workspace share in common?

Tom-Boscher commented 7 months ago

I'm interested to help too!

rcssdy commented 7 months ago

Interested to see this!

rgbkrk commented 7 months ago

The place to go after this is in clone_on_split of the impl Item for TerminalView of crates/terminal_view/src/terminal_view.rs. Based on the current comment it appears that there's more work to be done to make it keep the current working directory:

    fn clone_on_split(
        &self,
        _workspace_id: WorkspaceId,
        _cx: &mut ViewContext<Self>,
    ) -> Option<View<Self>> {
        //From what I can tell, there's no  way to tell the current working
        //Directory of the terminal from outside the shell. There might be
        //solutions to this, but they are non-trivial and require more IPC

        // Some(TerminalContainer::new(
        //     Err(anyhow::anyhow!("failed to instantiate terminal")),
        //     workspace_id,
        //     cx,
        // ))

        // TODO
        None
    }

Example implementation you can look at is https://github.com/zed-industries/zed/pull/9425.

As @mikayla-maki pointed out below, the Model<Terminal> has a get_cwd() method. This will probably get you started:

    fn clone_on_split(
        &self,
        workspace_id: WorkspaceId,
        cx: &mut ViewContext<Self>,
    ) -> Option<View<Self>> {
        Some(cx.new_view(|cx| {
            TerminalView::new(
                self.terminal.clone(),
                self.workspace.clone(),
                workspace_id,
                cx,
            )
        }))
    }
mikayla-maki commented 7 months ago

FYI for anyone looking to implement this, that comment is out of date. the Model<Terminal> has a get_cwd() method on it that can be used for this purpose.

trev-gulls commented 2 months ago

I still can't figure out how to split the terminal pane so I can see two terminals at once. Is this feature on the project roadmap? Do we know when this feature may be available?

iambudi commented 2 months ago

I still can't figure out how to split the terminal pane so I can see two terminals at once. Is this feature on the project roadmap? Do we know when this feature may be available?

Can you drag the second terminal tab and position it side by side with the first terminal?

iambudi commented 2 months ago

How can I prevent Zed from opening code files in the terminal tab when it’s docked vertically? I often forget to switch focus, and new files end up in the terminal pane.

AlbertMarashi commented 4 weeks ago

Related UX proposal to improve pane management: