From 10ba89fe9d3c9f9c749eac861c653ddf7529528a Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 23 May 2024 16:58:52 -0700 Subject: [PATCH] fix(wm): dynamically reserve monitor ring space This commit makes a small change to dynamically keep reserving space in the VecDeque that backs Ring until an index preference can be contained within the current length. This commit also fixes some clippy lints and adds some allow annotations. --- komorebi-core/src/lib.rs | 2 +- komorebi-gui/src/main.rs | 2 ++ komorebi/src/main.rs | 3 ++- komorebi/src/static_config.rs | 8 ++++++-- komorebi/src/windows_api.rs | 5 +++-- komorebic/src/main.rs | 3 ++- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index d5f94229b..a7ac70a2f 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -1,5 +1,5 @@ #![warn(clippy::all, clippy::nursery, clippy::pedantic)] -#![allow(clippy::missing_errors_doc, clippy::use_self)] +#![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)] use std::path::Path; use std::path::PathBuf; diff --git a/komorebi-gui/src/main.rs b/komorebi-gui/src/main.rs index 50b1c8ec4..cedd77565 100644 --- a/komorebi-gui/src/main.rs +++ b/komorebi-gui/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::assigning_clones)] + use eframe::egui; use eframe::egui::color_picker::Alpha; use eframe::egui::Color32; diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 0929625f2..d690a790e 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -3,7 +3,8 @@ clippy::missing_errors_doc, clippy::redundant_pub_crate, clippy::significant_drop_tightening, - clippy::significant_drop_in_scrutinee + clippy::significant_drop_in_scrutinee, + clippy::doc_markdown )] use std::path::PathBuf; diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 891eced13..f24cf7f6e 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -333,7 +333,7 @@ impl StaticConfig { let mut display = false; - for (_, aliases) in &map { + for aliases in map.values() { for a in aliases { if raw.contains(a) { display = true; @@ -493,7 +493,11 @@ impl From<&WindowManager> for StaticConfig { } impl StaticConfig { - #[allow(clippy::cognitive_complexity, clippy::too_many_lines)] + #[allow( + clippy::cognitive_complexity, + clippy::too_many_lines, + clippy::assigning_clones + )] fn apply_globals(&mut self) -> Result<()> { if let Some(monitor_index_preferences) = &self.monitor_index_preferences { let mut preferences = MONITOR_INDEX_PREFERENCES.lock(); diff --git a/komorebi/src/windows_api.rs b/komorebi/src/windows_api.rs index 38212df1d..98d780277 100644 --- a/komorebi/src/windows_api.rs +++ b/komorebi/src/windows_api.rs @@ -276,9 +276,10 @@ impl WindowsApi { if monitors.elements().is_empty() { monitors.elements_mut().push_back(m); } else if let Some(preference) = index_preference { - let current_len = monitors.elements().len(); - if *preference > current_len { + let mut current_len = monitors.elements().len(); + while *preference > current_len { monitors.elements_mut().reserve(1); + current_len = monitors.elements().len(); } monitors.elements_mut().insert(*preference, m); diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index e6793cc5a..82ef51683 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1,5 +1,5 @@ #![warn(clippy::all, clippy::nursery, clippy::pedantic)] -#![allow(clippy::missing_errors_doc)] +#![allow(clippy::missing_errors_doc, clippy::doc_markdown)] use chrono::Local; use std::fs::File; @@ -102,6 +102,7 @@ lazy_static! { }; } +#[allow(dead_code)] trait AhkLibrary { fn generate_ahk_library() -> String; }