Refactor context method
This commit is contained in:
parent
d6ab891d7f
commit
bd76622543
@ -444,23 +444,17 @@ impl ContextInner {
|
|||||||
let found = self.update_position_if_found(identifier, position)?;
|
let found = self.update_position_if_found(identifier, position)?;
|
||||||
|
|
||||||
if found {
|
if found {
|
||||||
return Ok(true);
|
Ok(true)
|
||||||
} else if let Some(parent) = &self.parent {
|
} else {
|
||||||
if let Some(parent) = parent.upgrade() {
|
|
||||||
let found_in_ancestor = parent.update_position_if_found(identifier, position)?;
|
|
||||||
|
|
||||||
if !found_in_ancestor {
|
|
||||||
let mut associations = self.associations.write()?;
|
let mut associations = self.associations.write()?;
|
||||||
|
|
||||||
log::trace!("Updating {identifier}'s last position to {position:?}");
|
log::trace!("Updating {identifier}'s last position to {position:?}");
|
||||||
|
|
||||||
associations.insert(identifier.clone(), (ContextData::Reserved, position));
|
associations.insert(identifier.clone(), (ContextData::Reserved, position));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn update_position_if_found(
|
fn update_position_if_found(
|
||||||
&self,
|
&self,
|
||||||
@ -474,11 +468,15 @@ impl ContextInner {
|
|||||||
|
|
||||||
*last_position = position;
|
*last_position = position;
|
||||||
|
|
||||||
Ok(true)
|
return Ok(true);
|
||||||
} else {
|
} else if let Some(parent) = &self.parent {
|
||||||
Ok(false)
|
if let Some(parent) = parent.upgrade() {
|
||||||
|
return parent.update_position_if_found(identifier, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
Loading…
Reference in New Issue
Block a user