Selectable popover text (#12918)
Release Notes: - Fixed #5236 - Added the ability to select and copy text from information popovers https://github.com/zed-industries/zed/assets/50590465/d5c86623-342b-474b-913e-d07cc3f76de4 --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> Co-authored-by: Antonio <ascii@zed.dev>
This commit is contained in:
parent
f1281c14dd
commit
945764e409
12 changed files with 592 additions and 396 deletions
|
@ -7,11 +7,22 @@ use std::ops::Range;
|
|||
pub fn parse_markdown(text: &str) -> Vec<(Range<usize>, MarkdownEvent)> {
|
||||
let mut events = Vec::new();
|
||||
let mut within_link = false;
|
||||
let mut within_metadata = false;
|
||||
for (pulldown_event, mut range) in Parser::new_ext(text, Options::all()).into_offset_iter() {
|
||||
if within_metadata {
|
||||
if let pulldown_cmark::Event::End(pulldown_cmark::TagEnd::MetadataBlock { .. }) =
|
||||
pulldown_event
|
||||
{
|
||||
within_metadata = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
match pulldown_event {
|
||||
pulldown_cmark::Event::Start(tag) => {
|
||||
if let pulldown_cmark::Tag::Link { .. } = tag {
|
||||
within_link = true;
|
||||
match tag {
|
||||
pulldown_cmark::Tag::Link { .. } => within_link = true,
|
||||
pulldown_cmark::Tag::MetadataBlock { .. } => within_metadata = true,
|
||||
_ => {}
|
||||
}
|
||||
events.push((range, MarkdownEvent::Start(tag.into())))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue