Merge pull request #407 from a-kenji/default-layout

Fix Startup with Default in Same Folder
This commit is contained in:
a-kenji 2021-04-29 18:09:14 +02:00 committed by GitHub
commit b5d38e95c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -205,6 +205,18 @@ impl Layout {
layout layout
} }
// It wants to use Path here, but that doesn't compile.
#[warn(clippy::ptr_arg)]
pub fn from_defaults(layout_path: &PathBuf, data_dir: &Path) -> Self {
Self::new(
&data_dir
.join("layouts/")
.join(layout_path)
.with_extension("yaml"),
&data_dir,
)
}
pub fn total_terminal_panes(&self) -> usize { pub fn total_terminal_panes(&self) -> usize {
let mut total_panes = 0; let mut total_panes = 0;
total_panes += self.parts.len(); total_panes += self.parts.len();

View File

@ -186,8 +186,8 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let default_layout = None; let default_layout = None;
let maybe_layout = opts let maybe_layout = opts
.layout .layout
.or(default_layout) .map(|p| Layout::new(&p, &data_dir))
.map(|p| Layout::new(&p, &data_dir)); .or_else(|| default_layout.map(|p| Layout::from_defaults(&p, &data_dir)));
#[cfg(not(test))] #[cfg(not(test))]
std::panic::set_hook({ std::panic::set_hook({