Skip to content

Commit

Permalink
fix make check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hamflx committed Jun 17, 2023
1 parent 4cd425f commit 4f157bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* allow `copy` file path on revision files and status tree [[@yanganto]](https://github.com/yanganto) ([#1516](https://github.com/extrawurst/gitui/pull/1516))
* print message of where log will be written if `-l` is set ([#1472](https://github.com/extrawurst/gitui/pull/1472))
* show remote branches in log [[@cruessler](https://github.com/cruessler)] ([#1501](https://github.com/extrawurst/gitui/issues/1501))
* support 'n'/'p' key to move to the next/prev hunk in diff component [[@hamflx](https://github.com/hamflx)] ([#1523](https://github.com/extrawurst/gitui/issues/1523))

### Fixes
* fixed side effect of crossterm 0.26 on windows that caused double input of all keys [[@pm100]](https://github/pm100) ([#1686](https://github.com/extrawurst/gitui/pull/1686))
Expand Down
21 changes: 6 additions & 15 deletions src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,24 +637,15 @@ impl DiffComponent {
if diff.hunks.is_empty() {
return None;
}
let max = diff.hunks.len() as isize - 1;
let target_index = self
.selected_hunk
.map(|i| {
std::cmp::max(
0,
std::cmp::min(max, i as isize + direction),
)
})
.unwrap_or(0) as usize;
let max = diff.hunks.len() - 1;
let target_index = self.selected_hunk.map_or(0, |i| {
std::cmp::min(max, i.saturating_add_signed(direction))
});
Some(target_index)
}

fn diff_hunk_move_up_down(&mut self, direction: isize) {
let diff = match &self.diff {
Some(diff) => diff,
None => return,
};
let Some(diff) = &self.diff else { return };
let target_index = self.calc_hunk_move_target(direction);
// return if selected_hunk not change
if self.selected_hunk == target_index {
Expand Down Expand Up @@ -820,7 +811,7 @@ impl Component for DiffComponent {
CommandBlocking::PassingOn
}

#[allow(clippy::cognitive_complexity)]
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
fn event(&mut self, ev: &Event) -> Result<EventState> {
if self.focused() {
if let Event::Key(e) = ev {
Expand Down

0 comments on commit 4f157bf

Please sign in to comment.