Compact consecutive search locations in history, fixes #759
This commit is contained in:
parent
f95762bd44
commit
2228ea35ea
1 changed files with 16 additions and 0 deletions
16
src/tab.rs
16
src/tab.rs
|
|
@ -2208,6 +2208,7 @@ impl Tab {
|
|||
}
|
||||
|
||||
pub fn change_location(&mut self, location: &Location, history_i_opt: Option<usize>) {
|
||||
println!("change_location {:?}", location);
|
||||
self.location = location.normalize();
|
||||
self.context_menu = None;
|
||||
self.edit_location = None;
|
||||
|
|
@ -2223,6 +2224,21 @@ impl Tab {
|
|||
// Truncate history to remove next entries
|
||||
self.history.truncate(self.history_i + 1);
|
||||
|
||||
// Compact consecutive search locations
|
||||
{
|
||||
let mut remove = false;
|
||||
if let Some(last_location) = self.history.last() {
|
||||
if let Location::Search(last_path, ..) = last_location {
|
||||
if let Location::Search(path, ..) = location {
|
||||
remove = last_path == path;
|
||||
}
|
||||
}
|
||||
}
|
||||
if remove {
|
||||
self.history.pop();
|
||||
}
|
||||
}
|
||||
|
||||
// Push to the front of history
|
||||
self.history_i = self.history.len();
|
||||
self.history.push(location.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue