Skip to content

Commit

Permalink
fix(config): unset values on ws configs appropriately
Browse files Browse the repository at this point in the history
This commit ensures that if a user removes an optional block from the
static config file, when reloading a workspace config, the removed
option will also be unset in the window manager workspace configuration
state.
  • Loading branch information
LGUG2Z committed Jan 27, 2025
1 parent b8e8ac2 commit 59cd36a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions komorebi/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,34 +161,32 @@ impl Workspace {
self.tile = false;
}

let mut all_layout_rules = vec![];
if let Some(layout_rules) = &config.layout_rules {
let mut all_rules = vec![];
for (count, rule) in layout_rules {
all_rules.push((*count, Layout::Default(*rule)));
all_layout_rules.push((*count, Layout::Default(*rule)));
}

self.set_layout_rules(all_rules);

self.tile = true;
}

self.set_layout_rules(all_layout_rules.clone());

if let Some(layout_rules) = &config.custom_layout_rules {
let rules = self.layout_rules_mut();
for (count, pathbuf) in layout_rules {
let rule = CustomLayout::from_path(pathbuf)?;
rules.push((*count, Layout::Custom(rule)));
all_layout_rules.push((*count, Layout::Custom(rule)));
}

self.tile = true;
self.set_layout_rules(all_layout_rules);
}

self.set_apply_window_based_work_area_offset(
config.apply_window_based_work_area_offset.unwrap_or(true),
);

if config.window_container_behaviour.is_some() {
self.set_window_container_behaviour(config.window_container_behaviour);
}
self.set_window_container_behaviour(config.window_container_behaviour);

if let Some(window_container_behaviour_rules) = &config.window_container_behaviour_rules {
if window_container_behaviour_rules.is_empty() {
Expand All @@ -201,15 +199,13 @@ impl Workspace {

self.set_window_container_behaviour_rules(Some(all_rules));
}
} else {
self.set_window_container_behaviour_rules(None);
self.set_window_container_behaviour(None);

This comment has been minimized.

Copy link
@alex-ds13

alex-ds13 Jan 27, 2025

Contributor

@LGUG2Z Isn't this line overriding the one above on line 189?! If the user doesn't have window_container_behaviour_rules set this line is always forcing the window_container_behaviour to None.

This comment has been minimized.

Copy link
@LGUG2Z

LGUG2Z Jan 27, 2025

Author Owner

Yeah you're right, we need to check if the behavior is explicitly not set in the config before we do this

}

if config.float_override.is_some() {
self.set_float_override(config.float_override);
}

if config.layout_flip.is_some() {
self.set_layout_flip(config.layout_flip);
}
self.set_float_override(config.float_override);
self.set_layout_flip(config.layout_flip);

Ok(())
}
Expand Down

0 comments on commit 59cd36a

Please sign in to comment.