Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5f29d2f
Add Go to line feature for the blame view
andrea-berling Jun 9, 2024
9c526de
Fix make check errors
andrea-berling Jun 9, 2024
55da5d9
Move goto_line_popup up the components list for proper event handling
andrea-berling Jun 9, 2024
6bdab9d
Preserve BlameProcess in BlamePopup when jumping lines
andrea-berling Jun 30, 2024
20ed1d2
Load blame from the last blame file instead of context
andrea-berling Jul 6, 2024
e1291f0
Add a BlameRequest enum for re-using blame data in Goto line
andrea-berling Jul 16, 2024
4855ca6
Add input validation to Go to line popup
andrea-berling Sep 7, 2024
be182ae
Merge remote-tracking branch 'upstream/master'
andrea-berling Sep 17, 2024
56732c2
Fix up negative indexing and add changelog entry
andrea-berling Sep 18, 2024
3c8afa1
Merge remote-tracking branch 'upstream/master'
andrea-berling Sep 18, 2024
dc65a8d
Merge remote-tracking branch 'upstream/master'
andrea-berling Oct 1, 2024
bea05c2
Prevent GotoLine popup from opening before blame load and fix typo
andrea-berling Oct 1, 2024
df83ef0
Merge remote-tracking branch 'upstream/master'
andrea-berling Nov 26, 2024
583eb7c
Add hints for the Go To Line popup
andrea-berling Mar 22, 2025
edb8e7b
Merge remote-tracking branch 'upstream/master'
andrea-berling Mar 22, 2025
2287164
Merge branch 'master' into master
extrawurst Mar 22, 2025
58cc56f
Merge remote-tracking branch 'upstream/master'
andrea-berling Oct 28, 2025
c4ad1aa
Merge remote-tracking branch 'origin/master'
andrea-berling Oct 28, 2025
89f4fbb
Merge remote-tracking branch 'upstream/master'
andrea-berling Oct 28, 2025
e3fe1a8
Merge remote-tracking branch 'upstream/master'
andrea-berling Oct 30, 2025
fb2563d
fix(changelog): clean up some merge mixups in the changelog
andrea-berling Oct 30, 2025
ec4b1ef
refactor(go_to_line): rename "Go to line" into "Go to"
andrea-berling Oct 30, 2025
e95c394
refactor(popup): make goto line a non-stackable popup
andrea-berling Oct 31, 2025
f26b25e
refactor: remove unused Debug derives
andrea-berling Oct 31, 2025
aa80843
refactor: remove unnecessary pub specifiers
andrea-berling Oct 31, 2025
092431f
Merge remote-tracking branch 'upstream/master'
andrea-berling Nov 1, 2025
81e6515
refactor: simplify `GotoLinePopup`
andrea-berling Nov 1, 2025
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
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* new command-line option to override the default log file path (`--logfile`) [[@acuteenvy](https://github.com/acuteenvy)] ([#2539](https://github.com/gitui-org/gitui/pull/2539))
* dx: `make check` checks Cargo.toml dependency ordering using `cargo sort` [[@naseschwarz](https://github.com/naseschwarz)]
* add `use_selection_fg` to theme file to allow customizing selection foreground color [[@Upsylonbare](https://github.com/Upsylonbare)] ([#2515](https://github.com/gitui-org/gitui/pull/2515))
* Add "go to line" command for the blame view [[@andrea-berling](https://github.com/andrea-berling)] ([#2262](https://github.com/extrawurst/gitui/pull/2262))

### Changed
* improve error messages [[@acuteenvy](https://github.com/acuteenvy)] ([#2617](https://github.com/gitui-org/gitui/pull/2617))
Expand Down Expand Up @@ -47,13 +48,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* use default shell instead of bash on Unix-like OS [[@yerke](https://github.com/yerke)] ([#2343](https://github.com/gitui-org/gitui/pull/2343))

### Added
* add popups for viewing, adding, updating and removing remotes [[@robin-thoene](https://github.com/robin-thoene)] ([#2172](https://github.com/gitui-org/gitui/issues/2172))
* support for `Copy Path` action in WSL [[@johnDeSilencio](https://github.com/johnDeSilencio)] ([#2413](https://github.com/gitui-org/gitui/pull/2413))
* help popup scrollbar [[@wugeer](https://github.com/wugeer)] ([#2388](https://github.com/gitui-org/gitui/pull/2388))

### Fixes
* respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/gitui-org/gitui/issues/2298))
* Set `CREATE_NO_WINDOW` flag when executing Git hooks on Windows ([#2371](https://github.com/gitui-org/gitui/pull/2371))
* support for "Copy Path" action in WSL [[@johnDeSilencio](https://github.com/johnDeSilencio)] ([#2413](https://github.com/extrawurst/gitui/pull/2413))
* help popup scrollbar [[@wugeer](https://github.com/wugeer)](https://github.com/extrawurst/gitui/pull/2388))
* add popups for viewing, adding, updating and removing remotes [[@robin-thoene](https://github.com/robin-thoene)] ([#2172](https://github.com/extrawurst/gitui/issues/2172))

## [0.26.3] - 2024-06-02

Expand Down
6 changes: 4 additions & 2 deletions asyncgit/src/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@ use std::{
};

///
#[derive(Hash, Clone, PartialEq, Eq)]
#[derive(Hash, Clone, PartialEq, Eq, Debug)]
pub struct BlameParams {
/// path to the file to blame
pub file_path: String,
/// blame at a specific revision
pub commit_id: Option<CommitId>,
}

#[derive(Debug)]
struct Request<R, A>(R, Option<A>);

#[derive(Default, Clone)]
#[derive(Debug, Default, Clone)]
struct LastResult<P, R> {
params: P,
result: R,
}

///
#[derive(Debug, Clone)]
pub struct AsyncBlame {
current: Arc<Mutex<Request<u64, FileBlame>>>,
last: Arc<Mutex<Option<LastResult<BlameParams, FileBlame>>>>,
Expand Down
49 changes: 38 additions & 11 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use crate::{
options::{Options, SharedOptions},
popup_stack::PopupStack,
popups::{
AppOption, BlameFilePopup, BranchListPopup, CommitPopup,
CompareCommitsPopup, ConfirmPopup, CreateBranchPopup,
CreateRemotePopup, ExternalEditorPopup, FetchPopup,
FileRevlogPopup, FuzzyFindPopup, HelpPopup,
InspectCommitPopup, LogSearchPopupPopup, MsgPopup,
OptionsPopup, PullPopup, PushPopup, PushTagsPopup,
RemoteListPopup, RenameBranchPopup, RenameRemotePopup,
ResetPopup, RevisionFilesPopup, StashMsgPopup,
SubmodulesListPopup, TagCommitPopup, TagListPopup,
UpdateRemoteUrlPopup,
AppOption, BlameFileOpen, BlameFilePopup, BlameRequest,
BranchListPopup, CommitPopup, CompareCommitsPopup,
ConfirmPopup, CreateBranchPopup, CreateRemotePopup,
ExternalEditorPopup, FetchPopup, FileRevlogPopup,
FuzzyFindPopup, GotoLinePopup, HelpPopup, InspectCommitPopup,
LogSearchPopupPopup, MsgPopup, OptionsPopup, PullPopup,
PushPopup, PushTagsPopup, RemoteListPopup, RenameBranchPopup,
RenameRemotePopup, ResetPopup, RevisionFilesPopup,
StashMsgPopup, SubmodulesListPopup, TagCommitPopup,
TagListPopup, UpdateRemoteUrlPopup,
},
queue::{
Action, AppTabs, InternalEvent, NeedsUpdate, Queue,
Expand Down Expand Up @@ -112,6 +112,7 @@ pub struct App {
popup_stack: PopupStack,
options: SharedOptions,
repo_path_text: String,
goto_line_popup: GotoLinePopup,

// "Flags"
requires_redraw: Cell<bool>,
Expand Down Expand Up @@ -218,6 +219,7 @@ impl App {
stashing_tab: Stashing::new(&env),
stashlist_tab: StashList::new(&env),
files_tab: FilesTab::new(&env),
goto_line_popup: GotoLinePopup::new(&env),
tab: 0,
queue: env.queue,
theme: env.theme,
Expand Down Expand Up @@ -481,6 +483,7 @@ impl App {
msg_popup,
confirm_popup,
commit_popup,
goto_line_popup,
blame_file_popup,
file_revlog_popup,
stashmsg_popup,
Expand Down Expand Up @@ -544,7 +547,8 @@ impl App {
fetch_popup,
options_popup,
confirm_popup,
msg_popup
msg_popup,
goto_line_popup
]
);

Expand Down Expand Up @@ -691,6 +695,9 @@ impl App {
StackablePopupOpen::CompareCommits(param) => {
self.compare_commits_popup.open(param)?;
}
StackablePopupOpen::GotoLine(param) => {
self.goto_line_popup.open(param);
}
}

Ok(())
Expand Down Expand Up @@ -905,6 +912,26 @@ impl App {
InternalEvent::CommitSearch(options) => {
self.revlog.search(options);
}
InternalEvent::GotoLine(line) => {
if let Some(popup) = self.popup_stack.pop() {
if let StackablePopupOpen::BlameFile(params) =
popup
{
self.popup_stack.push(
StackablePopupOpen::BlameFile(
BlameFileOpen {
selection: Some(line),
blame: BlameRequest::KeepExisting,
..params
},
),
);
}
flags.insert(
NeedsUpdate::ALL | NeedsUpdate::COMMANDS,
);
}
}
}

Ok(flags)
Expand Down
3 changes: 2 additions & 1 deletion src/components/revision_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{
use crate::{
app::Environment,
keys::{key_match, SharedKeyConfig},
popups::{BlameFileOpen, FileRevOpen},
popups::{BlameFileOpen, BlameRequest, FileRevOpen},
queue::{InternalEvent, Queue, StackablePopupOpen},
strings::{self, order, symbol},
try_or_popup,
Expand Down Expand Up @@ -193,6 +193,7 @@ impl RevisionFilesComponent {
file_path: path,
commit_id: self.revision.as_ref().map(|c| c.id),
selection: None,
blame: BlameRequest::StartNew,
}),
));

Expand Down
4 changes: 3 additions & 1 deletion src/components/status_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
app::Environment,
components::{CommandInfo, Component, EventState},
keys::{key_match, SharedKeyConfig},
popups::{BlameFileOpen, FileRevOpen},
popups::{BlameFileOpen, BlameRequest, FileRevOpen},
queue::{InternalEvent, NeedsUpdate, Queue, StackablePopupOpen},
strings::{self, order},
ui::{self, style::SharedTheme},
Expand Down Expand Up @@ -492,6 +492,8 @@ impl Component for StatusTreeComponent {
.path,
commit_id: self.revision,
selection: None,
blame:
BlameRequest::StartNew,
},
),
),
Expand Down
2 changes: 2 additions & 0 deletions src/keys/key_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ pub struct KeysList {
pub commit_history_next: GituiKeyEvent,
pub commit: GituiKeyEvent,
pub newline: GituiKeyEvent,
pub goto_line: GituiKeyEvent,
}

#[rustfmt::skip]
Expand Down Expand Up @@ -225,6 +226,7 @@ impl Default for KeysList {
commit_history_next: GituiKeyEvent::new(KeyCode::Char('n'), KeyModifiers::CONTROL),
commit: GituiKeyEvent::new(KeyCode::Char('d'), KeyModifiers::CONTROL),
newline: GituiKeyEvent::new(KeyCode::Enter, KeyModifiers::empty()),
goto_line: GituiKeyEvent::new(KeyCode::Char('L'), KeyModifiers::SHIFT),
}
}
}
Expand Down
69 changes: 60 additions & 9 deletions src/popups/blame_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ use ratatui::{
};
use std::path::Path;

use super::{goto_line::GotoLineContext, GotoLineOpen};

static NO_COMMIT_ID: &str = "0000000";
static NO_AUTHOR: &str = "<no author>";
static MIN_AUTHOR_WIDTH: usize = 3;
static MAX_AUTHOR_WIDTH: usize = 20;

struct SyntaxFileBlame {
#[derive(Debug, Clone)]
pub struct SyntaxFileBlame {
pub file_blame: FileBlame,
pub styled_text: Option<SyntaxText>,
}
Expand All @@ -54,7 +57,8 @@ impl SyntaxFileBlame {
}
}

enum BlameProcess {
#[derive(Clone, Debug)]
pub enum BlameProcess {
GettingBlame(AsyncBlame),
SyntaxHighlighting {
unstyled_file_blame: SyntaxFileBlame,
Expand All @@ -76,11 +80,18 @@ impl BlameProcess {
}
}

#[derive(Clone, Debug)]
pub enum BlameRequest {
StartNew,
KeepExisting,
}

#[derive(Clone, Debug)]
pub struct BlameFileOpen {
pub file_path: String,
pub commit_id: Option<CommitId>,
pub selection: Option<usize>,
pub blame: BlameRequest,
}

pub struct BlameFilePopup {
Expand Down Expand Up @@ -234,6 +245,16 @@ impl Component for BlameFilePopup {
)
.order(1),
);
out.push(
CommandInfo::new(
strings::commands::open_line_number_popup(
&self.key_config,
),
true,
has_result,
)
.order(1),
);
}

visibility_blocking(self)
Expand Down Expand Up @@ -307,6 +328,31 @@ impl Component for BlameFilePopup {
),
));
}
} else if key_match(
key,
self.key_config.keys.goto_line,
) {
let maybe_blame_result = &self
.blame
.as_ref()
.and_then(|blame| blame.result());
if maybe_blame_result.is_some() {
let max_line = maybe_blame_result
.expect("This can not be None")
.lines()
.len() - 1;
self.hide_stacked(true);
self.visible = true;
self.queue.push(InternalEvent::OpenPopup(
StackablePopupOpen::GotoLine(
GotoLineOpen {
context: GotoLineContext {
max_line,
},
},
),
));
}
}

return Ok(EventState::Consumed);
Expand Down Expand Up @@ -356,6 +402,7 @@ impl BlameFilePopup {
file_path: request.file_path,
commit_id: request.commit_id,
selection: self.get_selection(),
blame: BlameRequest::KeepExisting,
}),
));
}
Expand All @@ -371,11 +418,13 @@ impl BlameFilePopup {
file_path: open.file_path,
commit_id: open.commit_id,
});
self.blame =
Some(BlameProcess::GettingBlame(AsyncBlame::new(
self.repo.borrow().clone(),
&self.git_sender,
)));
if matches!(open.blame, BlameRequest::StartNew) {
self.blame =
Some(BlameProcess::GettingBlame(AsyncBlame::new(
self.repo.borrow().clone(),
&self.git_sender,
)));
}
self.table_state.get_mut().select(Some(0));
self.visible = true;
self.update()?;
Expand Down Expand Up @@ -438,7 +487,6 @@ impl BlameFilePopup {
),
},
);
self.set_open_selection();
self.highlight_blame_lines();

return Ok(());
Expand All @@ -449,6 +497,7 @@ impl BlameFilePopup {
}
}
}
self.set_open_selection();

Ok(())
}
Expand Down Expand Up @@ -722,7 +771,9 @@ impl BlameFilePopup {
self.open_request.as_ref().and_then(|req| req.selection)
{
let mut table_state = self.table_state.take();
table_state.select(Some(selection));
let max_line_number = self.get_max_line_number();
table_state
.select(Some(selection.clamp(0, max_line_number)));
self.table_state.set(table_state);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/popups/file_revlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use ratatui::{
Frame,
};

use super::{BlameFileOpen, InspectCommitOpen};
use super::{BlameFileOpen, BlameRequest, InspectCommitOpen};

const SLICE_SIZE: usize = 1200;

Expand Down Expand Up @@ -533,6 +533,7 @@ impl Component for FileRevlogPopup {
file_path: open_request.file_path,
commit_id: self.selected_commit(),
selection: None,
blame: BlameRequest::StartNew,
},
),
));
Expand Down
Loading