Skip to content

Commit

Permalink
style: run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Oct 23, 2024
1 parent 91cf735 commit 89d91b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
14 changes: 7 additions & 7 deletions packages/wm/src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,9 @@ pub struct WindowMatchConfig {
pub enum MatchType {
Equals { equals: String },
Includes { includes: String },
Regex { regex: String},
Regex { regex: String },
NotEquals { not_equals: String },
NotRegex {not_regex: String}
NotRegex { not_regex: String },
}

impl MatchType {
Expand All @@ -607,13 +607,13 @@ impl MatchType {
match self {
MatchType::Equals { equals } => value == equals,
MatchType::Includes { includes } => value.contains(includes),
MatchType::Regex { regex} => regex::Regex::new(regex)
.map(|re| re.is_match(value))
.unwrap_or(false),
MatchType::Regex { regex } => regex::Regex::new(regex)
.map(|re| re.is_match(value))
.unwrap_or(false),
MatchType::NotEquals { not_equals } => value != not_equals,
MatchType::NotRegex { not_regex } => regex::Regex::new(not_regex)
.map(|re| !re.is_match(value))
.unwrap_or(false),
.map(|re| !re.is_match(value))
.unwrap_or(false),
}
}
}
Expand Down
60 changes: 34 additions & 26 deletions packages/wm/src/wm_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ impl WmState {
.context("Failed to get index of given workspace.")?;

let prev_active_workspace = active_workspaces.get(
origin_index.checked_sub(1).unwrap_or(active_workspaces.len() - 1),
origin_index
.checked_sub(1)
.unwrap_or(active_workspaces.len() - 1),
);

(
Expand All @@ -335,42 +337,48 @@ impl WmState {
)
}
WorkspaceTarget::Next => {
let workspaces = &config.value.workspaces;
let workspaces = &config.value.workspaces;
let origin_name = origin_workspace.config().name.clone();
let origin_index = workspaces.iter()
.position(|workspace| workspace.name == origin_name)
.context("Failed to get index of given workspace.")?;

let origin_index = workspaces
.iter()
.position(|workspace| workspace.name == origin_name)
.context("Failed to get index of given workspace.")?;

let next_workspace_config = workspaces
.get(origin_index + 1)
.or_else(|| workspaces.first());

let next_workspace_name = next_workspace_config.map(|config| config.name.clone());
.get(origin_index + 1)
.or_else(|| workspaces.first());

let next_workspace_name =
next_workspace_config.map(|config| config.name.clone());

let next_workspace = next_workspace_name
.as_ref()
.and_then(|name| self.workspace_by_name(name));
.as_ref()
.and_then(|name| self.workspace_by_name(name));

(next_workspace_name, next_workspace)
}
WorkspaceTarget::Previous => {
let workspaces = &config.value.workspaces;
let workspaces = &config.value.workspaces;
let origin_name = origin_workspace.config().name.clone();
let origin_index = workspaces.iter()
.position(|workspace| workspace.name == origin_name)
.context("Failed to get index of given workspace.")?;

let origin_index = workspaces
.iter()
.position(|workspace| workspace.name == origin_name)
.context("Failed to get index of given workspace.")?;

let previous_workspace_config = workspaces.get(
origin_index.checked_sub(1).unwrap_or(workspaces.len() - 1),
);

let previous_workspace_name = previous_workspace_config.map(|config| config.name.clone());
origin_index.checked_sub(1).unwrap_or(workspaces.len() - 1),
);

let previous_workspace_name =
previous_workspace_config.map(|config| config.name.clone());

let previous_workspace = previous_workspace_name
.as_ref()
.and_then(|name| self.workspace_by_name(name));
.as_ref()
.and_then(|name| self.workspace_by_name(name));

(previous_workspace_name, previous_workspace)
}

WorkspaceTarget::Direction(direction) => {
let origin_monitor =
origin_workspace.monitor().context("No focused monitor.")?;
Expand Down

0 comments on commit 89d91b0

Please sign in to comment.