mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
parent
df1bf4a042
commit
066f97d855
@ -659,9 +659,18 @@ impl Tokens {
|
|||||||
for pat in patterns {
|
for pat in patterns {
|
||||||
let mut altre = String::new();
|
let mut altre = String::new();
|
||||||
self.tokens_to_regex(options, &pat, &mut altre);
|
self.tokens_to_regex(options, &pat, &mut altre);
|
||||||
parts.push(altre);
|
if !altre.is_empty() {
|
||||||
|
parts.push(altre);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is possible to have an empty set in which case the
|
||||||
|
// resulting alternation '()' would be an error.
|
||||||
|
if !parts.is_empty() {
|
||||||
|
re.push('(');
|
||||||
|
re.push_str(&parts.join("|"));
|
||||||
|
re.push(')');
|
||||||
}
|
}
|
||||||
re.push_str(&parts.join("|"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1326,6 +1326,27 @@ fn regression_270() {
|
|||||||
assert_eq!(lines, path("foo:-test\n"));
|
assert_eq!(lines, path("foo:-test\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See: https://github.com/BurntSushi/ripgrep/issues/391
|
||||||
|
#[test]
|
||||||
|
fn regression_391() {
|
||||||
|
let wd = WorkDir::new("regression_391");
|
||||||
|
wd.create_dir(".git");
|
||||||
|
wd.create("lock", "");
|
||||||
|
wd.create("bar.py", "");
|
||||||
|
wd.create(".git/packed-refs", "");
|
||||||
|
wd.create(".git/description", "");
|
||||||
|
|
||||||
|
let mut cmd = wd.command();
|
||||||
|
cmd.arg("--no-ignore").arg("--hidden").arg("--follow").arg("--files")
|
||||||
|
.arg("--glob")
|
||||||
|
.arg("!{.git,node_modules,plugged}/**")
|
||||||
|
.arg("--glob")
|
||||||
|
.arg("*.{js,json,php,md,styl,scss,sass,pug,html,config,py,cpp,c,go,hs}");
|
||||||
|
|
||||||
|
let lines: String = wd.stdout(&mut cmd);
|
||||||
|
assert_eq!(lines, "bar.py\n");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn type_list() {
|
fn type_list() {
|
||||||
let wd = WorkDir::new("type_list");
|
let wd = WorkDir::new("type_list");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user