mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
fix navigation index offset
This commit is contained in:
parent
45276dd304
commit
04eaa1c3fd
1 changed files with 8 additions and 3 deletions
|
|
@ -66,13 +66,18 @@ impl History {
|
||||||
pub fn add(&self, request: GString, follow_to_index: bool) {
|
pub fn add(&self, request: GString, follow_to_index: bool) {
|
||||||
// Append new Memory record
|
// Append new Memory record
|
||||||
self.memory.borrow_mut().push(Memory {
|
self.memory.borrow_mut().push(Memory {
|
||||||
request,
|
request: request.clone(),
|
||||||
//time: SystemTime::now(),
|
//time: SystemTime::now(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if follow_to_index {
|
if follow_to_index {
|
||||||
// Navigate to the last record appended
|
// Even push action make positive len value, make sure twice
|
||||||
self.index.replace(Some(self.memory.borrow().len()));
|
if !self.memory.borrow().is_empty() {
|
||||||
|
// Navigate to the last record appended
|
||||||
|
self.index.replace(Some(self.memory.borrow().len() - 1));
|
||||||
|
} else {
|
||||||
|
self.index.replace(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue