diff --git a/CHANGELOG.md b/CHANGELOG.md index d180b503..ed8f5b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `edit` command duplication ([#1489](https://github.com/extrawurst/gitui/issues/1489)) * syntax errors in `key_bindings.ron` will be logged ([#1491](https://github.com/extrawurst/gitui/issues/1491)) * commit hooks report "command not found" on Windows with wsl2 installed ([#1528](https://github.com/extrawurst/gitui/issues/1528)) +* crashes on entering submodules ([#1510](https://github.com/extrawurst/gitui/issues/1510)) ### Changed * minimum supported rust version bumped to 1.64 (thank you `clap`) diff --git a/src/components/submodules.rs b/src/components/submodules.rs index b14fc6ca..949f01c0 100644 --- a/src/components/submodules.rs +++ b/src/components/submodules.rs @@ -88,7 +88,7 @@ impl DrawableComponent for SubmodulesListComponent { let chunks = Layout::default() .direction(Direction::Horizontal) .constraints( - [Constraint::Min(40), Constraint::Length(40)] + [Constraint::Min(40), Constraint::Length(60)] .as_ref(), ) .split(chunks_vertical[0]); @@ -127,7 +127,7 @@ impl Component for SubmodulesListComponent { out.push(CommandInfo::new( strings::commands::open_submodule(&self.key_config), - self.is_valid_selection(), + self.can_open_submodule(), true, )); @@ -182,9 +182,11 @@ impl Component for SubmodulesListComponent { .map(Into::into); } else if key_match(e, self.key_config.keys.enter) { if let Some(submodule) = self.selected_entry() { - self.queue.push(InternalEvent::OpenRepo { - path: submodule.path.clone(), - }); + if submodule.status.is_in_wd() { + self.queue.push(InternalEvent::OpenRepo { + path: submodule.path.clone(), + }); + } } } else if key_match( e, @@ -297,6 +299,12 @@ impl SubmodulesListComponent { self.selected_entry().is_some() } + fn can_open_submodule(&self) -> bool { + self.selected_entry() + .map(|s| s.status.is_in_wd()) + .unwrap_or_default() + } + //TODO: dedup this almost identical with BranchListComponent fn move_selection(&mut self, scroll: ScrollType) -> Result { let new_selection = match scroll { diff --git a/src/watcher.rs b/src/watcher.rs index 01f99278..ee0c3aa0 100644 --- a/src/watcher.rs +++ b/src/watcher.rs @@ -8,9 +8,7 @@ use notify_debouncer_mini::{ new_debouncer, new_debouncer_opt, DebouncedEvent, }; use scopetime::scope_time; -use std::{ - path::Path, sync::mpsc::RecvError, thread, time::Duration, -}; +use std::{path::Path, thread, time::Duration}; pub struct RepoWatcher { receiver: crossbeam_channel::Receiver<()>, @@ -54,7 +52,7 @@ impl RepoWatcher { Result, Vec>, >, sender: &Sender<()>, - ) -> Result<(), RecvError> { + ) -> Result<()> { loop { let ev = receiver.recv()?; @@ -66,7 +64,7 @@ impl RepoWatcher { } if !ev.is_empty() { - sender.send(()).expect("send error"); + sender.send(())?; } } }