Update tab location when drag and dropping, fixes #178
This commit is contained in:
parent
e3f0f5b776
commit
e947bee833
2 changed files with 34 additions and 22 deletions
22
src/app.rs
22
src/app.rs
|
|
@ -1630,13 +1630,21 @@ impl Application for App {
|
||||||
{
|
{
|
||||||
self.nav_dnd_hover = None;
|
self.nav_dnd_hover = None;
|
||||||
let entity = self.tab_model.active();
|
let entity = self.tab_model.active();
|
||||||
let title = location.to_string();
|
let title_opt = match self.tab_model.data_mut::<Tab>(entity) {
|
||||||
self.tab_model.text_set(entity, title);
|
Some(tab) => {
|
||||||
return Command::batch([
|
tab.change_location(&location, None);
|
||||||
self.update_title(),
|
Some(tab.title())
|
||||||
self.update_watcher(),
|
}
|
||||||
self.rescan_tab(entity, location),
|
None => None,
|
||||||
]);
|
};
|
||||||
|
if let Some(title) = title_opt {
|
||||||
|
self.tab_model.text_set(entity, title);
|
||||||
|
return Command::batch([
|
||||||
|
self.update_title(),
|
||||||
|
self.update_watcher(),
|
||||||
|
self.rescan_tab(entity, location),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::DndEnterTab(entity) => {
|
Message::DndEnterTab(entity) => {
|
||||||
|
|
|
||||||
34
src/tab.rs
34
src/tab.rs
|
|
@ -988,6 +988,24 @@ impl Tab {
|
||||||
last
|
last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn change_location(&mut self, location: &Location, history_i_opt: Option<usize>) {
|
||||||
|
self.location = location.clone();
|
||||||
|
self.items_opt = None;
|
||||||
|
self.select_focus = None;
|
||||||
|
self.edit_location = None;
|
||||||
|
if let Some(history_i) = history_i_opt {
|
||||||
|
// 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
|
||||||
|
self.history_i = self.history.len();
|
||||||
|
self.history.push(location.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, message: Message, modifiers: Modifiers) -> Vec<Command> {
|
pub fn update(&mut self, message: Message, modifiers: Modifiers) -> Vec<Command> {
|
||||||
let mut commands = Vec::new();
|
let mut commands = Vec::new();
|
||||||
let mut cd = None;
|
let mut cd = None;
|
||||||
|
|
@ -1442,21 +1460,7 @@ impl Tab {
|
||||||
Location::Path(path) => path.is_dir(),
|
Location::Path(path) => path.is_dir(),
|
||||||
Location::Trash => true,
|
Location::Trash => true,
|
||||||
} {
|
} {
|
||||||
self.location = location.clone();
|
self.change_location(&location, history_i_opt);
|
||||||
self.items_opt = None;
|
|
||||||
self.select_focus = None;
|
|
||||||
self.edit_location = None;
|
|
||||||
if let Some(history_i) = history_i_opt {
|
|
||||||
// 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
|
|
||||||
self.history_i = self.history.len();
|
|
||||||
self.history.push(location.clone());
|
|
||||||
}
|
|
||||||
commands.push(Command::ChangeLocation(self.title(), location));
|
commands.push(Command::ChangeLocation(self.title(), location));
|
||||||
} else {
|
} else {
|
||||||
log::warn!("tried to cd to {:?} which is not a directory", location);
|
log::warn!("tried to cd to {:?} which is not a directory", location);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue