Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
extrawurst committed Aug 26, 2023
1 parent e238f19 commit d1418bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
33 changes: 8 additions & 25 deletions src/components/commitlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,9 @@ impl CommitList {
}

///
pub fn set_commits(
&mut self,
commits: Vec<CommitId>,
) -> Result<()> {
pub fn set_commits(&mut self, commits: Vec<CommitId>) {
self.commits = commits;
self.fetch_commits()?;

Ok(())
self.fetch_commits();
}

fn select_next_highlight(&mut self) {
Expand Down Expand Up @@ -666,32 +661,23 @@ impl CommitList {
}

///
pub fn refresh_extend_data(
&mut self,
commits: Vec<CommitId>,
) -> Result<()> {
log::info!("refresh_extend_data: {}", commits.len());

pub fn refresh_extend_data(&mut self, commits: Vec<CommitId>) {
let new_commits = !commits.is_empty();
self.commits.extend(commits.into_iter());
self.commits.extend(commits);

let selection = self.selection();
let selection_max = self.selection_max();

if self.needs_data(selection, selection_max) || new_commits {
self.fetch_commits()?;
self.fetch_commits();
}

Ok(())
}

fn fetch_commits(&mut self) -> Result<()> {
fn fetch_commits(&mut self) {
let want_min =
self.selection().saturating_sub(SLICE_SIZE / 2);
let commits = self.commits.len();

log::info!("fetch_commits: {want_min}/{commits}");

let want_min = want_min.min(commits);
let slice_end =
want_min.saturating_add(SLICE_SIZE).min(commits);
Expand All @@ -710,19 +696,16 @@ impl CommitList {
&self.highlights.clone(),
);
}

Ok(())
}

///
pub fn set_highlighting(
&mut self,
highlighting: Option<HashSet<CommitId>>,
) -> Result<()> {
) {
self.highlights = highlighting;
self.select_next_highlight();
self.fetch_commits()?;
Ok(())
self.fetch_commits();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/tabs/revlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ impl Revlog {

if self.update_search_state()? {
if let Some(search) = self.search_result_set() {
self.list.set_highlighting(Some(search))?;
self.list.set_highlighting(Some(search));
}
}

self.list
.refresh_extend_data(self.git_log.extract_items()?)?;
.refresh_extend_data(self.git_log.extract_items()?);

self.git_tags.request(Duration::from_secs(3), false)?;

Expand Down Expand Up @@ -277,7 +277,7 @@ impl Revlog {

self.search = LogSearch::Searching(async_find, options);

self.list.set_highlighting(None)?;
self.list.set_highlighting(None);
}

Ok(())
Expand Down Expand Up @@ -429,7 +429,7 @@ impl Component for Revlog {
) {
if self.can_leave_search() {
self.search = LogSearch::Off;
self.list.set_highlighting(None)?;
self.list.set_highlighting(None);
return Ok(EventState::Consumed);
}
} else if key_match(k, self.key_config.keys.copy) {
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/stashlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl StashList {
pub fn update(&mut self) -> Result<()> {
if self.is_visible() {
let stashes = sync::get_stashes(&self.repo.borrow())?;
self.list.set_commits(stashes)?;
self.list.set_commits(stashes);
}

Ok(())
Expand Down

0 comments on commit d1418bb

Please sign in to comment.