Skip to content

Commit b0fdf50

Browse files
author
Stephan Dilly
authored
Switch to a tree view for changed files list (#37)
1 parent 2311098 commit b0fdf50

File tree

15 files changed

+1183
-113
lines changed

15 files changed

+1183
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2+
/release
23
.DS_Store

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description = "blazing fast terminal-ui for git"
66
edition = "2018"
77
exclude = [".github/*",".vscode/*"]
88
homepage = "https://github.com/extrawurst/gitui"
9+
repository = "https://github.com/extrawurst/gitui"
910
readme = "README.md"
1011
license = "MIT"
1112
categories = ["command-line-utilities"]
@@ -28,6 +29,7 @@ dirs = "2.0"
2829
crossbeam-channel = "0.4"
2930
scopeguard = "1.1"
3031
bitflags = "1.2"
32+
maplit = "1.0"
3133
backtrace = { version = "0.3" }
3234
scopetime = { path = "./scopetime", version = "0.1" }
3335
asyncgit = { path = "./asyncgit", version = "0.1" }

asyncgit/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.1.8"
44
authors = ["Stephan Dilly <[email protected]>"]
55
edition = "2018"
66
description = "allow using git2 in a asynchronous context"
7-
homepage = "https://gitui.org"
7+
homepage = "https://github.com/extrawurst/gitui"
8+
repository = "https://github.com/extrawurst/gitui"
89
readme = "README.md"
910
license = "MIT"
1011
categories = ["concurrency","asynchronous"]

asyncgit/src/sync/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use git2::{Status, StatusOptions, StatusShow};
55
use scopetime::scope_time;
66

77
///
8-
#[derive(Copy, Clone, Hash)]
8+
#[derive(Copy, Clone, Hash, PartialEq, Debug)]
99
pub enum StatusItemType {
1010
///
1111
New,
@@ -36,7 +36,7 @@ impl From<Status> for StatusItemType {
3636
}
3737

3838
///
39-
#[derive(Default, Clone, Hash)]
39+
#[derive(Default, Clone, Hash, PartialEq, Debug)]
4040
pub struct StatusItem {
4141
///
4242
pub path: String,

scopetime/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.1.1"
44
authors = ["Stephan Dilly <[email protected]>"]
55
edition = "2018"
66
description = "log runtime of arbitrary scope"
7-
homepage = "https://gitui.org"
7+
homepage = "https://github.com/extrawurst/gitui"
8+
repository = "https://github.com/extrawurst/gitui"
89
license = "MIT"
910
readme = "README.md"
1011
categories = ["development-tools::profiling"]

src/app.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::{
22
components::{
33
ChangesComponent, CommandBlocking, CommandInfo,
44
CommitComponent, Component, DiffComponent, DrawableComponent,
5-
HelpComponent, MsgComponent, ResetComponent,
5+
FileTreeItemKind, HelpComponent, MsgComponent,
6+
ResetComponent,
67
},
78
keys,
89
queue::{InternalEvent, NeedsUpdate, Queue},
@@ -177,7 +178,9 @@ impl App {
177178
self.switch_focus(Focus::WorkDir)
178179
}
179180
keys::FOCUS_STAGE => self.switch_focus(Focus::Stage),
180-
keys::FOCUS_RIGHT => self.switch_focus(Focus::Diff),
181+
keys::FOCUS_RIGHT if self.can_focus_diff() => {
182+
self.switch_focus(Focus::Diff)
183+
}
181184
keys::FOCUS_LEFT => {
182185
self.switch_focus(match self.diff_target {
183186
DiffTarget::Stage => Focus::Stage,
@@ -225,6 +228,14 @@ impl App {
225228
pub fn is_quit(&self) -> bool {
226229
self.do_quit
227230
}
231+
232+
fn can_focus_diff(&self) -> bool {
233+
match self.focus {
234+
Focus::WorkDir => self.index_wd.is_file_seleted(),
235+
Focus::Stage => self.index.is_file_seleted(),
236+
_ => false,
237+
}
238+
}
228239
}
229240

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

262-
if let Some(i) = idx.selection() {
263-
Some((i.path, is_stage))
264-
} else {
265-
None
273+
if let Some(item) = idx.selection() {
274+
if let FileTreeItemKind::File(i) = item.kind {
275+
return Some((i.path, is_stage));
276+
}
266277
}
278+
None
267279
}
268280

269281
fn update_commands(&mut self) {
@@ -381,7 +393,7 @@ impl App {
381393
));
382394
res.push(CommandInfo::new(
383395
commands::STATUS_FOCUS_RIGHT,
384-
true,
396+
self.can_focus_diff(),
385397
main_cmds_available && !focus_on_diff,
386398
));
387399
}

0 commit comments

Comments
 (0)