mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Refactor snapshot attribute handling in patch computation
- Removed redundant Rojo reference attributes from snapshot comparisons to prevent spurious diffs during VFS events. - Updated the logic for interned instance additions to ensure deterministic ordering by redacted parent and name. These changes aim to improve the accuracy of snapshot comparisons and enhance the handling of interned instances.
This commit is contained in:
parent
c47e568cd4
commit
eb114ac76e
7 changed files with 40 additions and 40 deletions
|
|
@ -9,7 +9,8 @@ use rbx_dom_weak::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
variant_eq::variant_eq, RojoRef, REF_PATH_ATTRIBUTE_PREFIX, REF_POINTER_ATTRIBUTE_PREFIX,
|
||||
variant_eq::variant_eq, RojoRef, REF_ID_ATTRIBUTE_NAME, REF_PATH_ATTRIBUTE_PREFIX,
|
||||
REF_POINTER_ATTRIBUTE_PREFIX,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
@ -110,6 +111,29 @@ fn compute_property_patches(
|
|||
|
||||
let attribute_ref_properties = compute_ref_properties(snapshot, tree, instance.id());
|
||||
|
||||
// Strip Rojo ref transport attributes from the snapshot before comparison.
|
||||
// finalize_patch_application strips these from the tree after resolving refs,
|
||||
// so the snapshot must be stripped too to prevent spurious diffs on duplicate
|
||||
// VFS events (common on macOS). The refs were already extracted above.
|
||||
if let Some(Variant::Attributes(attrs)) = snapshot.properties.get_mut(&ustr("Attributes")) {
|
||||
let keys_to_remove: Vec<String> = attrs
|
||||
.iter()
|
||||
.filter_map(|(name, _)| {
|
||||
if name == REF_ID_ATTRIBUTE_NAME
|
||||
|| name.starts_with(REF_POINTER_ATTRIBUTE_PREFIX)
|
||||
|| name.starts_with(REF_PATH_ATTRIBUTE_PREFIX)
|
||||
{
|
||||
Some(name.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
for key in keys_to_remove {
|
||||
attrs.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
let changed_name = if snapshot.name == instance.name() {
|
||||
None
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue