Revert "debugger: Process ANSI color escape codes in console" (#32906)
Reverts zed-industries/zed#32817 Release Notes: - N/A
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use collections::BTreeMap;
|
||||
use gpui::HighlightStyle;
|
||||
use language::Chunk;
|
||||
use multi_buffer::{MultiBufferChunks, MultiBufferSnapshot, ToOffset as _};
|
||||
use multi_buffer::{Anchor, MultiBufferChunks, MultiBufferSnapshot, ToOffset as _};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
cmp,
|
||||
iter::{self, Peekable},
|
||||
ops::Range,
|
||||
sync::Arc,
|
||||
vec,
|
||||
};
|
||||
|
||||
use crate::display_map::TextHighlights;
|
||||
use sum_tree::TreeMap;
|
||||
|
||||
pub struct CustomHighlightsChunks<'a> {
|
||||
buffer_chunks: MultiBufferChunks<'a>,
|
||||
@@ -19,15 +19,15 @@ pub struct CustomHighlightsChunks<'a> {
|
||||
multibuffer_snapshot: &'a MultiBufferSnapshot,
|
||||
|
||||
highlight_endpoints: Peekable<vec::IntoIter<HighlightEndpoint>>,
|
||||
active_highlights: BTreeMap<(TypeId, usize), HighlightStyle>,
|
||||
text_highlights: Option<&'a TextHighlights>,
|
||||
active_highlights: BTreeMap<TypeId, HighlightStyle>,
|
||||
text_highlights: Option<&'a TreeMap<TypeId, Arc<(HighlightStyle, Vec<Range<Anchor>>)>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
struct HighlightEndpoint {
|
||||
offset: usize,
|
||||
is_start: bool,
|
||||
tag: (TypeId, usize),
|
||||
tag: TypeId,
|
||||
style: HighlightStyle,
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl<'a> CustomHighlightsChunks<'a> {
|
||||
pub fn new(
|
||||
range: Range<usize>,
|
||||
language_aware: bool,
|
||||
text_highlights: Option<&'a TextHighlights>,
|
||||
text_highlights: Option<&'a TreeMap<TypeId, Arc<(HighlightStyle, Vec<Range<Anchor>>)>>>,
|
||||
multibuffer_snapshot: &'a MultiBufferSnapshot,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -66,7 +66,7 @@ impl<'a> CustomHighlightsChunks<'a> {
|
||||
|
||||
fn create_highlight_endpoints(
|
||||
range: &Range<usize>,
|
||||
text_highlights: Option<&TextHighlights>,
|
||||
text_highlights: Option<&TreeMap<TypeId, Arc<(HighlightStyle, Vec<Range<Anchor>>)>>>,
|
||||
buffer: &MultiBufferSnapshot,
|
||||
) -> iter::Peekable<vec::IntoIter<HighlightEndpoint>> {
|
||||
let mut highlight_endpoints = Vec::new();
|
||||
@@ -74,7 +74,10 @@ fn create_highlight_endpoints(
|
||||
let start = buffer.anchor_after(range.start);
|
||||
let end = buffer.anchor_after(range.end);
|
||||
for (&tag, text_highlights) in text_highlights.iter() {
|
||||
let start_ix = match text_highlights.binary_search_by(|(probe, _)| {
|
||||
let style = text_highlights.0;
|
||||
let ranges = &text_highlights.1;
|
||||
|
||||
let start_ix = match ranges.binary_search_by(|probe| {
|
||||
let cmp = probe.end.cmp(&start, &buffer);
|
||||
if cmp.is_gt() {
|
||||
cmp::Ordering::Greater
|
||||
@@ -85,7 +88,7 @@ fn create_highlight_endpoints(
|
||||
Ok(i) | Err(i) => i,
|
||||
};
|
||||
|
||||
for (ix, (range, style)) in text_highlights[start_ix..].iter().enumerate() {
|
||||
for range in &ranges[start_ix..] {
|
||||
if range.start.cmp(&end, &buffer).is_ge() {
|
||||
break;
|
||||
}
|
||||
@@ -93,14 +96,14 @@ fn create_highlight_endpoints(
|
||||
highlight_endpoints.push(HighlightEndpoint {
|
||||
offset: range.start.to_offset(&buffer),
|
||||
is_start: true,
|
||||
tag: (tag, ix),
|
||||
style: *style,
|
||||
tag,
|
||||
style,
|
||||
});
|
||||
highlight_endpoints.push(HighlightEndpoint {
|
||||
offset: range.end.to_offset(&buffer),
|
||||
is_start: false,
|
||||
tag: (tag, ix),
|
||||
style: *style,
|
||||
tag,
|
||||
style,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1122,7 +1122,7 @@ mod tests {
|
||||
use project::{InlayHint, InlayHintLabel, ResolveState};
|
||||
use rand::prelude::*;
|
||||
use settings::SettingsStore;
|
||||
use std::{any::TypeId, cmp::Reverse, env};
|
||||
use std::{any::TypeId, cmp::Reverse, env, sync::Arc};
|
||||
use sum_tree::TreeMap;
|
||||
use text::Patch;
|
||||
use util::post_inc;
|
||||
@@ -1630,16 +1630,16 @@ mod tests {
|
||||
log::info!("highlighting text ranges {text_highlight_ranges:?}");
|
||||
text_highlights.insert(
|
||||
TypeId::of::<()>(),
|
||||
text_highlight_ranges
|
||||
.into_iter()
|
||||
.map(|range| {
|
||||
(
|
||||
Arc::new((
|
||||
HighlightStyle::default(),
|
||||
text_highlight_ranges
|
||||
.into_iter()
|
||||
.map(|range| {
|
||||
buffer_snapshot.anchor_before(range.start)
|
||||
..buffer_snapshot.anchor_after(range.end),
|
||||
HighlightStyle::default(),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
..buffer_snapshot.anchor_after(range.end)
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
);
|
||||
|
||||
let mut inlay_highlights = InlayHighlights::default();
|
||||
|
||||
Reference in New Issue
Block a user