
Release Notes: - Added "[ c" & "] c" To select prev/next git modified file within the project panel - Added "[ d" & "] d" To select prev/next file with diagnostics from an LSP within the project panel - Added "{" & "}" To select prev/next directory within the project panel Note: I wanted to extend project panel's functionality when netrw is active so I added some shortcuts that I believe will be helpful for most users. I tried to keep the default key mappings for the shortcuts inline with Zed's vim mode. ## Selecting prev/next modified git file https://github.com/user-attachments/assets/a9c057c7-1015-444f-b273-6d52ac54aa9c ## Selecting prev/next diagnostics https://github.com/user-attachments/assets/d1fb04ac-02c6-477c-b751-90a11bb42a78 ## Selecting prev/next directories (Only works with visible directoires) https://github.com/user-attachments/assets/9e96371e-105f-4fe9-bbf7-58f4a529f0dd
42 lines
896 B
Rust
42 lines
896 B
Rust
pub(crate) struct ReversibleIterable<It> {
|
|
pub(crate) it: It,
|
|
pub(crate) reverse: bool,
|
|
}
|
|
|
|
impl<T> ReversibleIterable<T> {
|
|
pub(crate) fn new(it: T, reverse: bool) -> Self {
|
|
Self { it, reverse }
|
|
}
|
|
}
|
|
|
|
impl<It, Item> ReversibleIterable<It>
|
|
where
|
|
It: Iterator<Item = Item>,
|
|
{
|
|
pub(crate) fn find_single_ended<F>(mut self, pred: F) -> Option<Item>
|
|
where
|
|
F: FnMut(&Item) -> bool,
|
|
{
|
|
if self.reverse {
|
|
self.it.filter(pred).last()
|
|
} else {
|
|
self.it.find(pred)
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<It, Item> ReversibleIterable<It>
|
|
where
|
|
It: DoubleEndedIterator<Item = Item>,
|
|
{
|
|
pub(crate) fn find<F>(mut self, mut pred: F) -> Option<Item>
|
|
where
|
|
F: FnMut(&Item) -> bool,
|
|
{
|
|
if self.reverse {
|
|
self.it.rfind(|x| pred(x))
|
|
} else {
|
|
self.it.find(|x| pred(x))
|
|
}
|
|
}
|
|
}
|