mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 07:35:10 +01:00
fix: panic without in path without "/"
This commit is contained in:
parent
23b01c4775
commit
f17e4c4ce2
1 changed files with 5 additions and 4 deletions
|
|
@ -117,7 +117,6 @@ fn eval_suggest(suggest: &str, last_command: &str) -> String {
|
||||||
if suggest.contains("{{command}}") {
|
if suggest.contains("{{command}}") {
|
||||||
suggest = suggest.replace("{{command}}", last_command);
|
suggest = suggest.replace("{{command}}", last_command);
|
||||||
}
|
}
|
||||||
println!("eval suggest: {}", suggest);
|
|
||||||
while suggest.contains("{{command") {
|
while suggest.contains("{{command") {
|
||||||
let placeholder_start = "{{command";
|
let placeholder_start = "{{command";
|
||||||
let placeholder_end = "}}";
|
let placeholder_end = "}}";
|
||||||
|
|
@ -155,7 +154,6 @@ fn eval_suggest(suggest: &str, last_command: &str) -> String {
|
||||||
suggest = suggest.replace(&suggest[start_index..end_index], &command);
|
suggest = suggest.replace(&suggest[start_index..end_index], &command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("eval suggest: {}", suggest);
|
|
||||||
|
|
||||||
while suggest.contains("{{typo") {
|
while suggest.contains("{{typo") {
|
||||||
let placeholder_start = "{{typo";
|
let placeholder_start = "{{typo";
|
||||||
|
|
@ -198,7 +196,6 @@ fn eval_suggest(suggest: &str, last_command: &str) -> String {
|
||||||
|
|
||||||
suggest = suggest.replace(&suggest[start_index..end_index], &suggestion);
|
suggest = suggest.replace(&suggest[start_index..end_index], &suggestion);
|
||||||
}
|
}
|
||||||
println!("eval suggest: {}", suggest);
|
|
||||||
|
|
||||||
suggest
|
suggest
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +261,11 @@ fn get_directory_files(input: &str) -> Vec<String> {
|
||||||
match std::fs::read_dir(&input) {
|
match std::fs::read_dir(&input) {
|
||||||
Ok(files) => break files,
|
Ok(files) => break files,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
input = input.rsplit('/').nth(1).unwrap().to_owned();
|
if let Some((dirs, _)) = input.rsplit_once('/') {
|
||||||
|
input = dirs.to_owned();
|
||||||
|
} else {
|
||||||
|
break std::fs::read_dir("./").unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue