Skip to content

Commit

Permalink
fix: cleanup and crate updates (#1602)
Browse files Browse the repository at this point in the history
* update incompatible packages

* fix some clippy warnings

* fix clippy warnings

* update winrt-notification version

* fix formatting

* fix warning

* fix warning
  • Loading branch information
federico-terzi committed May 8, 2023
1 parent 4caf7f6 commit 56e02b1
Show file tree
Hide file tree
Showing 21 changed files with 227 additions and 221 deletions.
344 changes: 179 additions & 165 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion espanso-config/src/config/mod.rs
Expand Up @@ -190,6 +190,7 @@ pub trait Config: Send + Sync {
// in this issue: https://github.com/federico-terzi/espanso/issues/745
fn win32_keyboard_layout_cache_interval(&self) -> i64;

#[allow(clippy::needless_lifetimes)]
fn is_match<'a>(&self, app: &AppProperties<'a>) -> bool;

fn pretty_dump(&self) -> String {
Expand Down Expand Up @@ -270,7 +271,7 @@ pub trait Config: Send + Sync {

pub trait ConfigStore: Send {
fn default(&self) -> Arc<dyn Config>;
fn active<'a>(&'a self, app: &AppProperties) -> Arc<dyn Config>;
fn active(&self, app: &AppProperties) -> Arc<dyn Config>;
fn configs(&self) -> Vec<Arc<dyn Config>>;

fn get_all_match_paths(&self) -> HashSet<String>;
Expand Down
6 changes: 3 additions & 3 deletions espanso-config/src/config/path.rs
Expand Up @@ -127,11 +127,11 @@ pub mod tests {
create_dir_all(&sub_dir).unwrap();

let base_file = match_dir.join("base.yml");
std::fs::write(&base_file, "test").unwrap();
std::fs::write(base_file, "test").unwrap();
let another_file = match_dir.join("another.yml");
std::fs::write(&another_file, "test").unwrap();
std::fs::write(another_file, "test").unwrap();
let under_file = match_dir.join("_sub.yml");
std::fs::write(&under_file, "test").unwrap();
std::fs::write(under_file, "test").unwrap();
let sub_file = sub_dir.join("sub.yml");
std::fs::write(&sub_file, "test").unwrap();

Expand Down
6 changes: 3 additions & 3 deletions espanso-config/src/config/resolve.rs
Expand Up @@ -692,7 +692,7 @@ mod tests {
let another_file = match_dir.join("another.yml");
std::fs::write(&another_file, "test").unwrap();
let under_file = match_dir.join("_sub.yml");
std::fs::write(&under_file, "test").unwrap();
std::fs::write(under_file, "test").unwrap();
let sub_file = sub_dir.join("sub.yml");
std::fs::write(&sub_file, "test").unwrap();

Expand Down Expand Up @@ -724,9 +724,9 @@ mod tests {
let base_file = match_dir.join("base.yml");
std::fs::write(&base_file, "test").unwrap();
let another_file = match_dir.join("another.yml");
std::fs::write(&another_file, "test").unwrap();
std::fs::write(another_file, "test").unwrap();
let under_file = match_dir.join("_sub.yml");
std::fs::write(&under_file, "test").unwrap();
std::fs::write(under_file, "test").unwrap();
let sub_file = sub_dir.join("another.yml");
std::fs::write(&sub_file, "test").unwrap();
let sub_under_file = sub_dir.join("_sub.yml");
Expand Down
2 changes: 1 addition & 1 deletion espanso-config/src/config/store.rs
Expand Up @@ -35,7 +35,7 @@ impl ConfigStore for DefaultConfigStore {
Arc::clone(&self.default)
}

fn active<'a>(&'a self, app: &super::AppProperties) -> Arc<dyn super::Config> {
fn active(&self, app: &super::AppProperties) -> Arc<dyn super::Config> {
// Find a custom config that matches or fallback to the default one
for custom in self.customs.iter() {
if custom.is_match(app) {
Expand Down
8 changes: 2 additions & 6 deletions espanso-config/src/legacy/config.rs
Expand Up @@ -386,17 +386,13 @@ impl LegacyConfig {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Default)]
pub enum BackendType {
Inject,
Clipboard,
#[default]
Auto,
}
impl Default for BackendType {
fn default() -> Self {
BackendType::Auto
}
}

impl LegacyConfig {
fn load_config(path: &Path) -> Result<LegacyConfig, ConfigLoadError> {
Expand Down
4 changes: 2 additions & 2 deletions espanso-config/src/legacy/mod.rs
Expand Up @@ -475,9 +475,9 @@ mod tests {
let package_dir = TempDir::new("tempconfig").unwrap();

callback(
&dunce::canonicalize(&dir.path()).unwrap(),
&dunce::canonicalize(dir.path()).unwrap(),
&dunce::canonicalize(&user_dir).unwrap(),
&dunce::canonicalize(&package_dir.path()).unwrap(),
&dunce::canonicalize(package_dir.path()).unwrap(),
);
}

Expand Down
11 changes: 3 additions & 8 deletions espanso-config/src/legacy/model.rs
Expand Up @@ -45,18 +45,13 @@ pub enum KeyModifier {
CAPS_LOCK,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub enum PasteShortcut {
Default, // Default one for the current system
#[default]
Default, // Default one for the current system
CtrlV, // Classic Ctrl+V shortcut
CtrlShiftV, // Could be used to paste without formatting in many applications
ShiftInsert, // Often used in Linux systems
CtrlAltV, // Used in some Linux terminals (urxvt)
MetaV, // Corresponding to Win+V on Windows and Linux, CMD+V on macOS
}

impl Default for PasteShortcut {
fn default() -> Self {
PasteShortcut::Default
}
}
26 changes: 13 additions & 13 deletions espanso-config/src/lib.rs
Expand Up @@ -91,7 +91,7 @@ mod tests {
use_test_directory(|base, match_dir, config_dir| {
let base_file = match_dir.join("base.yml");
std::fs::write(
&base_file,
base_file,
r#"
matches:
- trigger: "hello"
Expand All @@ -102,7 +102,7 @@ mod tests {

let another_file = match_dir.join("another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "_sub.yml"
Expand All @@ -116,7 +116,7 @@ mod tests {

let under_file = match_dir.join("_sub.yml");
std::fs::write(
&under_file,
under_file,
r#"
matches:
- trigger: "hello3"
Expand All @@ -126,11 +126,11 @@ mod tests {
.unwrap();

let config_file = config_dir.join("default.yml");
std::fs::write(&config_file, "").unwrap();
std::fs::write(config_file, "").unwrap();

let custom_config_file = config_dir.join("custom.yml");
std::fs::write(
&custom_config_file,
custom_config_file,
r#"
filter_title: "Chrome"
Expand Down Expand Up @@ -186,7 +186,7 @@ mod tests {
use_test_directory(|base, match_dir, config_dir| {
let base_file = match_dir.join("base.yml");
std::fs::write(
&base_file,
base_file,
r#"
matches:
- "invalid"invalid
Expand All @@ -196,7 +196,7 @@ mod tests {

let another_file = match_dir.join("another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "_sub.yml"
Expand All @@ -210,7 +210,7 @@ mod tests {

let under_file = match_dir.join("_sub.yml");
std::fs::write(
&under_file,
under_file,
r#"
matches:
- trigger: "hello3"
Expand All @@ -220,11 +220,11 @@ mod tests {
.unwrap();

let config_file = config_dir.join("default.yml");
std::fs::write(&config_file, r#""#).unwrap();
std::fs::write(config_file, r#""#).unwrap();

let custom_config_file = config_dir.join("custom.yml");
std::fs::write(
&custom_config_file,
custom_config_file,
r#"
filter_title: "Chrome"
"
Expand Down Expand Up @@ -261,7 +261,7 @@ mod tests {
.unwrap();

let config_file = config_dir.join("default.yml");
std::fs::write(&config_file, r#""#).unwrap();
std::fs::write(config_file, r#""#).unwrap();

let (config_store, match_store, errors) = load(base).unwrap();

Expand All @@ -284,7 +284,7 @@ mod tests {
use_test_directory(|base, match_dir, config_dir| {
let base_file = match_dir.join("base.yml");
std::fs::write(
&base_file,
base_file,
r#"
matches:
- trigger: hello
Expand All @@ -295,7 +295,7 @@ mod tests {

let config_file = config_dir.join("default.yml");
std::fs::write(
&config_file,
config_file,
r#"
invalid
Expand Down
16 changes: 8 additions & 8 deletions espanso-config/src/matches/store/default.rs
Expand Up @@ -314,7 +314,7 @@ mod tests {

let another_file = match_dir.join("_another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "sub/sub.yml"
Expand All @@ -330,7 +330,7 @@ mod tests {

let sub_file = sub_dir.join("sub.yml");
std::fs::write(
&sub_file,
sub_file,
r#"
imports:
- "../_another.yml"
Expand Down Expand Up @@ -376,7 +376,7 @@ mod tests {

let another_file = match_dir.join("_another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "sub/sub.yml"
Expand All @@ -392,7 +392,7 @@ mod tests {

let sub_file = sub_dir.join("sub.yml");
std::fs::write(
&sub_file,
sub_file,
r#"
global_vars:
- name: var2
Expand Down Expand Up @@ -470,7 +470,7 @@ mod tests {

let another_file = match_dir.join("_another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "sub/sub.yml"
Expand All @@ -486,7 +486,7 @@ mod tests {

let sub_file = sub_dir.join("sub.yml");
std::fs::write(
&sub_file,
sub_file,
r#"
imports:
- "../_another.yml" # Circular import
Expand Down Expand Up @@ -567,7 +567,7 @@ mod tests {

let another_file = match_dir.join("_another.yml");
std::fs::write(
&another_file,
another_file,
r#"
matches:
- trigger: "hello"
Expand Down Expand Up @@ -663,7 +663,7 @@ mod tests {

let another_file = match_dir.join("_another.yml");
std::fs::write(
&another_file,
another_file,
r#"
imports:
- "sub/sub.yml"
Expand Down
2 changes: 1 addition & 1 deletion espanso-config/src/util.rs
Expand Up @@ -46,7 +46,7 @@ pub mod tests {
create_dir_all(&config_dir).unwrap();

callback(
&dunce::canonicalize(&dir.path()).unwrap(),
&dunce::canonicalize(dir.path()).unwrap(),
&dunce::canonicalize(match_dir).unwrap(),
&dunce::canonicalize(config_dir).unwrap(),
);
Expand Down
2 changes: 1 addition & 1 deletion espanso-detect/src/hotkey/keys.rs
Expand Up @@ -591,7 +591,7 @@ impl ShortcutKey {
ShortcutKey::Numpad7 => Some(0xffb7),
ShortcutKey::Numpad8 => Some(0xffb8),
ShortcutKey::Numpad9 => Some(0xffb9),
ShortcutKey::Raw(code) => Some(*code as u32),
ShortcutKey::Raw(code) => Some(*code),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion espanso-migrate/src/lib.rs
Expand Up @@ -188,7 +188,7 @@ mod tests {

fn list_files_in_dir(dir: &Path) -> Vec<String> {
let prefix = dir.to_string_lossy().to_string();
fs_extra::dir::get_dir_content(&dir)
fs_extra::dir::get_dir_content(dir)
.unwrap()
.files
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion espanso-package/Cargo.toml
Expand Up @@ -21,7 +21,7 @@ scopeguard = "1.1.0"
fs_extra = "1.2.0"
sha2 = "0.9.6"
hex = "0.4.3"
reqwest = { version = "0.11.4", features = ["blocking"], default-features = false}
reqwest = { version = "0.11.16", features = ["blocking"], default-features = false}

# On Linux we don't want to depend on openssl to avoid dependency issues
# https://github.com/espanso/espanso/issues/1056
Expand Down
2 changes: 1 addition & 1 deletion espanso-package/src/archive/default.rs
Expand Up @@ -328,7 +328,7 @@ matches:
assert!(package_out_dir.is_dir());

let legacy_package = dest_dir.join("z_legacypackage1");
create_dir_all(&legacy_package).unwrap();
create_dir_all(legacy_package).unwrap();

let package_list = archiver.list().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion espanso-ui/Cargo.toml
Expand Up @@ -20,7 +20,7 @@ thiserror = "1.0.23"
[target.'cfg(windows)'.dependencies]
widestring = "0.4.3"
lazycell = "1.3.0"
winrt-notification = "0.3.1"
winrt-notification = "0.5.1"
lazy_static = "1.4.0"

[target.'cfg(target_os="macos")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion espanso/Cargo.toml
Expand Up @@ -63,7 +63,7 @@ colored = "2.0.0"
tempdir = "0.3.7"
notify = "4.0.17"
opener = "0.5.0"
sysinfo = "0.24.5"
sysinfo = "0.28.4"

[target.'cfg(windows)'.dependencies]
named_pipe = "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion espanso/src/cli/launcher/edition_check.rs
Expand Up @@ -54,6 +54,6 @@ fn get_session_type() -> Option<String> {
return None;
}

let session_type: Option<&str> = raw_session_type.split('=').into_iter().last();
let session_type: Option<&str> = raw_session_type.split('=').last();
session_type.map(String::from)
}
2 changes: 1 addition & 1 deletion espanso/src/patch/config_store.rs
Expand Up @@ -66,7 +66,7 @@ impl ConfigStore for PatchedConfigStore {
self.config_store.default()
}

fn active<'f>(&'f self, app: &espanso_config::config::AppProperties) -> Arc<dyn Config> {
fn active(&self, app: &espanso_config::config::AppProperties) -> Arc<dyn Config> {
let active_config = self.config_store.active(app);

if !active_config.apply_patch() {
Expand Down
2 changes: 1 addition & 1 deletion espanso/src/patch/patches/macros.rs
Expand Up @@ -71,7 +71,7 @@ macro_rules! generate_patchable_config {
self.base.match_paths()
}

fn is_match<'b>(&self, app: &AppProperties<'b>) -> bool {
fn is_match(&self, app: &AppProperties) -> bool {
self.base.is_match(app)
}

Expand Down
2 changes: 1 addition & 1 deletion espanso/src/path/linux.rs
Expand Up @@ -35,7 +35,7 @@ pub fn add_espanso_to_path(_: bool) -> Result<()> {

let target_link_path = target_link_dir.join("espanso");

if let Err(error) = std::os::unix::fs::symlink(&exec_path, &target_link_path) {
if let Err(error) = std::os::unix::fs::symlink(exec_path, target_link_path) {
return Err(PathError::SymlinkError(error).into());
}

Expand Down

0 comments on commit 56e02b1

Please sign in to comment.