Skip to content

Commit 76577fc

Browse files
Load blame from the last blame file instead of context
Remove context and references to it Addres gitui-org#2262 (comment) Address gitui-org#2262 (comment)
1 parent ab2318f commit 76577fc

File tree

5 files changed

+20
-35
lines changed

5 files changed

+20
-35
lines changed

src/app.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::{
2121
TagListPopup,
2222
},
2323
queue::{
24-
Action, AppTabs, Context, InternalEvent, NeedsUpdate, Queue,
24+
Action, AppTabs, InternalEvent, NeedsUpdate, Queue,
2525
StackablePopupOpen,
2626
},
2727
setup_popups,
@@ -675,8 +675,8 @@ impl App {
675675
StackablePopupOpen::CompareCommits(param) => {
676676
self.compare_commits_popup.open(param)?;
677677
}
678-
StackablePopupOpen::GotoLine(context) => {
679-
self.goto_line_popup.open(Some(context));
678+
StackablePopupOpen::GotoLine => {
679+
self.goto_line_popup.open();
680680
}
681681
}
682682

@@ -880,21 +880,18 @@ impl App {
880880
InternalEvent::CommitSearch(options) => {
881881
self.revlog.search(options);
882882
}
883-
InternalEvent::GotoLine(line, context) => {
883+
InternalEvent::GotoLine(line) => {
884884
if let Some(popup) = self.popup_stack.pop() {
885885
if let StackablePopupOpen::BlameFile(params) =
886886
popup
887887
{
888+
let blame =
889+
self.blame_file_popup.blame.clone();
888890
self.popup_stack.push(
889891
StackablePopupOpen::BlameFile(
890892
BlameFileOpen {
891893
selection: Some(line),
892-
blame: context.and_then(|ctx| {
893-
let Context::Blame(
894-
blame_process,
895-
) = ctx;
896-
blame_process
897-
}),
894+
blame,
898895
..params
899896
},
900897
),

src/popups/blame_file.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
},
88
keys::{key_match, SharedKeyConfig},
99
popups::{FileRevOpen, InspectCommitOpen},
10-
queue::{Context, InternalEvent, Queue, StackablePopupOpen},
10+
queue::{InternalEvent, Queue, StackablePopupOpen},
1111
string_utils::tabs_to_spaces,
1212
strings,
1313
ui::{self, style::SharedTheme, AsyncSyntaxJob, SyntaxText},
@@ -96,7 +96,7 @@ pub struct BlameFilePopup {
9696
table_state: std::cell::Cell<TableState>,
9797
key_config: SharedKeyConfig,
9898
current_height: std::cell::Cell<usize>,
99-
blame: Option<BlameProcess>,
99+
pub blame: Option<BlameProcess>,
100100
app_sender: Sender<AsyncAppNotification>,
101101
git_sender: Sender<AsyncGitNotification>,
102102
repo: RepoPathRef,
@@ -327,9 +327,7 @@ impl Component for BlameFilePopup {
327327
self.hide_stacked(true);
328328
self.visible = true;
329329
self.queue.push(InternalEvent::OpenPopup(
330-
StackablePopupOpen::GotoLine(Context::Blame(
331-
self.blame.clone(),
332-
)),
330+
StackablePopupOpen::GotoLine,
333331
));
334332
}
335333

@@ -751,7 +749,8 @@ impl BlameFilePopup {
751749
{
752750
let mut table_state = self.table_state.take();
753751
let max_line_number = self.get_max_line_number();
754-
table_state.select(Some(selection.min(max_line_number)));
752+
table_state
753+
.select(Some(selection.clamp(0, max_line_number)));
755754
self.table_state.set(table_state);
756755
}
757756
}

src/popups/goto_line.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
DrawableComponent, EventState,
66
},
77
keys::{key_match, SharedKeyConfig},
8-
queue::{Context, InternalEvent, Queue},
8+
queue::{InternalEvent, Queue},
99
ui::{self, style::SharedTheme},
1010
};
1111

@@ -25,7 +25,6 @@ pub struct GotoLinePopup {
2525
key_config: SharedKeyConfig,
2626
queue: Queue,
2727
theme: SharedTheme,
28-
context: Option<Context>,
2928
}
3029

3130
impl GotoLinePopup {
@@ -36,13 +35,11 @@ impl GotoLinePopup {
3635
key_config: env.key_config.clone(),
3736
queue: env.queue.clone(),
3837
theme: env.theme.clone(),
39-
context: None,
4038
}
4139
}
4240

43-
pub fn open(&mut self, context: Option<Context>) {
41+
pub fn open(&mut self) {
4442
self.visible = true;
45-
self.context = context;
4643
}
4744
}
4845

@@ -82,8 +79,7 @@ impl Component for GotoLinePopup {
8279
self.visible = false;
8380
if !self.line.is_empty() {
8481
self.queue.push(InternalEvent::GotoLine(
85-
self.line.parse::<usize>().expect("This shouldn't happen since the input is constrained to ascii digits only"),
86-
self.context.clone()
82+
self.line.parse::<usize>()?,
8783
));
8884
}
8985
self.queue.push(InternalEvent::PopupStackPop);

src/popups/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mod submodules;
2525
mod tag_commit;
2626
mod taglist;
2727

28-
pub use blame_file::{BlameFileOpen, BlameFilePopup, BlameProcess};
28+
pub use blame_file::{BlameFileOpen, BlameFilePopup};
2929
pub use branchlist::BranchListPopup;
3030
pub use commit::CommitPopup;
3131
pub use compare_commits::CompareCommitsPopup;

src/queue.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{
22
components::FuzzyFinderTarget,
33
popups::{
4-
AppOption, BlameFileOpen, BlameProcess, FileRevOpen,
5-
FileTreeOpen, InspectCommitOpen,
4+
AppOption, BlameFileOpen, FileRevOpen, FileTreeOpen,
5+
InspectCommitOpen,
66
},
77
tabs::StashingOptions,
88
};
@@ -56,13 +56,6 @@ pub enum Action {
5656
UndoCommit,
5757
}
5858

59-
#[derive(Debug, Clone)]
60-
pub enum Context {
61-
Blame(Option<BlameProcess>),
62-
//FileView,
63-
//PossibleRange(u32, u32),
64-
}
65-
6659
#[derive(Debug)]
6760
pub enum StackablePopupOpen {
6861
///
@@ -76,7 +69,7 @@ pub enum StackablePopupOpen {
7669
///
7770
CompareCommits(InspectCommitOpen),
7871
///
79-
GotoLine(Context),
72+
GotoLine,
8073
}
8174

8275
pub enum AppTabs {
@@ -156,7 +149,7 @@ pub enum InternalEvent {
156149
///
157150
CommitSearch(LogFilterSearchOptions),
158151
///
159-
GotoLine(usize, Option<Context>),
152+
GotoLine(usize),
160153
}
161154

162155
/// single threaded simple queue for components to communicate with each other

0 commit comments

Comments
 (0)