Gracefully handle models searching for empty glob (#27370)
Sometimes we've seen models provide an empty string for the path search glob. This assumes they meant "*" when that happens. Separately, this also removes an unnecessary `clone` of a `String`. Release Notes: - N/A
This commit is contained in:
parent
430814c0a9
commit
6b7167a32d
3 changed files with 11 additions and 6 deletions
|
@ -71,7 +71,11 @@ impl Tool for PathSearchTool {
|
|||
Ok(input) => (input.offset.unwrap_or(0), input.glob),
|
||||
Err(err) => return Task::ready(Err(anyhow!(err))),
|
||||
};
|
||||
let path_matcher = match PathMatcher::new(&[glob.clone()]) {
|
||||
|
||||
let path_matcher = match PathMatcher::new([
|
||||
// Sometimes models try to search for "". In this case, return all paths in the project.
|
||||
if glob.is_empty() { "*" } else { &glob },
|
||||
]) {
|
||||
Ok(matcher) => matcher,
|
||||
Err(err) => return Task::ready(Err(anyhow!("Invalid glob: {err}"))),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue