Do not cd to path that is not a directory, fixes #87
This commit is contained in:
parent
af4828a509
commit
d15372a635
1 changed files with 21 additions and 14 deletions
35
src/tab.rs
35
src/tab.rs
|
|
@ -1233,22 +1233,29 @@ impl Tab {
|
||||||
}
|
}
|
||||||
if let Some(location) = cd {
|
if let Some(location) = cd {
|
||||||
if location != self.location {
|
if location != self.location {
|
||||||
self.location = location.clone();
|
if match &location {
|
||||||
self.items_opt = None;
|
Location::Path(path) => path.is_dir(),
|
||||||
self.select_focus = None;
|
Location::Trash => true,
|
||||||
self.edit_location = None;
|
} {
|
||||||
if let Some(history_i) = history_i_opt {
|
self.location = location.clone();
|
||||||
// Navigating in history
|
self.items_opt = None;
|
||||||
self.history_i = history_i;
|
self.select_focus = None;
|
||||||
} else {
|
self.edit_location = None;
|
||||||
// Truncate history to remove next entries
|
if let Some(history_i) = history_i_opt {
|
||||||
self.history.truncate(self.history_i + 1);
|
// Navigating in history
|
||||||
|
self.history_i = history_i;
|
||||||
|
} else {
|
||||||
|
// Truncate history to remove next entries
|
||||||
|
self.history.truncate(self.history_i + 1);
|
||||||
|
|
||||||
// Push to the front of history
|
// Push to the front of history
|
||||||
self.history_i = self.history.len();
|
self.history_i = self.history.len();
|
||||||
self.history.push(location.clone());
|
self.history.push(location.clone());
|
||||||
|
}
|
||||||
|
commands.push(Command::ChangeLocation(self.title(), location));
|
||||||
|
} else {
|
||||||
|
log::warn!("tried to cd to {:?} which is not a directory", location);
|
||||||
}
|
}
|
||||||
commands.push(Command::ChangeLocation(self.title(), location));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commands
|
commands
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue