Merge pull request #716 from bu5hm4nn/fix/do-tag-replacements-only-once-per-tag

Tagging: Do tag replacements only once per tag
This commit is contained in:
Michael Dilger 2024-04-16 13:23:57 +12:00 committed by GitHub
commit a72cea172c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -798,6 +798,7 @@ fn calc_tag_hovers(ui: &mut Ui, app: &mut GossipUi, output: &TextEditOutput) {
);
hovers.insert(popup_id, popup);
break; // only one popup per tag, first match wins
}
}
}
@ -862,7 +863,7 @@ fn do_replacements(draft: &str, replacements: &HashMap<String, ContentSegment>)
if let ContentSegment::NostrUrl(nostr_url) = content {
output = output
.as_str()
.replace(pat, format!("nostr:{}", nostr_url.0).as_str())
.replacen(pat, format!("nostr:{}", nostr_url.0).as_str(), 1)
.to_string();
}
}

View File

@ -142,7 +142,18 @@ pub(in crate::ui) fn show_contact_search(
if is_selected {
response.scroll_to_me(None)
}
let clicked = response.interact(egui::Sense::click()).clicked();
// to workaround https://github.com/emilk/egui/issues/4147
// we will interact again, OVER the painted avatar and text
let response = ui
.interact(
response.rect,
ui.auto_id_with(pair.1.as_hex_string()).with(2),
egui::Sense::click(),
)
.on_hover_cursor(egui::CursorIcon::PointingHand);
let clicked = response.clicked();
if clicked || (enter_key && is_selected) {
on_select_callback(ui, app, output, pair);
}