agent2: always finalize diffs from the edit tool
There were cases before where we would exit after creating the diff and wouldn't finalize it
This commit is contained in:
parent
64b14ef848
commit
afd2c3aa76
1 changed files with 137 additions and 132 deletions
|
@ -272,6 +272,7 @@ impl AgentTool for EditFileTool {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let diff = cx.new(|cx| Diff::new(buffer.clone(), cx))?;
|
let diff = cx.new(|cx| Diff::new(buffer.clone(), cx))?;
|
||||||
|
let result = async {
|
||||||
event_stream.update_diff(diff.clone());
|
event_stream.update_diff(diff.clone());
|
||||||
|
|
||||||
let old_snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?;
|
let old_snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?;
|
||||||
|
@ -389,8 +390,6 @@ impl AgentTool for EditFileTool {
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
diff.update(cx, |diff, cx| diff.finalize(cx)).ok();
|
|
||||||
|
|
||||||
let input_path = input.path.display();
|
let input_path = input.path.display();
|
||||||
if unified_diff.is_empty() {
|
if unified_diff.is_empty() {
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
|
@ -425,6 +424,12 @@ impl AgentTool for EditFileTool {
|
||||||
diff: unified_diff,
|
diff: unified_diff,
|
||||||
edit_agent_output,
|
edit_agent_output,
|
||||||
})
|
})
|
||||||
|
}.await;
|
||||||
|
|
||||||
|
// Always finalize the diff, regardless of whether the operation succeeded or failed
|
||||||
|
diff.update(cx, |diff, cx| diff.finalize(cx)).ok();
|
||||||
|
|
||||||
|
result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue