Edit file from file tree (#1430)

* allow edit file from any StatusTreeComponent
This commit is contained in:
extrawurst 2022-11-14 15:01:34 +01:00 committed by GitHub
parent b6ed33037e
commit 6b9a91f17d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View file

@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* display current repository path in the top-right corner [[@alexmaco](https://github.com/alexmaco)]([#1387](https://github.com/extrawurst/gitui/pull/1387))
* add Linux targets for ARM, ARMv7 and AARCH64 [[@adur1990](https://github.com/adur1990)] ([#1419](https://github.com/extrawurst/gitui/pull/1419))
* display commit description in file view [[@alexmaco](https://github.com/alexmaco)] ([#1380](https://github.com/extrawurst/gitui/pull/1380))
* allow launching editor from Compare Commits view ([#1409](https://github.com/extrawurst/gitui/pull/1409))
### Fixes
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))

View file

@ -138,6 +138,12 @@ impl Component for InspectCommitComponent {
true,
true,
));
out.push(CommandInfo::new(
strings::commands::edit_item(&self.key_config),
true,
true,
));
}
visibility_blocking(self)

View file

@ -419,6 +419,14 @@ impl Component for StatusTreeComponent {
)
.order(order::RARE_ACTION),
);
out.push(
CommandInfo::new(
strings::commands::edit_item(&self.key_config),
self.selection_file().is_some(),
self.focused || force_all,
)
.order(order::RARE_ACTION),
);
CommandBlocking::PassingOn
}
@ -459,6 +467,18 @@ impl Component for StatusTreeComponent {
}
}
Ok(EventState::Consumed)
} else if key_match(e, self.key_config.keys.edit_file)
{
if let Some(status_item) = self.selection_file() {
if let Some(queue) = &self.queue {
queue.push(
InternalEvent::OpenExternalEditor(
Some(status_item.path),
),
);
}
}
Ok(EventState::Consumed)
} else if key_match(e, self.key_config.keys.move_down)
{
Ok(self