listing: do not clear selection after action
Clear selection only when Escape is pressed, not after action is completed. The user might want to perform further actions on the selection. Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
parent
7952006870
commit
61a0c3c27f
|
@ -467,6 +467,9 @@ you can use the following commands on entries and selections to modify them:
|
|||
and
|
||||
.Ic ignore_tags
|
||||
for how to set tag colors and tag visibility)
|
||||
You can clear the selection with the
|
||||
.Aq Esc
|
||||
key.
|
||||
.Sh PAGER
|
||||
You can open an e-mail entry by pressing
|
||||
.ShortcutPeriod Enter listing open_entry
|
||||
|
|
|
@ -1661,14 +1661,21 @@ impl Component for Listing {
|
|||
| Action::Listing(a @ ListingAction::Tag(_)) => {
|
||||
let focused = self.component.get_focused_items(context);
|
||||
self.component.perform_action(context, focused, a);
|
||||
let should_be_unselected: bool = matches!(
|
||||
a,
|
||||
ListingAction::Delete
|
||||
| ListingAction::MoveTo(_)
|
||||
| ListingAction::MoveToOtherAccount(_, _)
|
||||
);
|
||||
let mut row_updates: SmallVec<[EnvelopeHash; 8]> = SmallVec::new();
|
||||
for (k, v) in self.component.selection().iter_mut() {
|
||||
if *v {
|
||||
*v = false;
|
||||
*v = !should_be_unselected;
|
||||
row_updates.push(*k);
|
||||
}
|
||||
}
|
||||
self.component.row_updates().extend(row_updates);
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
@ -1867,6 +1874,7 @@ impl Component for Listing {
|
|||
&& self.component.modifier_command().is_some() =>
|
||||
{
|
||||
self.component.set_modifier_command(Some(Modifier::Union));
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(ref key)
|
||||
if !self.component.unfocused()
|
||||
|
@ -1875,6 +1883,7 @@ impl Component for Listing {
|
|||
{
|
||||
self.component
|
||||
.set_modifier_command(Some(Modifier::Difference));
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(ref key)
|
||||
if !self.component.unfocused()
|
||||
|
@ -1885,12 +1894,14 @@ impl Component for Listing {
|
|||
{
|
||||
self.component
|
||||
.set_modifier_command(Some(Modifier::Intersection));
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(ref key)
|
||||
if self.component.unfocused()
|
||||
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["next_entry"]) =>
|
||||
{
|
||||
self.component.next_entry(context);
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(ref key)
|
||||
if self.component.unfocused()
|
||||
|
@ -1899,9 +1910,26 @@ impl Component for Listing {
|
|||
) =>
|
||||
{
|
||||
self.component.prev_entry(context);
|
||||
return true;
|
||||
}
|
||||
_ => {}
|
||||
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt(''))
|
||||
if !self.component.unfocused() =>
|
||||
{
|
||||
// Clear selection.
|
||||
let row_updates: SmallVec<[EnvelopeHash; 8]> =
|
||||
self.component.get_focused_items(context);
|
||||
for h in &row_updates {
|
||||
if let Some(val) = self.component.selection().get_mut(h) {
|
||||
*val = false;
|
||||
}
|
||||
}
|
||||
self.component.row_updates().extend(row_updates);
|
||||
self.component.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
_ => return false,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if self.focus == ListingFocus::Menu {
|
||||
match *event {
|
||||
|
|
|
@ -2019,21 +2019,6 @@ impl Component for CompactListing {
|
|||
UIEvent::Resize => {
|
||||
self.set_dirty(true);
|
||||
}
|
||||
UIEvent::Input(Key::Esc)
|
||||
if !self.unfocused()
|
||||
&& self
|
||||
.rows
|
||||
.selection
|
||||
.values()
|
||||
.cloned()
|
||||
.any(std::convert::identity) =>
|
||||
{
|
||||
for v in self.rows.selection.values_mut() {
|
||||
*v = false;
|
||||
}
|
||||
self.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(Key::Esc) if !self.unfocused() && !self.filter_term.is_empty() => {
|
||||
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
|
||||
self.refresh_mailbox(context, false);
|
||||
|
|
|
@ -1468,19 +1468,6 @@ impl Component for ConversationsListing {
|
|||
}
|
||||
_ => {}
|
||||
},
|
||||
UIEvent::Input(Key::Esc)
|
||||
if !self.unfocused()
|
||||
&& self
|
||||
.rows
|
||||
.selection
|
||||
.values()
|
||||
.cloned()
|
||||
.any(std::convert::identity) =>
|
||||
{
|
||||
self.rows.clear_selection();
|
||||
self.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Char(''))
|
||||
if !self.unfocused() && !&self.filter_term.is_empty() =>
|
||||
{
|
||||
|
|
|
@ -1718,19 +1718,6 @@ impl Component for PlainListing {
|
|||
UIEvent::Resize => {
|
||||
self.set_dirty(true);
|
||||
}
|
||||
UIEvent::Input(Key::Esc)
|
||||
if !self.unfocused()
|
||||
&& self
|
||||
.rows
|
||||
.selection
|
||||
.values()
|
||||
.cloned()
|
||||
.any(std::convert::identity) =>
|
||||
{
|
||||
self.rows.clear_selection();
|
||||
self.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(Key::Esc) if !self.unfocused() && !self.filter_term.is_empty() => {
|
||||
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
|
||||
self.set_dirty(true);
|
||||
|
|
|
@ -1585,21 +1585,6 @@ impl Component for ThreadListing {
|
|||
UIEvent::Resize => {
|
||||
self.set_dirty(true);
|
||||
}
|
||||
UIEvent::Input(Key::Esc)
|
||||
if !self.unfocused()
|
||||
&& self
|
||||
.rows
|
||||
.selection
|
||||
.values()
|
||||
.cloned()
|
||||
.any(std::convert::identity) =>
|
||||
{
|
||||
for v in self.rows.selection.values_mut() {
|
||||
*v = false;
|
||||
}
|
||||
self.set_dirty(true);
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(ref key)
|
||||
if !self.unfocused()
|
||||
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["select_entry"]) =>
|
||||
|
|
Loading…
Reference in New Issue