mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-27 10:15:07 +03:00
trigger update only after sending commit
This commit is contained in:
parent
cb247b9e7f
commit
87254045c3
@ -137,8 +137,10 @@ impl App {
|
||||
///
|
||||
pub fn event(&mut self, ev: Event) {
|
||||
trace!("event: {:?}", ev);
|
||||
if self.commit.event(ev) {
|
||||
self.update_diff();
|
||||
if self.commit.is_visible() && self.commit.event(ev) {
|
||||
if !self.commit.is_visible() {
|
||||
self.update();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,6 +185,9 @@ impl App {
|
||||
self.index_reset();
|
||||
self.update();
|
||||
}
|
||||
keys::OPEN_COMMIT if !self.index.is_empty() => {
|
||||
self.commit.show();
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
|
@ -60,35 +60,26 @@ impl Component for CommitComponent {
|
||||
}
|
||||
|
||||
fn event(&mut self, ev: Event) -> bool {
|
||||
if self.visible {
|
||||
if let Event::Key(e) = ev {
|
||||
return match e.code {
|
||||
KeyCode::Esc => {
|
||||
self.hide();
|
||||
true
|
||||
}
|
||||
KeyCode::Char(c) => {
|
||||
self.msg.push(c);
|
||||
true
|
||||
}
|
||||
KeyCode::Enter if self.can_commit() => {
|
||||
self.commit();
|
||||
true
|
||||
}
|
||||
KeyCode::Backspace if self.msg.len() > 0 => {
|
||||
self.msg.pop().unwrap();
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
if ev == Event::Key(KeyCode::Char('c').into()) {
|
||||
if !git_utils::index_empty() {
|
||||
self.show();
|
||||
return true;
|
||||
if let Event::Key(e) = ev {
|
||||
return match e.code {
|
||||
KeyCode::Esc => {
|
||||
self.hide();
|
||||
true
|
||||
}
|
||||
}
|
||||
KeyCode::Char(c) => {
|
||||
self.msg.push(c);
|
||||
true
|
||||
}
|
||||
KeyCode::Enter if self.can_commit() => {
|
||||
self.commit();
|
||||
true
|
||||
}
|
||||
KeyCode::Backspace if self.msg.len() > 0 => {
|
||||
self.msg.pop().unwrap();
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
false
|
||||
|
@ -1,7 +1,6 @@
|
||||
use git2::{
|
||||
build::CheckoutBuilder, DiffFormat, DiffOptions, IndexAddOption,
|
||||
ObjectType, Repository, RepositoryOpenFlags, StatusOptions,
|
||||
StatusShow,
|
||||
ObjectType, Repository, RepositoryOpenFlags,
|
||||
};
|
||||
use scopetime::scope_time;
|
||||
use std::path::Path;
|
||||
@ -134,21 +133,6 @@ pub fn commit(msg: &String) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
///
|
||||
pub fn index_empty() -> bool {
|
||||
scope_time!("index_empty");
|
||||
|
||||
let repo = repo();
|
||||
|
||||
let statuses = repo
|
||||
.statuses(Some(
|
||||
StatusOptions::default().show(StatusShow::Index),
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
statuses.is_empty()
|
||||
}
|
||||
|
||||
pub fn stage_add(path: &Path) -> bool {
|
||||
scope_time!("stage_add");
|
||||
|
||||
|
@ -15,3 +15,4 @@ pub const STATUS_RESET_FILE: KeyEvent = no_mod(KeyCode::Char('D'));
|
||||
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
|
||||
pub const EXIT_1: KeyEvent = no_mod(KeyCode::Esc);
|
||||
pub const EXIT_2: KeyEvent = no_mod(KeyCode::Char('q'));
|
||||
pub const OPEN_COMMIT: KeyEvent = no_mod(KeyCode::Char('c'));
|
||||
|
Loading…
Reference in New Issue
Block a user