Merge branch 'main' into diagnostics-style-2
This commit is contained in:
@@ -154,7 +154,6 @@ pub fn render_parsed_markdown(
|
||||
}
|
||||
}),
|
||||
);
|
||||
let runs = text_runs_for_highlights(&parsed.text, &editor_style.text, highlights);
|
||||
|
||||
let mut links = Vec::new();
|
||||
let mut link_ranges = Vec::new();
|
||||
@@ -167,7 +166,7 @@ pub fn render_parsed_markdown(
|
||||
|
||||
InteractiveText::new(
|
||||
element_id,
|
||||
StyledText::new(parsed.text.clone()).with_runs(runs),
|
||||
StyledText::new(parsed.text.clone()).with_highlights(&editor_style.text, highlights),
|
||||
)
|
||||
.on_click(link_ranges, move |clicked_range_ix, cx| {
|
||||
match &links[clicked_range_ix] {
|
||||
@@ -1199,11 +1198,7 @@ impl CompletionsMenu {
|
||||
),
|
||||
);
|
||||
let completion_label = StyledText::new(completion.label.text.clone())
|
||||
.with_runs(text_runs_for_highlights(
|
||||
&completion.label.text,
|
||||
&style.text,
|
||||
highlights,
|
||||
));
|
||||
.with_highlights(&style.text, highlights);
|
||||
let documentation_label =
|
||||
if let Some(Documentation::SingleLine(text)) = documentation {
|
||||
Some(SharedString::from(text.clone()))
|
||||
@@ -1925,14 +1920,14 @@ impl Editor {
|
||||
// self.buffer.read(cx).read(cx).file_at(point).cloned()
|
||||
// }
|
||||
|
||||
// pub fn active_excerpt(
|
||||
// &self,
|
||||
// cx: &AppContext,
|
||||
// ) -> Option<(ExcerptId, Model<Buffer>, Range<text::Anchor>)> {
|
||||
// self.buffer
|
||||
// .read(cx)
|
||||
// .excerpt_containing(self.selections.newest_anchor().head(), cx)
|
||||
// }
|
||||
pub fn active_excerpt(
|
||||
&self,
|
||||
cx: &AppContext,
|
||||
) -> Option<(ExcerptId, Model<Buffer>, Range<text::Anchor>)> {
|
||||
self.buffer
|
||||
.read(cx)
|
||||
.excerpt_containing(self.selections.newest_anchor().head(), cx)
|
||||
}
|
||||
|
||||
// pub fn style(&self, cx: &AppContext) -> EditorStyle {
|
||||
// build_style(
|
||||
@@ -9777,31 +9772,6 @@ pub fn diagnostic_style(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text_runs_for_highlights(
|
||||
text: &str,
|
||||
default_style: &TextStyle,
|
||||
highlights: impl IntoIterator<Item = (Range<usize>, HighlightStyle)>,
|
||||
) -> Vec<TextRun> {
|
||||
let mut runs = Vec::new();
|
||||
let mut ix = 0;
|
||||
for (range, highlight) in highlights {
|
||||
if ix < range.start {
|
||||
runs.push(default_style.clone().to_run(range.start - ix));
|
||||
}
|
||||
runs.push(
|
||||
default_style
|
||||
.clone()
|
||||
.highlight(highlight)
|
||||
.to_run(range.len()),
|
||||
);
|
||||
ix = range.end;
|
||||
}
|
||||
if ix < text.len() {
|
||||
runs.push(default_style.to_run(text.len() - ix));
|
||||
}
|
||||
runs
|
||||
}
|
||||
|
||||
pub fn styled_runs_for_code_label<'a>(
|
||||
label: &'a CodeLabel,
|
||||
syntax_theme: &'a theme::SyntaxTheme,
|
||||
|
||||
Reference in New Issue
Block a user