mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
stash list does not update after pop/drop (#1865)
* move to stashlist after stashing * move to status after stash popping
This commit is contained in:
parent
16c97edb4d
commit
5be397b335
6 changed files with 63 additions and 16 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixes
|
||||
* fix commit log not updating after branch switch ([#1862](https://github.com/extrawurst/gitui/issues/1862))
|
||||
* fix stashlist not updating after pop/drop ([#1864](https://github.com/extrawurst/gitui/issues/1864))
|
||||
|
||||
## [0.24.1] - 2023-08-30
|
||||
|
||||
|
|
|
|||
28
src/app.rs
28
src/app.rs
|
|
@ -20,7 +20,8 @@ use crate::{
|
|||
options::{Options, SharedOptions},
|
||||
popup_stack::PopupStack,
|
||||
queue::{
|
||||
Action, InternalEvent, NeedsUpdate, Queue, StackablePopupOpen,
|
||||
Action, AppTabs, InternalEvent, NeedsUpdate, Queue,
|
||||
StackablePopupOpen,
|
||||
},
|
||||
setup_popups,
|
||||
strings::{self, ellipsis_trim_start, order},
|
||||
|
|
@ -697,15 +698,15 @@ impl App {
|
|||
|
||||
fn switch_tab(&mut self, k: &KeyEvent) -> Result<()> {
|
||||
if key_match(k, self.key_config.keys.tab_status) {
|
||||
self.set_tab(0)?;
|
||||
self.switch_to_tab(&AppTabs::Status)?;
|
||||
} else if key_match(k, self.key_config.keys.tab_log) {
|
||||
self.set_tab(1)?;
|
||||
self.switch_to_tab(&AppTabs::Log)?;
|
||||
} else if key_match(k, self.key_config.keys.tab_files) {
|
||||
self.set_tab(2)?;
|
||||
self.switch_to_tab(&AppTabs::Files)?;
|
||||
} else if key_match(k, self.key_config.keys.tab_stashing) {
|
||||
self.set_tab(3)?;
|
||||
self.switch_to_tab(&AppTabs::Stashing)?;
|
||||
} else if key_match(k, self.key_config.keys.tab_stashes) {
|
||||
self.set_tab(4)?;
|
||||
self.switch_to_tab(&AppTabs::Stashlist)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -727,6 +728,17 @@ impl App {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn switch_to_tab(&mut self, tab: &AppTabs) -> Result<()> {
|
||||
match tab {
|
||||
AppTabs::Status => self.set_tab(0)?,
|
||||
AppTabs::Log => self.set_tab(1)?,
|
||||
AppTabs::Files => self.set_tab(2)?,
|
||||
AppTabs::Stashing => self.set_tab(3)?,
|
||||
AppTabs::Stashlist => self.set_tab(4)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_commands(&mut self) {
|
||||
if self.help.is_visible() {
|
||||
self.help.set_cmds(self.commands(true));
|
||||
|
|
@ -855,6 +867,10 @@ impl App {
|
|||
self.tags_popup.open()?;
|
||||
}
|
||||
InternalEvent::TabSwitchStatus => self.set_tab(0)?,
|
||||
InternalEvent::TabSwitch(tab) => {
|
||||
self.switch_to_tab(&tab)?;
|
||||
flags.insert(NeedsUpdate::ALL);
|
||||
}
|
||||
InternalEvent::SelectCommitInRevlog(id) => {
|
||||
if let Err(error) = self.revlog.select_commit(id) {
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
|
|
|
|||
|
|
@ -225,8 +225,11 @@ impl CommitList {
|
|||
|
||||
///
|
||||
pub fn set_commits(&mut self, commits: Vec<CommitId>) {
|
||||
self.commits = commits;
|
||||
self.fetch_commits(false);
|
||||
if commits != self.commits {
|
||||
self.items.clear();
|
||||
self.commits = commits;
|
||||
self.fetch_commits(false);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -724,6 +727,19 @@ impl CommitList {
|
|||
self.items.needs_data(idx, idx_max)
|
||||
}
|
||||
|
||||
// checks if first entry in items is the same commit as we expect
|
||||
fn is_list_in_sync(&self) -> bool {
|
||||
self.items
|
||||
.index_offset_raw()
|
||||
.and_then(|index| {
|
||||
self.items
|
||||
.iter()
|
||||
.next()
|
||||
.map(|item| item.id == self.commits[index])
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn fetch_commits(&mut self, force: bool) {
|
||||
let want_min =
|
||||
self.selection().saturating_sub(SLICE_SIZE / 2);
|
||||
|
|
@ -731,13 +747,13 @@ impl CommitList {
|
|||
|
||||
let want_min = want_min.min(commits);
|
||||
|
||||
if !self
|
||||
let index_in_sync = self
|
||||
.items
|
||||
.index_offset_raw()
|
||||
.map(|index| want_min == index)
|
||||
.unwrap_or_default()
|
||||
|| force
|
||||
{
|
||||
.unwrap_or_default();
|
||||
|
||||
if !index_in_sync || !self.is_list_in_sync() || force {
|
||||
let slice_end =
|
||||
want_min.saturating_add(SLICE_SIZE).min(commits);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use super::{
|
|||
};
|
||||
use crate::{
|
||||
keys::{key_match, SharedKeyConfig},
|
||||
queue::{InternalEvent, NeedsUpdate, Queue},
|
||||
queue::{AppTabs, InternalEvent, Queue},
|
||||
strings,
|
||||
tabs::StashingOptions,
|
||||
ui::style::SharedTheme,
|
||||
|
|
@ -79,9 +79,11 @@ impl Component for StashMsgComponent {
|
|||
self.input.clear();
|
||||
self.hide();
|
||||
|
||||
self.queue.push(InternalEvent::Update(
|
||||
NeedsUpdate::ALL,
|
||||
));
|
||||
self.queue.push(
|
||||
InternalEvent::TabSwitch(
|
||||
AppTabs::Stashlist,
|
||||
),
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
self.hide();
|
||||
|
|
|
|||
10
src/queue.rs
10
src/queue.rs
|
|
@ -70,6 +70,14 @@ pub enum StackablePopupOpen {
|
|||
CompareCommits(InspectCommitOpen),
|
||||
}
|
||||
|
||||
pub enum AppTabs {
|
||||
Status,
|
||||
Log,
|
||||
Files,
|
||||
Stashing,
|
||||
Stashlist,
|
||||
}
|
||||
|
||||
///
|
||||
pub enum InternalEvent {
|
||||
///
|
||||
|
|
@ -91,6 +99,8 @@ pub enum InternalEvent {
|
|||
///
|
||||
TabSwitchStatus,
|
||||
///
|
||||
TabSwitch(AppTabs),
|
||||
///
|
||||
SelectCommitInRevlog(CommitId),
|
||||
///
|
||||
TagCommit(CommitId),
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ impl StashList {
|
|||
self.list.clear_marked();
|
||||
self.update()?;
|
||||
|
||||
self.queue.push(InternalEvent::TabSwitchStatus);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue