diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index e157d832b440b8016f152c88b376a9418ee3c843..304a5736d76124deaf0a43c281b918a4a457da51 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -240,6 +240,7 @@ impl Console { start_offset, vec![range], style, + false, cx, ); } diff --git a/crates/editor/src/bracket_colorization.rs b/crates/editor/src/bracket_colorization.rs index 6b44e64ab486b49810b20d7db95ccd656a2ed6d8..6da68a25fe95080a366a522514baee9572046b22 100644 --- a/crates/editor/src/bracket_colorization.rs +++ b/crates/editor/src/bracket_colorization.rs @@ -95,6 +95,7 @@ impl Editor { depth, bracket_highlights, style, + true, cx, ); } diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index c2658c4f8e3db40b37a1bb747c5caf2b159bbbbf..598ac9b143a0e1bf1b280e6a256c82a3acabc74c 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -485,8 +485,17 @@ impl DisplayMap { key: HighlightKey, ranges: Vec>, style: HighlightStyle, + merge: bool, ) { - self.text_highlights.insert(key, Arc::new((style, ranges))); + let to_insert = match self.text_highlights.remove(&key).filter(|_| merge) { + Some(previous) => { + let mut merged_ranges = previous.1.clone(); + merged_ranges.extend(ranges); + Arc::new((style, merged_ranges)) + } + None => Arc::new((style, ranges)), + }; + self.text_highlights.insert(key, to_insert); } pub(crate) fn highlight_inlays( @@ -523,7 +532,7 @@ impl DisplayMap { pub fn clear_highlights(&mut self, type_id: TypeId) -> bool { let mut cleared = self .text_highlights - .remove(HighlightKey::Type(type_id)) + .remove(&HighlightKey::Type(type_id)) .is_some(); self.text_highlights.retain(|key, _| { let retain = if let HighlightKey::TypePlus(key_type_id, _) = key { @@ -2402,6 +2411,7 @@ pub mod tests { ..buffer_snapshot.anchor_after(Point::new(3, 18)), ], red.into(), + false, ); map.insert_blocks( [BlockProperties { @@ -2724,6 +2734,7 @@ pub mod tests { }) .collect(), style, + false, ); }); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6a758e3c10afc544e14e88ac21223448519edd4a..240125fd8a8691a52236bfee098f397518e9e1ff 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -20916,6 +20916,7 @@ impl Editor { key: usize, ranges: Vec>, style: HighlightStyle, + merge: bool, cx: &mut Context, ) { self.display_map.update(cx, |map, _| { @@ -20923,6 +20924,7 @@ impl Editor { HighlightKey::TypePlus(TypeId::of::(), key), ranges, style, + merge, ); }); cx.notify(); diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 8efe3587077757ba6dab21466212e0ad06ced37b..7b8c8d678eed96d2acf62bd48b07230651763b7e 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -4202,7 +4202,8 @@ impl BufferSnapshot { .map(|grammar| grammar.brackets_config.as_ref().unwrap()) .collect::>(); - // todo! this seems like a wrong parameter: instead, use chunk range, `Range`, as a key part + add bracket_id that will be used for each bracket + // todo! this seems like a wrong parameter: add bracket_id that will be used for each bracket + // this will require changing `depth` treatment during style application, we'll need to group brackets by their hsla let mut depth = 0; let chunk_range = chunk_range.clone(); let new_matches = iter::from_fn(move || {