Files
zed/crates/edit_prediction_cli/src/distill.rs
T
Oleksiy Syvokon d09e6cd7b9 ep: Store cursor position in global coordinates (#48469)
This also fixes the isolated whitespace change metric, which is not
takes cursor position into account (it's okay to insert a newline if it
has a cursor on it)

Release Notes:

- N/A
2026-02-05 12:31:12 +00:00

37 lines
968 B
Rust

use anyhow::Result;
use crate::{PredictionProvider, example::Example};
pub async fn run_distill(example: &mut Example) -> Result<()> {
let has_repair = example
.predictions
.iter()
.find(|p| p.provider == PredictionProvider::Repair);
let predictions = if let Some(has_repair) = has_repair {
vec![has_repair]
} else {
example.predictions.iter().collect()
};
let expected_patches = predictions
.into_iter()
.filter_map(|p| {
Some((
p.actual_patch.clone()?,
p.actual_cursor
.as_ref()
.and_then(|c| c.editable_region_offset),
))
})
.collect();
example
.spec
.set_expected_patches_with_cursor_positions(expected_patches);
example.prompt = None;
example.predictions = Vec::new();
example.score = Vec::new();
example.qa = Vec::new();
Ok(())
}