Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct Commit {
pub body: String,
pub parent_commit_hashes: Vec<CommitHash>,
pub commit_type: CommitType,
pub line_number: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -267,7 +268,7 @@ fn load_all_commits(path: &Path, sort: SortCommit, stashes: &[Commit]) -> Vec<Co

let mut commits = Vec::new();

for bytes in reader.split(b'\0') {
for (i, bytes) in reader.split(b'\0').enumerate() {
let bytes = bytes.unwrap();
let s = String::from_utf8_lossy(&bytes);

Expand All @@ -288,6 +289,7 @@ fn load_all_commits(path: &Path, sort: SortCommit, stashes: &[Commit]) -> Vec<Co
body: parts[8].into(),
parent_commit_hashes: parse_parent_commit_hashes(parts[9]),
commit_type: CommitType::Commit,
line_number: i,
};

commits.push(commit);
Expand Down Expand Up @@ -316,7 +318,7 @@ fn load_all_stashes(path: &Path) -> Vec<Commit> {

let mut commits = Vec::new();

for bytes in reader.split(b'\0') {
for (i, bytes) in reader.split(b'\0').enumerate() {
let bytes = bytes.unwrap();
let s = String::from_utf8_lossy(&bytes);

Expand All @@ -337,6 +339,7 @@ fn load_all_stashes(path: &Path) -> Vec<Commit> {
body: parts[8].into(),
parent_commit_hashes: parse_parent_commit_hashes(parts[9]),
commit_type: CommitType::Stash,
line_number: i,
};

commits.push(commit);
Expand Down
7 changes: 5 additions & 2 deletions src/widget/commit_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,17 +803,20 @@ impl CommitList<'_> {
commit.subject.to_string()
};

let line_number = commit.line_number + 1; // 1-based
let subject_with_line = format!("{:>4} | {}", line_number, subject);

let sub_spans =
if let Some(pos) = state.search_matches[state.offset + i].subject.clone() {
highlighted_spans(
subject,
subject_with_line,
pos,
self.color_theme.list_subject_fg,
self.color_theme,
truncate,
)
} else {
vec![subject.into()]
vec![subject_with_line.into()]
};

spans.extend(sub_spans)
Expand Down