mirror of
https://github.com/gitui-org/gitui
synced 2026-05-22 16:38:28 +00:00
allow opening file selected in tree (#989)
This commit is contained in:
parent
36699a0a36
commit
ecabee02da
2 changed files with 23 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ The way this works got changed and simplified ([See docs](https://github.com/ext
|
|||
- simplify key overrides ([see docs](https://github.com/extrawurst/gitui/blob/master/KEY_CONFIG.md)) ([#946](https://github.com/extrawurst/gitui/issues/946))
|
||||
- dedicated fuzzy finder up/down keys to allow vim overrides ([#993](https://github.com/extrawurst/gitui/pull/993))
|
||||
- pull will also download tags ([#1013](https://github.com/extrawurst/gitui/pull/1013))
|
||||
- allow editing file from filetree ([#989](https://github.com/extrawurst/gitui/pull/989))
|
||||
|
||||
### Fixed
|
||||
- honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933))
|
||||
|
|
|
|||
|
|
@ -155,13 +155,15 @@ impl RevisionFilesComponent {
|
|||
}
|
||||
}
|
||||
|
||||
fn selection_changed(&mut self) {
|
||||
//TODO: retrieve TreeFile from tree datastructure
|
||||
if let Some(file) = self
|
||||
.tree
|
||||
fn selected_file(&self) -> Option<String> {
|
||||
self.tree
|
||||
.selected_file()
|
||||
.map(|file| file.full_path_str().to_string())
|
||||
{
|
||||
}
|
||||
|
||||
fn selection_changed(&mut self) {
|
||||
//TODO: retrieve TreeFile from tree datastructure
|
||||
if let Some(file) = self.selected_file() {
|
||||
log::info!("selected: {:?}", file);
|
||||
let path = Path::new(&file);
|
||||
if let Some(item) =
|
||||
|
|
@ -271,6 +273,11 @@ impl Component for RevisionFilesComponent {
|
|||
)
|
||||
.order(order::NAV),
|
||||
);
|
||||
out.push(CommandInfo::new(
|
||||
strings::commands::edit_item(&self.key_config),
|
||||
self.tree.selected_file().is_some(),
|
||||
true,
|
||||
));
|
||||
tree_nav_cmds(&self.tree, &self.key_config, out);
|
||||
} else {
|
||||
self.current_file.commands(out, force_all);
|
||||
|
|
@ -314,6 +321,16 @@ impl Component for RevisionFilesComponent {
|
|||
self.open_finder();
|
||||
return Ok(EventState::Consumed);
|
||||
}
|
||||
} else if key == self.key_config.keys.edit_file {
|
||||
if let Some(file) = self.selected_file() {
|
||||
//Note: switch to status tab so its clear we are
|
||||
// not altering a file inside a revision here
|
||||
self.queue.push(InternalEvent::TabSwitch);
|
||||
self.queue.push(
|
||||
InternalEvent::OpenExternalEditor(Some(file)),
|
||||
);
|
||||
return Ok(EventState::Consumed);
|
||||
}
|
||||
} else if !is_tree_focused {
|
||||
return self.current_file.event(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue