mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
fix follow_to_index exception
This commit is contained in:
parent
30142cf5e0
commit
2a535c7c60
1 changed files with 16 additions and 11 deletions
|
|
@ -23,24 +23,29 @@ impl Memory {
|
||||||
|
|
||||||
/// Create new record in the navigation memory
|
/// Create new record in the navigation memory
|
||||||
pub fn add(&self, value: GString, follow_to_index: bool) {
|
pub fn add(&self, value: GString, follow_to_index: bool) {
|
||||||
|
// borrow subject in r/w mode
|
||||||
|
let mut index = self.index.borrow_mut();
|
||||||
|
|
||||||
if follow_to_index {
|
if follow_to_index {
|
||||||
// request index recording
|
|
||||||
let mut index = self.index.borrow_mut();
|
|
||||||
// drop forward history if the user continue navigation
|
// drop forward history if the user continue navigation
|
||||||
// from the previous history position
|
// from the previous history position
|
||||||
if let Some(next) = self.cursor.borrow().next(index.len()) {
|
if let Some(next) = self.cursor.borrow_mut().next(index.len()) {
|
||||||
index.truncate(next);
|
index.truncate(next);
|
||||||
}
|
}
|
||||||
// prevent duplicates at the last history position
|
}
|
||||||
// e.g. on page reload with `follow_to_index` enabled
|
|
||||||
match index.last() {
|
// prevent duplicates at the last history position
|
||||||
Some(last) => {
|
// e.g. on page reload with `follow_to_index` enabled
|
||||||
if *last != value {
|
match index.last() {
|
||||||
index.push(value);
|
Some(last) => {
|
||||||
}
|
if *last != value {
|
||||||
|
index.push(value);
|
||||||
}
|
}
|
||||||
None => index.push(value),
|
|
||||||
}
|
}
|
||||||
|
None => index.push(value),
|
||||||
|
}
|
||||||
|
|
||||||
|
if follow_to_index {
|
||||||
// set cursor on to the last record
|
// set cursor on to the last record
|
||||||
self.cursor.borrow_mut().go_last(index.len());
|
self.cursor.borrow_mut().go_last(index.len());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue