Skip to content

Commit

Permalink
fix some potentials for errors to bubble up (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Feb 24, 2021
1 parent 4a0e671 commit eeab8f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ profile:
cargo run --features=timing,pprof -- -l

debug:
cargo run --features=timing -- -l
RUST_BACKTRACE=true cargo run --features=timing -- -l

build-release:
cargo build --release
Expand Down
21 changes: 16 additions & 5 deletions src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,16 @@ impl DiffComponent {
);
}

fn stage_unstage_hunk(&mut self) -> Result<()> {
if self.current.is_stage {
self.unstage_hunk()?;
} else {
self.stage_hunk()?;
}

Ok(())
}

const fn is_stage(&self) -> bool {
self.current.is_stage
}
Expand Down Expand Up @@ -659,11 +669,12 @@ impl Component for DiffComponent {
} else if e == self.key_config.enter
&& !self.is_immutable
{
if self.current.is_stage {
self.unstage_hunk()?;
} else {
self.stage_hunk()?;
}
try_or_popup!(
self,
"hunk error:",
self.stage_unstage_hunk()
);

Ok(true)
} else if e == self.key_config.status_reset_item
&& !self.is_immutable
Expand Down

0 comments on commit eeab8f2

Please sign in to comment.