feat: open multiple dirs in separate tabs
This commit is contained in:
parent
77f33c0acc
commit
03c5124859
1 changed files with 68 additions and 15 deletions
83
src/tab.rs
83
src/tab.rs
|
|
@ -3785,24 +3785,77 @@ impl Tab {
|
||||||
commands.push(Command::OpenFile(vec![path]));
|
commands.push(Command::OpenFile(vec![path]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Open selected items
|
||||||
None => {
|
None => {
|
||||||
if let Some(ref mut items) = self.items_opt {
|
enum ResolveResult {
|
||||||
let mut open_files = Vec::new();
|
Open(Option<PathBuf>),
|
||||||
for item in items.iter() {
|
OpenInTab(Option<PathBuf>),
|
||||||
if item.selected {
|
OpenTrash,
|
||||||
if let Some(location) = &item.location_opt {
|
OpenProperties,
|
||||||
if item.metadata.is_dir() {
|
Cd(Location),
|
||||||
//TODO: allow opening multiple tabs?
|
Skip,
|
||||||
cd = Some(location.clone());
|
}
|
||||||
} else if let Some(path) = location.path_opt() {
|
fn resolve_item(
|
||||||
open_files.push(path.clone());
|
item: &Item,
|
||||||
}
|
mode: &Mode,
|
||||||
} else {
|
is_only_one_selected: bool,
|
||||||
//TODO: open properties?
|
) -> ResolveResult {
|
||||||
}
|
if !item.selected {
|
||||||
}
|
return ResolveResult::Skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let location = match &item.location_opt {
|
||||||
|
Some(l) => l,
|
||||||
|
None => return ResolveResult::OpenProperties,
|
||||||
|
};
|
||||||
|
|
||||||
|
let path_opt = location.path_opt();
|
||||||
|
|
||||||
|
if item.metadata.is_dir() {
|
||||||
|
match mode {
|
||||||
|
Mode::App => {
|
||||||
|
if is_only_one_selected {
|
||||||
|
return ResolveResult::Cd(location.clone());
|
||||||
|
} else {
|
||||||
|
return ResolveResult::OpenInTab(path_opt.cloned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mode::Desktop => {
|
||||||
|
return match location {
|
||||||
|
Location::Trash => ResolveResult::OpenTrash,
|
||||||
|
_ => ResolveResult::Open(path_opt.cloned()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Mode::Dialog(_) => {
|
||||||
|
if is_only_one_selected {
|
||||||
|
return ResolveResult::Cd(location.clone());
|
||||||
|
} else {
|
||||||
|
return ResolveResult::Skip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ResolveResult::Open(path_opt.cloned());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut open_files = Vec::new();
|
||||||
|
if let Some(items) = self.items_opt.as_ref() {
|
||||||
|
let selected_count = items.iter().filter(|i| i.selected).count();
|
||||||
|
|
||||||
|
for item in items.iter() {
|
||||||
|
match resolve_item(item, &self.mode, selected_count == 1) {
|
||||||
|
ResolveResult::Open(Some(p)) => open_files.push(p),
|
||||||
|
ResolveResult::OpenInTab(Some(p)) => {
|
||||||
|
commands.push(Command::OpenInNewTab(p))
|
||||||
|
}
|
||||||
|
ResolveResult::Cd(loc) => cd = Some(loc),
|
||||||
|
ResolveResult::OpenTrash => commands.push(Command::OpenTrash),
|
||||||
|
ResolveResult::OpenProperties => {} //TODO: open properties?
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !open_files.is_empty() {
|
||||||
commands.push(Command::OpenFile(open_files));
|
commands.push(Command::OpenFile(open_files));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue