This commit is contained in:
jimmyfraiture
2025-09-09 14:35:12 -07:00
parent 2a3bc78f98
commit 3150f50c63
3 changed files with 21 additions and 27 deletions

View File

@@ -194,10 +194,10 @@ impl PatchUndoHistory {
}
fn finish_undo(&mut self, success: bool) {
if let Some(turn) = self.undo_in_progress.take() {
if !success {
self.completed_turns.push(turn);
}
if let Some(turn) = self.undo_in_progress.take()
&& !success
{
self.completed_turns.push(turn);
}
}

View File

@@ -1186,32 +1186,30 @@ pub(crate) fn new_patch_undo_available(patch_count: usize) -> PlainHistoryCell {
}
pub(crate) fn new_patch_undo_unavailable() -> PlainHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push("No applied patch to undo.".dim().into());
let lines = vec!["No applied patch to undo.".dim().into()];
PlainHistoryCell { lines }
}
pub(crate) fn new_patch_undo_busy() -> PlainHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push("Undo already running".magenta().bold().into());
lines.push(
let lines = vec![
"Undo already running".magenta().bold().into(),
"Wait for the previous undo to finish before starting another."
.dim()
.into(),
);
];
PlainHistoryCell { lines }
}
pub(crate) fn new_patch_undo_in_progress() -> PlainHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push("↺ Undoing latest patch…".magenta().bold().into());
let lines = vec!["↺ Undoing latest patch…".magenta().bold().into()];
PlainHistoryCell { lines }
}
pub(crate) fn new_patch_undo_cancelled() -> PlainHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push("↺ Undo cancelled".magenta().bold().into());
lines.push("Keeping the last turn's changes.".dim().into());
let lines = vec![
"↺ Undo cancelled".magenta().bold().into(),
"Keeping the last turn's changes.".dim().into(),
];
PlainHistoryCell { lines }
}

View File

@@ -61,10 +61,9 @@ mod tests {
if status.success() {
Ok(())
} else {
Err(io::Error::new(
io::ErrorKind::Other,
format!("git {:?} failed with status {status}", args),
))
Err(io::Error::other(format!(
"git {args:?} failed with status {status}"
)))
}
}
@@ -73,14 +72,11 @@ mod tests {
if output.status.success() {
Ok(String::from_utf8_lossy(&output.stdout).into_owned())
} else {
Err(io::Error::new(
io::ErrorKind::Other,
format!(
"git {:?} failed: {}",
args,
String::from_utf8_lossy(&output.stderr)
),
))
Err(io::Error::other(format!(
"git {:?} failed: {}",
args,
String::from_utf8_lossy(&output.stderr)
)))
}
}