mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +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 {
|
||||
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()
|
||||
|
|
@ -346,6 +344,13 @@ fn scroll_to_anchor(text_view: &TextView, fragment: GString) -> bool {
|
|||
cursor = match_end;
|
||||
}
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue