Handle single click to open on release, fixes #1212
This commit is contained in:
parent
f9f27765c7
commit
7d5fb79f02
1 changed files with 37 additions and 32 deletions
69
src/tab.rs
69
src/tab.rs
|
|
@ -2924,20 +2924,44 @@ impl Tab {
|
||||||
commands.push(Command::AutoScroll(auto_scroll));
|
commands.push(Command::AutoScroll(auto_scroll));
|
||||||
}
|
}
|
||||||
Message::ClickRelease(click_i_opt) => {
|
Message::ClickRelease(click_i_opt) => {
|
||||||
if click_i_opt == self.clicked.take() {
|
// Single click to open.
|
||||||
return commands;
|
if !mod_ctrl && self.config.single_click {
|
||||||
}
|
let mut paths_to_open = Vec::new();
|
||||||
self.context_menu = None;
|
if let Some(ref mut items) = self.items_opt {
|
||||||
self.location_context_menu_index = None;
|
for (i, item) in items.iter_mut().enumerate() {
|
||||||
if let Some(ref mut items) = self.items_opt {
|
if Some(i) == click_i_opt {
|
||||||
for (i, item) in items.iter_mut().enumerate() {
|
if let Some(location) = &item.location_opt {
|
||||||
if mod_ctrl {
|
if item.metadata.is_dir() {
|
||||||
if Some(i) == click_i_opt && item.selected {
|
cd = Some(location.clone());
|
||||||
item.selected = false;
|
} else if let Some(path) = location.path_opt() {
|
||||||
self.select_range = None;
|
paths_to_open.push(path.to_path_buf());
|
||||||
|
} else {
|
||||||
|
log::warn!("no path for item {:?}", item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("no location for item {:?}", item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !paths_to_open.is_empty() {
|
||||||
|
commands.push(Command::OpenFile(paths_to_open));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if click_i_opt != self.clicked.take() {
|
||||||
|
self.context_menu = None;
|
||||||
|
self.location_context_menu_index = None;
|
||||||
|
if let Some(ref mut items) = self.items_opt {
|
||||||
|
for (i, item) in items.iter_mut().enumerate() {
|
||||||
|
if mod_ctrl {
|
||||||
|
if Some(i) == click_i_opt && item.selected {
|
||||||
|
item.selected = false;
|
||||||
|
self.select_range = None;
|
||||||
|
}
|
||||||
|
} else if Some(i) != click_i_opt {
|
||||||
|
item.selected = false;
|
||||||
}
|
}
|
||||||
} else if Some(i) != click_i_opt {
|
|
||||||
item.selected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3062,24 +3086,8 @@ impl Tab {
|
||||||
.any(|(e_i, e)| Some(e_i) == click_i_opt.as_ref() && e.selected)
|
.any(|(e_i, e)| Some(e_i) == click_i_opt.as_ref() && e.selected)
|
||||||
});
|
});
|
||||||
if let Some(ref mut items) = self.items_opt {
|
if let Some(ref mut items) = self.items_opt {
|
||||||
let mut paths_to_open = vec![];
|
|
||||||
for (i, item) in items.iter_mut().enumerate() {
|
for (i, item) in items.iter_mut().enumerate() {
|
||||||
if Some(i) == click_i_opt {
|
if Some(i) == click_i_opt {
|
||||||
// Single click to open.
|
|
||||||
if !mod_ctrl && self.config.single_click {
|
|
||||||
if let Some(location) = &item.location_opt {
|
|
||||||
if item.metadata.is_dir() {
|
|
||||||
cd = Some(location.clone());
|
|
||||||
} else if let Some(path) = location.path_opt() {
|
|
||||||
paths_to_open.push(path.to_path_buf());
|
|
||||||
} else {
|
|
||||||
log::warn!("no path for item {:?}", item);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log::warn!("no location for item {:?}", item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter out selection if it does not match dialog kind
|
// Filter out selection if it does not match dialog kind
|
||||||
if let Mode::Dialog(dialog) = &self.mode {
|
if let Mode::Dialog(dialog) = &self.mode {
|
||||||
let item_is_dir = item.metadata.is_dir();
|
let item_is_dir = item.metadata.is_dir();
|
||||||
|
|
@ -3104,9 +3112,6 @@ impl Tab {
|
||||||
item.selected = false;
|
item.selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !paths_to_open.is_empty() {
|
|
||||||
commands.push(Command::OpenFile(paths_to_open));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue