Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/release
.DS_Store
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description = "blazing fast terminal-ui for git"
edition = "2018"
exclude = [".github/*",".vscode/*"]
homepage = "https://github.com/extrawurst/gitui"
repository = "https://github.com/extrawurst/gitui"
readme = "README.md"
license = "MIT"
categories = ["command-line-utilities"]
Expand All @@ -28,6 +29,7 @@ dirs = "2.0"
crossbeam-channel = "0.4"
scopeguard = "1.1"
bitflags = "1.2"
maplit = "1.0"
backtrace = { version = "0.3" }
scopetime = { path = "./scopetime", version = "0.1" }
asyncgit = { path = "./asyncgit", version = "0.1" }
Expand Down
3 changes: 2 additions & 1 deletion asyncgit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.1.8"
authors = ["Stephan Dilly <dilly.stephan@gmail.com>"]
edition = "2018"
description = "allow using git2 in a asynchronous context"
homepage = "https://gitui.org"
homepage = "https://github.com/extrawurst/gitui"
repository = "https://github.com/extrawurst/gitui"
readme = "README.md"
license = "MIT"
categories = ["concurrency","asynchronous"]
Expand Down
4 changes: 2 additions & 2 deletions asyncgit/src/sync/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use git2::{Status, StatusOptions, StatusShow};
use scopetime::scope_time;

///
#[derive(Copy, Clone, Hash)]
#[derive(Copy, Clone, Hash, PartialEq, Debug)]
pub enum StatusItemType {
///
New,
Expand Down Expand Up @@ -36,7 +36,7 @@ impl From<Status> for StatusItemType {
}

///
#[derive(Default, Clone, Hash)]
#[derive(Default, Clone, Hash, PartialEq, Debug)]
pub struct StatusItem {
///
pub path: String,
Expand Down
3 changes: 2 additions & 1 deletion scopetime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.1.1"
authors = ["Stephan Dilly <dilly.stephan@gmail.com>"]
edition = "2018"
description = "log runtime of arbitrary scope"
homepage = "https://gitui.org"
homepage = "https://github.com/extrawurst/gitui"
repository = "https://github.com/extrawurst/gitui"
license = "MIT"
readme = "README.md"
categories = ["development-tools::profiling"]
Expand Down
26 changes: 19 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use crate::{
components::{
ChangesComponent, CommandBlocking, CommandInfo,
CommitComponent, Component, DiffComponent, DrawableComponent,
HelpComponent, MsgComponent, ResetComponent,
FileTreeItemKind, HelpComponent, MsgComponent,
ResetComponent,
},
keys,
queue::{InternalEvent, NeedsUpdate, Queue},
Expand Down Expand Up @@ -177,7 +178,9 @@ impl App {
self.switch_focus(Focus::WorkDir)
}
keys::FOCUS_STAGE => self.switch_focus(Focus::Stage),
keys::FOCUS_RIGHT => self.switch_focus(Focus::Diff),
keys::FOCUS_RIGHT if self.can_focus_diff() => {
self.switch_focus(Focus::Diff)
}
keys::FOCUS_LEFT => {
self.switch_focus(match self.diff_target {
DiffTarget::Stage => Focus::Stage,
Expand Down Expand Up @@ -225,6 +228,14 @@ impl App {
pub fn is_quit(&self) -> bool {
self.do_quit
}

fn can_focus_diff(&self) -> bool {
match self.focus {
Focus::WorkDir => self.index_wd.is_file_seleted(),
Focus::Stage => self.index.is_file_seleted(),
_ => false,
}
}
}

// private impls
Expand Down Expand Up @@ -259,11 +270,12 @@ impl App {
DiffTarget::WorkingDir => (&self.index_wd, false),
};

if let Some(i) = idx.selection() {
Some((i.path, is_stage))
} else {
None
if let Some(item) = idx.selection() {
if let FileTreeItemKind::File(i) = item.kind {
return Some((i.path, is_stage));
}
}
None
}

fn update_commands(&mut self) {
Expand Down Expand Up @@ -381,7 +393,7 @@ impl App {
));
res.push(CommandInfo::new(
commands::STATUS_FOCUS_RIGHT,
true,
self.can_focus_diff(),
main_cmds_available && !focus_on_diff,
));
}
Expand Down
Loading