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

feat(cwd-pane): Allow to open a new pane from the current working directory #277

Closed
wants to merge 8 commits into from
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository = "https://github.com/zellij-org/zellij"
ansi_term = "0.12.1"
backtrace = "0.3.55"
bincode = "1.3.1"
byteorder = "1.4.3"
directories-next = "2.0"
futures = "0.3.5"
libc = "0.2"
Expand All @@ -36,6 +37,9 @@ wasmer-wasi = "1.0.0"
interprocess = "1.0.1"
zellij-tile = { path = "zellij-tile/", version = "0.6.0" }

[target.'cfg(target_os = "macos")'.dependencies]
darwin-libproc = "0.2.0"

[dependencies.async-std]
version = "1.3.0"
features = ["unstable"]
Expand Down
34 changes: 34 additions & 0 deletions src/client/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ impl Tab {
.unwrap();
}
self.active_terminal = self.panes.iter().map(|(id, _)| id.to_owned()).next();
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
self.render();
}
pub fn new_pane(&mut self, pid: PaneId) {
Expand Down Expand Up @@ -424,6 +427,9 @@ impl Tab {
self.active_terminal = Some(pid);
self.render();
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
}
pub fn horizontal_split(&mut self, pid: PaneId) {
self.close_down_to_max_terminals();
Expand Down Expand Up @@ -1743,6 +1749,9 @@ impl Tab {
} else {
self.active_terminal = Some(*first_terminal);
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
self.render();
}
pub fn focus_next_pane(&mut self) {
Expand Down Expand Up @@ -1829,6 +1838,9 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
self.render();
}
pub fn move_focus_down(&mut self) {
Expand Down Expand Up @@ -1859,6 +1871,9 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
self.render();
}
pub fn move_focus_up(&mut self) {
Expand Down Expand Up @@ -1889,6 +1904,9 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

I think this is the reason some of the tests are failing. Be sure to only send this instruction if the active_terminal has actually changed (eg. here move this inside the else block above).

self.render();
}
pub fn move_focus_right(&mut self) {
Expand Down Expand Up @@ -1919,6 +1937,9 @@ impl Tab {
} else {
self.active_terminal = Some(active_terminal.unwrap().pid());
}
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
self.render();
}
fn horizontal_borders(&self, terminals: &[PaneId]) -> HashSet<usize> {
Expand Down Expand Up @@ -2086,6 +2107,9 @@ impl Tab {
self.panes.remove(&id);
if self.active_terminal == Some(id) {
self.active_terminal = self.next_active_pane(panes);
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
}
return;
}
Expand All @@ -2102,6 +2126,9 @@ impl Tab {
self.panes.remove(&id);
if self.active_terminal == Some(id) {
self.active_terminal = self.next_active_pane(panes);
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
}
return;
}
Expand All @@ -2118,6 +2145,9 @@ impl Tab {
self.panes.remove(&id);
if self.active_terminal == Some(id) {
self.active_terminal = self.next_active_pane(panes);
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
}
return;
}
Expand All @@ -2134,10 +2164,14 @@ impl Tab {
self.panes.remove(&id);
if self.active_terminal == Some(id) {
self.active_terminal = self.next_active_pane(panes);
self.send_pty_instructions
.send(PtyInstruction::UpdateActivePane(self.active_terminal))
.unwrap();
}
return;
}
}

// if we reached here, this is either the last pane or there's some sort of
// configuration error (eg. we're trying to close a pane surrounded by fixed panes)
self.panes.remove(&id);
Expand Down
2 changes: 2 additions & 0 deletions src/common/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ pub enum PtyContext {
SpawnTerminalVertically,
SpawnTerminalHorizontally,
NewTab,
UpdateActivePane,
ClosePane,
CloseTab,
Quit,
Expand All @@ -281,6 +282,7 @@ impl From<&PtyInstruction> for PtyContext {
PtyInstruction::ClosePane(_) => PtyContext::ClosePane,
PtyInstruction::CloseTab(_) => PtyContext::CloseTab,
PtyInstruction::NewTab => PtyContext::NewTab,
PtyInstruction::UpdateActivePane(_) => PtyContext::UpdateActivePane,
PtyInstruction::Quit => PtyContext::Quit,
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
.unwrap();
}
}
PtyInstruction::UpdateActivePane(id) => {
pty_bus.update_active_pane(id);
}
PtyInstruction::ClosePane(id) => {
pty_bus.close_pane(id);
command_is_executing.done_closing_pane();
Expand Down
Loading