Skip to content
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

fix: pass cwd to new tab #2378

Closed
wants to merge 0 commits into from
Closed

Conversation

onichandame
Copy link
Contributor

@onichandame onichandame commented Apr 20, 2023

Problem

When creating new tab using Ctrl-T N key binding, the panes in the new tab should inherit the cwd of the current pane. However not all panes respect that.

My layout
layout {
    pane size=1 borderless=true{
        plugin location="zellij:tab-bar"
    }
    pane split_direction="vertical"{
        pane size="70%"{
            pane size="80%" name="editor" focus=true command="bash"
            pane size="20%" name="console"
        }
        pane size="30%" name="side"{
            pane{
                plugin location="zellij:strider"
            }
            pane command="htop"
        }
    }
    pane size=2 borderless=true{
        plugin location="zellij:status-bar"
    }
}
reproduction steps

image

Ctrl-T N

image

Here you can see that the panes in the new tab are in different cwds. the focused pane is in the old cwd while the non-focused pane is in the new(correct) cwd.

My experiment tells that the issue is not about focus, instead it is the command="bash" option that prevents the tab from knowing the right cwd.

Solution

I am new to zellij and haven't looked into every corner, so I still do not fully understand the issue. For example, I have no clue why the pane without command is in the right cwd. Please point out the missing parts if any.

Here I pass the cwd option to the NewTab command and the problem is fixed.

@onichandame onichandame temporarily deployed to cachix April 23, 2023 17:30 — with GitHub Actions Inactive
@onichandame onichandame temporarily deployed to cachix May 8, 2023 05:24 — with GitHub Actions Inactive
@jaeheonji jaeheonji self-requested a review May 8, 2023 05:25
@onichandame onichandame temporarily deployed to cachix May 8, 2023 13:41 — with GitHub Actions Inactive
@onichandame onichandame temporarily deployed to cachix May 9, 2023 15:40 — with GitHub Actions Inactive
Copy link
Member

@jaeheonji jaeheonji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @onichandame
Sorry for late review.

First, I understood and tested that this change is trying to change the cwd of the pane with the command.

When I tested this in my environment, the cwd still doesn't change in the pane with the command.
I think simply passing cwd to NewTab doesn't seem to solve this problem.

Following the actual NewTab creation process, the actual pane creation logic is handled in apply_tiled_panes_layout of src/tab/layout_applier.rs.

Pane with RunCommand here seems to not change cwd even when Tab is regenerated.

I think you need to look more into this to solve this problem.

@onichandame
Copy link
Contributor Author

Thanks for you time @jaeheonji . I'll look deeper to find a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants