Fix clear selection for selection editor

pull/583/head
Arijit Basu 1 year ago
parent 42618ad463
commit 0e43198093

@ -1338,21 +1338,12 @@ impl App {
pub fn select_all(mut self) -> Result<Self> {
if let Some(d) = self.directory_buffer.as_ref() {
d.nodes.clone().into_iter().for_each(|n| {
self.selection.insert(n);
});
self.selection = d.nodes.clone().into_iter().collect();
};
Ok(self)
}
pub fn un_select(mut self) -> Result<Self> {
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
self.selection.retain(|s| s != &n);
}
Ok(self)
}
pub fn un_select_path(mut self, path: String) -> Result<Self> {
let pathbuf = PathBuf::from(path).absolutize()?.to_path_buf();
self.selection
@ -1360,10 +1351,19 @@ impl App {
Ok(self)
}
pub fn un_select(mut self) -> Result<Self> {
if let Some(n) = self.focused_node().map(|n| n.to_owned()) {
self.selection
.retain(|s| s.absolute_path != n.absolute_path);
}
Ok(self)
}
pub fn un_select_all(mut self) -> Result<Self> {
if let Some(d) = self.directory_buffer.as_ref() {
d.nodes.clone().into_iter().for_each(|n| {
self.selection.retain(|s| s != &n);
self.selection
.retain(|s| s.absolute_path != n.absolute_path);
});
};

@ -1427,7 +1427,7 @@ xplr.config.modes.builtin.selection_ops = {
done < "${XPLR_PIPE_SELECTION_OUT:?}")
${EDITOR:-vi} "${TMPFILE:?}"
[ ! -e "$TMPFILE" ] && exit
"$XPLR" -m UnSelectAll
"$XPLR" -m ClearSelection
(while IFS= read -r PTH_ESC; do
"$XPLR" -m 'SelectPath: %q' "$(eval printf %s ${PTH_ESC:?})"
done < "${TMPFILE:?}")

Loading…
Cancel
Save