helix-editor/helix · warning
Failed to compile regex
Error message
Failed to compile regex
What it means
The workspace symbol picker builds a matcher from the typed pattern via state.regex_matcher_builder (the regex crate). Patterns that are not valid regex — unbalanced groups, dangling quantifiers, unsupported look-around — abort the search with 'Failed to compile regex'; the underlying compile error is logged at info level, and a later successful compile clears the stale statusline error.
Source
Thrown at helix-term/src/commands/syntax.rs:344
}
}
}
if !state.search_root.exists() {
return async { Err(anyhow::anyhow!("Current working directory does not exist")) }
.boxed();
}
let matcher = match state.regex_matcher_builder.build(query) {
Ok(matcher) => {
// Clear any "Failed to compile regex" errors out of the statusline.
editor.clear_status();
matcher
}
Err(err) => {
log::info!(
"Failed to compile search pattern in workspace symbol search: {}",
err
);
return async { Err(anyhow::anyhow!("Failed to compile regex")) }.boxed();
}
};
let pattern = Arc::new(pattern);
let injector = injector.clone();
let loader = editor.syn_loader.load();
let documents: HashSet<_> = editor
.documents()
.filter_map(Document::path)
.map(ToOwned::to_owned)
.collect();
async move {
let searcher = state.searcher_builder.build();
state.walk_builder.build_parallel().run(|| {
let mut searcher = searcher.clone();
let matcher = matcher.clone();
let injector = injector.clone();View on GitHub (pinned to 079a789e8c)
Solutions
- Escape metacharacters: 'Vec\<T\>', 'operator\(\)'.
- Remove unsupported constructs (look-around, backreferences) — regex cannot compile them.
- Type a simpler metacharacter-free prefix first, then refine.
Example fix
# before Vec<T> # after Vec\<T\>
Defensive patterns
Strategy: validation
Validate before calling
if regex::Regex::new(pattern).is_ok() {
// safe to submit to the workspace symbol prompt
} Type guard
fn is_valid_symbol_regex(p: &str) -> bool {
regex::Regex::new(p).is_ok()
} Prevention
- Escape <, >, (, ) when searching generic symbols; the prompt is a regex.
- Type plain prefixes first and add structure only after the query compiles.
When it happens
Trigger: Typing '(', '(?<=x)', '*sym', or '[a-' into the workspace symbol prompt while it dynamically re-filters.
Common situations: Symbol names containing regex metacharacters (generics like 'Vec<T>', 'operator()'); PCRE-style look-around habits; mid-typing states.
Related errors
AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16).
Data as JSON: /api/errors/f665737f5d3a3907.
Report an issue: GitHub.