resolve: build the resolved document field by field instead of cloning the input tree to discard it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
32205f8b2b
commit
2fcd522516
1 changed files with 11 additions and 1 deletions
|
|
@ -92,7 +92,17 @@ pub fn resolve(document: &SurfaceDocument, port: &dyn StatePort, limits: &Limits
|
|||
let tree = root.and_then(|root| {
|
||||
diagnostics.extend(validate::check(&root, limits, &document.record_key()));
|
||||
let refused = diagnostics.iter().any(|diagnostic| diagnostic.code.refuses_document());
|
||||
(!refused).then(|| ResolvedTree { document: SurfaceDocument { root, ..document.clone() } })
|
||||
// Field by field: `..document.clone()` would clone the whole input tree to discard it.
|
||||
(!refused).then(|| ResolvedTree {
|
||||
document: SurfaceDocument {
|
||||
provider_id: document.provider_id.clone(),
|
||||
label: document.label.clone(),
|
||||
version: document.version,
|
||||
title: document.title.clone(),
|
||||
root,
|
||||
commands: document.commands.clone(),
|
||||
},
|
||||
})
|
||||
});
|
||||
Resolution { tree, diagnostics, reads }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue