This commit is contained in:
pap
2025-07-30 18:06:11 +01:00
parent f78f8d8c7c
commit 34edf573d7
3 changed files with 11 additions and 5 deletions

View File

@@ -51,9 +51,15 @@ fn strip_surrounding_quotes(s: &str) -> String {
return trimmed.to_string();
}
let mut chars = trimmed.chars();
let first = chars.next().unwrap();
let last = trimmed.chars().last().unwrap();
// Safely obtain the first and last characters without unwraps.
let (first, last) = {
let mut chs = trimmed.chars();
match (chs.next(), chs.next_back()) {
(Some(f), Some(l)) => (f, l),
(Some(f), None) => (f, f),
_ => return trimmed.to_string(),
}
};
let is_valid_quote = match first {
'"' | '\'' | '“' | '' => first == last,

View File

@@ -203,7 +203,7 @@ fn fuzzy_match(haystack: &str, needle: &str) -> Option<(Vec<usize>, i32)> {
for ch in n_lower.chars() {
let mut found = None;
while let Some((i, hc)) = h_iter.next() {
for (i, hc) in h_iter.by_ref() {
if hc == ch {
found = Some(i);
break;

View File

@@ -531,7 +531,7 @@ impl ChatWidget<'_> {
// Emit a lightweight event in the conversation log so the change is visible.
if changed {
self.conversation_history
.add_background_event(format!("Set model to {}.", model));
.add_background_event(format!("Set model to {model}."));
self.emit_last_history_entry();
}