summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-02-27 15:51:06 +0100
committerAram Drevekenin <aram@poor.dev>2023-02-27 15:51:06 +0100
commit7db7fba62e148302cb4b234b8dbb1b6fad40ca47 (patch)
tree042adcacebd6973b9e2a6c7174579fd7f0183b23
parent219578c7b79e34e01981f6be98c03acb0c9ffff1 (diff)
style(fmt): rustfmtfix-cli-edit-cwd
-rw-r--r--zellij-utils/src/input/actions.rs8
-rw-r--r--zellij-utils/src/input/command.rs2
-rw-r--r--zellij-utils/src/input/layout.rs20
-rw-r--r--zellij-utils/src/kdl/kdl_layout_parser.rs4
4 files changed, 27 insertions, 7 deletions
diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs
index 99c2553f9..a47e79f47 100644
--- a/zellij-utils/src/input/actions.rs
+++ b/zellij-utils/src/input/actions.rs
@@ -152,7 +152,13 @@ pub enum Action {
/// If no direction is specified, will try to use the biggest available space.
NewPane(Option<Direction>, Option<String>), // String is an optional pane name
/// Open the file in a new pane using the default editor
- EditFile(PathBuf, Option<usize>, Option<PathBuf>, Option<Direction>, bool), // usize is an optional line number, Option<PathBuf> is an optional cwd, bool is floating true/false
+ EditFile(
+ PathBuf,
+ Option<usize>,
+ Option<PathBuf>,
+ Option<Direction>,
+ bool,
+ ), // usize is an optional line number, Option<PathBuf> is an optional cwd, bool is floating true/false
/// Open a new floating pane
NewFloatingPane(Option<RunCommandAction>, Option<String>), // String is an optional pane name
/// Open a new tiled (embedded, non-floating) pane
diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs
index cb6fdb1ef..3d2a87ab3 100644
--- a/zellij-utils/src/input/command.rs
+++ b/zellij-utils/src/input/command.rs
@@ -6,7 +6,7 @@ use std::path::PathBuf;
#[derive(Debug, Clone)]
pub enum TerminalAction {
OpenFile(PathBuf, Option<usize>, Option<PathBuf>), // path to file (should be absolute), optional line_number and an
- // optional cwd
+ // optional cwd
RunCommand(RunCommand),
}
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index 1ba9b735c..d6f5a2f7d 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -110,12 +110,24 @@ impl Run {
Some(Run::Command(base_run_command)),
Some(Run::EditFile(file_to_edit, line_number, edit_cwd)),
) => match &base_run_command.cwd {
- Some(cwd) => Some(Run::EditFile(cwd.join(&file_to_edit), *line_number, Some(cwd.join(edit_cwd.clone().unwrap_or_default())))),
- None => Some(Run::EditFile(file_to_edit.clone(), *line_number, edit_cwd.clone())),
+ Some(cwd) => Some(Run::EditFile(
+ cwd.join(&file_to_edit),
+ *line_number,
+ Some(cwd.join(edit_cwd.clone().unwrap_or_default())),
+ )),
+ None => Some(Run::EditFile(
+ file_to_edit.clone(),
+ *line_number,
+ edit_cwd.clone(),
+ )),
},
(Some(Run::Cwd(cwd)), Some(Run::EditFile(file_to_edit, line_number, edit_cwd))) => {
let cwd = edit_cwd.clone().unwrap_or(cwd.clone());
- Some(Run::EditFile(cwd.join(&file_to_edit), *line_number, Some(cwd)))
+ Some(Run::EditFile(
+ cwd.join(&file_to_edit),
+ *line_number,
+ Some(cwd),
+ ))
},
(Some(_base), Some(other)) => Some(other.clone()),
(Some(base), _) => Some(base.clone()),
@@ -140,7 +152,7 @@ impl Run {
},
None => {
let _ = edit_cwd.insert(cwd.clone());
- }
+ },
};
*path_to_file = cwd.join(&path_to_file);
},
diff --git a/zellij-utils/src/kdl/kdl_layout_parser.rs b/zellij-utils/src/kdl/kdl_layout_parser.rs
index 402dede99..cf6afaf70 100644
--- a/zellij-utils/src/kdl/kdl_layout_parser.rs
+++ b/zellij-utils/src/kdl/kdl_layout_parser.rs
@@ -374,7 +374,9 @@ impl<'a> KdlLayoutParser<'a> {
hold_on_close,
hold_on_start,
}))),
- (None, Some(edit), Some(cwd)) => Ok(Some(Run::EditFile(cwd.join(edit), None, Some(cwd)))),
+ (None, Some(edit), Some(cwd)) => {
+ Ok(Some(Run::EditFile(cwd.join(edit), None, Some(cwd))))
+ },
(None, Some(edit), None) => Ok(Some(Run::EditFile(edit, None, None))),
(Some(_command), Some(_edit), _) => Err(ConfigError::new_layout_kdl_error(
"cannot have both a command and an edit instruction for the same pane".into(),