summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-06-17 18:16:41 +0200
committerGitHub <noreply@github.com>2023-06-17 18:16:41 +0200
commit805fd1dc8184154bb7c5bc24db7b20c06fc47cad (patch)
tree164effb6ba747528be14c63f556bf88a13d9c4b3
parent29a391f60eb3aeecba4682dfdb38cdcd2a61b2b2 (diff)
feat(plugins): strider improvements (#2551)
* fix(plugins): adjust debounce and smart file ignore in strider * style(comment): remove commented code * style(fmt): rustfmt
-rw-r--r--Cargo.lock53
-rw-r--r--default-plugins/strider/Cargo.toml2
-rw-r--r--default-plugins/strider/src/search/mod.rs14
-rw-r--r--zellij-server/src/plugins/watch_filesystem.rs2
4 files changed, 59 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 535879b8d..cf4b40bd7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -30,6 +30,15 @@ dependencies = [
[[package]]
name = "aho-corasick"
+version = "0.7.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "aho-corasick"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
@@ -325,6 +334,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5988cb1d626264ac94100be357308f29ff7cbdd3b36bda27f450a4ee3f713426"
[[package]]
+name = "bstr"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
+dependencies = [
+ "memchr",
+ "serde",
+]
+
+[[package]]
name = "bumpalo"
version = "3.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1210,6 +1229,19 @@ dependencies = [
]
[[package]]
+name = "globset"
+version = "0.4.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
+dependencies = [
+ "aho-corasick 0.7.20",
+ "bstr",
+ "fnv",
+ "log",
+ "regex",
+]
+
+[[package]]
name = "gloo-timers"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1305,6 +1337,23 @@ dependencies = [
]
[[package]]
+name = "ignore"
+version = "0.4.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"
+dependencies = [
+ "globset",
+ "lazy_static",
+ "log",
+ "memchr",
+ "regex",
+ "same-file",
+ "thread_local",
+ "walkdir",
+ "winapi-util",
+]
+
+[[package]]
name = "indexmap"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2439,7 +2488,7 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
dependencies = [
- "aho-corasick",
+ "aho-corasick 1.0.1",
"memchr",
"regex-syntax",
]
@@ -2956,12 +3005,12 @@ dependencies = [
"ansi_term",
"colored",
"fuzzy-matcher",
+ "ignore",
"pretty-bytes",
"serde",
"serde_json",
"strip-ansi-escapes",
"unicode-width",
- "walkdir",
"zellij-tile",
]
diff --git a/default-plugins/strider/Cargo.toml b/default-plugins/strider/Cargo.toml
index 65b5d23e9..33cf4ca5f 100644
--- a/default-plugins/strider/Cargo.toml
+++ b/default-plugins/strider/Cargo.toml
@@ -10,7 +10,7 @@ license = "MIT"
colored = "2.0.0"
zellij-tile = { path = "../../zellij-tile" }
pretty-bytes = "0.2.2"
-walkdir = "2.3.3"
+ignore = "0.4.20"
fuzzy-matcher = "0.3.7"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/default-plugins/strider/src/search/mod.rs b/default-plugins/strider/src/search/mod.rs
index 1a9db2dad..33c8a60b0 100644
--- a/default-plugins/strider/src/search/mod.rs
+++ b/default-plugins/strider/src/search/mod.rs
@@ -15,9 +15,9 @@ use zellij_tile::prelude::*;
use fuzzy_matcher::skim::SkimMatcherV2;
use fuzzy_matcher::FuzzyMatcher;
+use ignore::Walk;
use search_results::SearchResult;
use serde::{Deserialize, Serialize};
-use walkdir::WalkDir;
use std::io::{self, BufRead};
@@ -64,8 +64,10 @@ impl Search {
}
}
pub fn scan_hd(&mut self) {
- for entry in WalkDir::new(ROOT).into_iter().filter_map(|e| e.ok()) {
- self.add_file_entry(entry.path(), entry.metadata().ok());
+ for result in Walk::new(ROOT) {
+ if let Ok(entry) = result {
+ self.add_file_entry(entry.path(), entry.metadata().ok());
+ }
}
}
pub fn search(&mut self, search_term: String) {
@@ -160,11 +162,7 @@ impl Search {
match line {
Ok(line) => {
self.file_contents.insert(
- (
- // String::from_utf8_lossy(&strip_ansi_escapes::strip(file_path_stripped_prefix.clone()).unwrap()).to_string(),
- file_path_stripped_prefix.clone(),
- index + 1,
- ),
+ (file_path_stripped_prefix.clone(), index + 1),
String::from_utf8_lossy(
&strip_ansi_escapes::strip(line).unwrap(),
)
diff --git a/zellij-server/src/plugins/watch_filesystem.rs b/zellij-server/src/plugins/watch_filesystem.rs
index 9ac0a320c..36c0e04d5 100644
--- a/zellij-server/src/plugins/watch_filesystem.rs
+++ b/zellij-server/src/plugins/watch_filesystem.rs
@@ -12,7 +12,7 @@ use zellij_utils::notify_debouncer_full::{
};
use zellij_utils::{data::Event, errors::prelude::Result};
-const DEBOUNCE_DURATION_MS: u64 = 500;
+const DEBOUNCE_DURATION_MS: u64 = 400;
pub fn watch_filesystem(
senders: ThreadSenders,