Skip to content

Commit

Permalink
fix(open/follow): respect max_windows global config
Browse files Browse the repository at this point in the history
  • Loading branch information
myypo committed Oct 6, 2024
1 parent 1940bc9 commit 2473958
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compass/src/functions/follow/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> TryFrom<CompassArgs<'a>> for FollowOptions {
.get("max_windows")
.map(|&s| s.try_into())
.transpose()?
.unwrap_or_default();
.unwrap_or_else(default_max_windows);

Ok(Self::Buf(BufOptions {
target,
Expand Down
12 changes: 8 additions & 4 deletions compass/src/functions/open/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ use serde::Deserialize;

#[derive(Deserialize, FromLua)]
pub struct OpenOptions {
#[serde(default)]
pub record_types: Option<Vec<RecordFilter>>,
#[serde(default = "default_max_windows")]
pub max_windows: WindowGridSize,
}

fn default_max_windows() -> WindowGridSize {
get_config().picker.max_windows
}

impl Default for OpenOptions {
fn default() -> Self {
let conf = &get_config().picker;

Self {
record_types: None,
max_windows: conf.max_windows,
max_windows: default_max_windows(),
}
}
}
Expand Down Expand Up @@ -69,7 +73,7 @@ impl<'a> TryFrom<CompassArgs<'a>> for OpenOptions {
.get("max_windows")
.map(|&s| s.try_into())
.transpose()?
.unwrap_or_default();
.unwrap_or_else(default_max_windows);

Ok(Self {
record_types,
Expand Down

0 comments on commit 2473958

Please sign in to comment.