summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorextrawurst <776816+extrawurst@users.noreply.github.com>2024-02-12 11:53:22 +0100
committerGitHub <noreply@github.com>2024-02-12 11:53:22 +0100
commit673edd8f2d516c7b298e65f53bf5d9fbdff79718 (patch)
treed6c9ab05a75a3793b6fe1482057929935b65f306 /src
parentd5f88df88a92d1cfea273e8e3375cfd2e8291ff9 (diff)
cargo updates (#1856)
closes #1781
Diffstat (limited to 'src')
-rw-r--r--src/keys/key_config.rs12
-rw-r--r--src/keys/key_list.rs25
-rw-r--r--src/watcher.rs14
3 files changed, 29 insertions, 22 deletions
diff --git a/src/keys/key_config.rs b/src/keys/key_config.rs
index e48db11b..5feb5606 100644
--- a/src/keys/key_config.rs
+++ b/src/keys/key_config.rs
@@ -163,11 +163,11 @@ mod tests {
NamedTempFile::new_in(&app_home).unwrap();
writeln!(
temporary_key_list,
- r"
+ r#"
(
- move_down: Some(( code: Char('j'), modifiers: ( bits: 2,),)),
+ move_down: Some(( code: Char('j'), modifiers: "CONTROL")),
)
-"
+"#
)
.unwrap();
@@ -175,11 +175,11 @@ mod tests {
NamedTempFile::new_in(&app_home).unwrap();
writeln!(
temporary_key_symbols,
- "
+ r#"
(
- esc: Some(\"Esc\"),
+ esc: Some("Esc"),
)
-"
+"#
)
.unwrap();
diff --git a/src/keys/key_list.rs b/src/keys/key_list.rs
index 55307193..cc6fc99a 100644
--- a/src/keys/key_list.rs
+++ b/src/keys/key_list.rs
@@ -34,8 +34,8 @@ impl From<&GituiKeyEvent> for KeyEvent {
}
}
-#[derive(Clone, Patch)]
-#[patch_derive(Deserialize)]
+#[derive(Debug, Clone, Patch)]
+#[patch_derive(Deserialize, Debug)]
pub struct KeysList {
pub tab_status: GituiKeyEvent,
pub tab_log: GituiKeyEvent,
@@ -217,8 +217,11 @@ impl KeysList {
pub fn init(file: PathBuf) -> Self {
let mut keys_list = Self::default();
if let Ok(f) = File::open(file) {
- if let Ok(patch) = ron::de::from_reader(f) {
- keys_list.apply(patch);
+ match ron::de::from_reader(f) {
+ Ok(patch) => keys_list.apply(patch),
+ Err(e) => {
+ log::error!("KeysList parse error: {e}");
+ }
}
}
keys_list
@@ -248,11 +251,12 @@ mod tests {
writeln!(
file,
- r"
+ r#"
(
- move_down: Some(( code: Char('j'), modifiers: ( bits: 2,),)),
+ move_down: Some(( code: Char('j'), modifiers: "CONTROL")),
+ move_up: Some((code: Char('h'), modifiers: ""))
)
-"
+"#
)
.unwrap();
@@ -266,5 +270,12 @@ mod tests {
KeyModifiers::CONTROL
)
);
+ assert_eq!(
+ keys.move_up,
+ GituiKeyEvent::new(
+ KeyCode::Char('h'),
+ KeyModifiers::NONE
+ )
+ );
}
}
diff --git a/src/watcher.rs b/src/watcher.rs
index 42fe8dcf..9c557b92 100644
--- a/src/watcher.rs
+++ b/src/watcher.rs
@@ -1,7 +1,7 @@
use anyhow::Result;
use crossbeam_channel::{unbounded, Sender};
-use notify::{Error, RecommendedWatcher, RecursiveMode, Watcher};
-use notify_debouncer_mini::{new_debouncer, DebouncedEvent};
+use notify::{RecommendedWatcher, RecursiveMode, Watcher};
+use notify_debouncer_mini::{new_debouncer, DebounceEventResult};
use scopetime::scope_time;
use std::{path::Path, thread, time::Duration};
@@ -43,9 +43,7 @@ impl RepoWatcher {
}
fn forwarder(
- receiver: &std::sync::mpsc::Receiver<
- Result<Vec<DebouncedEvent>, Vec<Error>>,
- >,
+ receiver: &std::sync::mpsc::Receiver<DebounceEventResult>,
sender: &Sender<()>,
) -> Result<()> {
loop {
@@ -68,15 +66,13 @@ impl RepoWatcher {
fn create_watcher(
timeout: Duration,
- tx: std::sync::mpsc::Sender<
- Result<Vec<DebouncedEvent>, Vec<Error>>,
- >,
+ tx: std::sync::mpsc::Sender<DebounceEventResult>,
workdir: &str,
) {
scope_time!("create_watcher");
let mut bouncer =
- new_debouncer(timeout, None, tx).expect("Watch create error");
+ new_debouncer(timeout, tx).expect("Watch create error");
bouncer
.watcher()
.watch(Path::new(&workdir), RecursiveMode::Recursive)