try few search scenarios on result fail

This commit is contained in:
yggverse 2026-03-10 04:18:17 +02:00
parent 36568004e8
commit 9612c988cc

View file

@ -329,12 +329,10 @@ impl Markdown {
}
fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
let query = uri_unescape_string(&fragment, None::<&str>)
.unwrap_or(fragment)
.replace("-", " ");
fn try_scroll(text_view: &TextView, query: &str) -> bool {
let mut cursor = text_view.buffer().start_iter();
while let Some((mut match_start, match_end)) =
cursor.forward_search(&query, TextSearchFlags::CASE_INSENSITIVE, None)
cursor.forward_search(query, TextSearchFlags::CASE_INSENSITIVE, None)
{
if match_start
.tags()
@ -347,6 +345,13 @@ fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
}
false
}
let query = uri_unescape_string(&fragment, None::<&str>).unwrap_or(fragment);
let result = try_scroll(text_view, &query); // exact match
if !result {
return try_scroll(text_view, &query.replace("-", " ")); // unstable @TODO
}
result
}
fn is_internal_link(request: &str) -> bool {
// schemes