Skip to content

Commit

Permalink
fix: close window if dirty is set
Browse files Browse the repository at this point in the history
In case 'dirty' was set, we could end up with 'reuse_window = false', but
not closing the existing window.

This moves the closing check to after 'if reuse_window', which allows to
simplify the logic.

Fixes regression from b6b7bc8
  • Loading branch information
bkueng committed Feb 10, 2025
1 parent b68f3d8 commit 9aec9e9
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions crates/eww/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,23 +431,20 @@ impl<B: DisplayBackend> App<B> {
self.failed_windows.remove(instance_id);
log::info!("Opening window {} as '{}'", window_args.window_name, instance_id);

// if an instance of this is already running and arguments haven't change, only update duration
let reuse_window = if !dirty && self.open_windows.contains_key(instance_id) {
if self.instance_id_to_args.get(instance_id).is_some_and(|args| window_args.can_reuse_window_with_args(args)) {
true
} else {
self.close_window(instance_id, false)?;
false
}
} else {
false
};
self.instance_id_to_args.insert(instance_id.to_string(), window_args.clone());
// if an instance of this is already running and arguments haven't changed, only update duration
let reuse_window = !dirty
&& self.open_windows.contains_key(instance_id)
&& self.instance_id_to_args.get(instance_id).is_some_and(|args| window_args.can_reuse_window_with_args(args));

let open_result: Result<_> = (|| {
if reuse_window {
return Ok(());
}
if self.open_windows.contains_key(instance_id) {
self.close_window(instance_id, false)?;
}

self.instance_id_to_args.insert(instance_id.to_string(), window_args.clone());

let window_name: &str = &window_args.window_name;

Expand Down

0 comments on commit 9aec9e9

Please sign in to comment.