mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
fix crash on entering submodule #1510
also do not allow opening submodule without workdir
This commit is contained in:
parent
8f612c5cb4
commit
ba9b6d6b6a
3 changed files with 17 additions and 10 deletions
|
|
@ -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`)
|
||||
|
|
|
|||
|
|
@ -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<bool> {
|
||||
let new_selection = match scroll {
|
||||
|
|
|
|||
|
|
@ -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<DebouncedEvent>, Vec<Error>>,
|
||||
>,
|
||||
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(())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue