From 61ee3fd695f0d5bd7bfa8774303c45709ea6f7ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 02:32:20 +0000 Subject: updates and fixes --- src/app.rs | 6 +++--- src/components/changes.rs | 2 -- src/components/commit.rs | 3 ++- src/components/status_tree.rs | 4 ++-- src/components/textinput.rs | 16 ++++++++-------- src/options.rs | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/app.rs b/src/app.rs index 3278d0bf..6fdfc424 100644 --- a/src/app.rs +++ b/src/app.rs @@ -125,15 +125,15 @@ pub struct Environment { /// The need to construct a "whatever" environment only arises in testing right now #[cfg(test)] -impl Default for Environment { - fn default() -> Self { +impl Environment { + pub fn test_env() -> Self { use crossbeam_channel::unbounded; Self { queue: Queue::new(), theme: Default::default(), key_config: Default::default(), repo: RefCell::new(RepoPath::Path(Default::default())), - options: Default::default(), + options: Rc::new(RefCell::new(Options::test_env())), sender_git: unbounded().0, sender_app: unbounded().0, } diff --git a/src/components/changes.rs b/src/components/changes.rs index af8d68f0..30c0ab68 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -32,8 +32,6 @@ pub struct ChangesComponent { impl ChangesComponent { /// - //TODO: fix - #[allow(clippy::too_many_arguments)] pub fn new( env: &Environment, title: &str, diff --git a/src/components/commit.rs b/src/components/commit.rs index 8a26ecd3..60365eee 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -4,6 +4,7 @@ use super::{ EventState, ExternalEditorComponent, }; use crate::{ + app::Environment, keys::{key_match, SharedKeyConfig}, options::SharedOptions, queue::{InternalEvent, NeedsUpdate, Queue}, @@ -65,7 +66,7 @@ const FIRST_LINE_LIMIT: usize = 50; impl CommitComponent { /// - pub fn new(env: &crate::app::Environment) -> Self { + pub fn new(env: &Environment) -> Self { Self { queue: env.queue.clone(), mode: Mode::Normal, diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs index 2cbd29b6..613460db 100644 --- a/src/components/status_tree.rs +++ b/src/components/status_tree.rs @@ -590,7 +590,7 @@ mod tests { // set up file tree let mut ftc = StatusTreeComponent::new( - &Default::default(), + &Environment::test_env(), "title", true, ); @@ -630,7 +630,7 @@ mod tests { // set up file tree let mut ftc = StatusTreeComponent::new( - &Default::default(), + &Environment::test_env(), "title", true, ); diff --git a/src/components/textinput.rs b/src/components/textinput.rs index b9c98a23..e60737a6 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -555,7 +555,7 @@ mod tests { #[test] fn test_smoke() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -575,7 +575,7 @@ mod tests { #[test] fn text_cursor_initial_position() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -600,7 +600,7 @@ mod tests { #[test] fn test_cursor_second_position() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -636,7 +636,7 @@ mod tests { #[test] fn test_visualize_newline() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -671,7 +671,7 @@ mod tests { #[test] fn test_invisible_newline() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -701,7 +701,7 @@ mod tests { #[test] fn test_next_word_position() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -725,7 +725,7 @@ mod tests { #[test] fn test_previous_word_position() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, @@ -752,7 +752,7 @@ mod tests { #[test] fn test_next_word_multibyte() { let mut comp = TextInputComponent::new( - &Environment::default(), + &Environment::test_env(), "", "", false, diff --git a/src/options.rs b/src/options.rs index 017f4144..87f92aeb 100644 --- a/src/options.rs +++ b/src/options.rs @@ -33,8 +33,8 @@ pub struct Options { } #[cfg(test)] -impl Default for Options { - fn default() -> Self { +impl Options { + pub fn test_env() -> Self { use asyncgit::sync::RepoPath; Self { repo: RefCell::new(RepoPath::Path(Default::default())), -- cgit v1.2.3