mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 08:35:28 +00:00
try few search scenarios on result fail
This commit is contained in:
parent
36568004e8
commit
9612c988cc
1 changed files with 19 additions and 14 deletions
|
|
@ -329,12 +329,10 @@ impl Markdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
|
fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
|
||||||
let query = uri_unescape_string(&fragment, None::<&str>)
|
fn try_scroll(text_view: &TextView, query: &str) -> bool {
|
||||||
.unwrap_or(fragment)
|
|
||||||
.replace("-", " ");
|
|
||||||
let mut cursor = text_view.buffer().start_iter();
|
let mut cursor = text_view.buffer().start_iter();
|
||||||
while let Some((mut match_start, match_end)) =
|
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
|
if match_start
|
||||||
.tags()
|
.tags()
|
||||||
|
|
@ -347,6 +345,13 @@ fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
|
||||||
}
|
}
|
||||||
false
|
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 {
|
fn is_internal_link(request: &str) -> bool {
|
||||||
// schemes
|
// schemes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue