diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 6c481eaa55..5e18ad0b64 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -174,8 +174,11 @@ impl DisplayMap { .insert(Some(type_id), Arc::new((style, ranges))); } - pub fn clear_text_highlights(&mut self, type_id: TypeId) { - self.text_highlights.remove(&Some(type_id)); + pub fn clear_text_highlights( + &mut self, + type_id: TypeId, + ) -> Option>)>> { + self.text_highlights.remove(&Some(type_id)) } pub fn set_font(&self, font_id: FontId, font_size: f32, cx: &mut ModelContext) { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0a4bd6caa8..e462bd9872 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -134,6 +134,9 @@ action!(ConfirmCompletion, Option); action!(ConfirmCodeAction, Option); action!(OpenExcerpts); +enum DocumentHighlightRead {} +enum DocumentHighlightWrite {} + pub fn init(cx: &mut MutableAppContext, path_openers: &mut Vec>) { path_openers.push(Box::new(items::BufferOpener)); cx.add_bindings(vec![ @@ -2421,13 +2424,14 @@ impl Editor { project.document_highlights(&cursor_buffer, cursor_buffer_position, cx) }); - enum DocumentHighlightRead {} - enum DocumentHighlightWrite {} - self.document_highlights_task = Some(cx.spawn_weak(|this, mut cx| async move { let highlights = highlights.log_err().await; if let Some((this, highlights)) = this.upgrade(&cx).zip(highlights) { this.update(&mut cx, |this, cx| { + if this.pending_rename.is_some() { + return; + } + let buffer_id = cursor_position.buffer_id; let excerpt_id = cursor_position.excerpt_id.clone(); let style = this.style(cx); @@ -4436,8 +4440,19 @@ impl Editor { editor.select_all(&SelectAll, cx); editor }); + + let ranges = this + .clear_background_highlights::(cx) + .into_iter() + .flat_map(|(_, ranges)| ranges) + .chain( + this.clear_background_highlights::(cx) + .into_iter() + .flat_map(|(_, ranges)| ranges), + ) + .collect(); this.highlight_text::( - vec![range.clone()], + ranges, HighlightStyle { fade_out: Some(style.rename_fade), ..Default::default() @@ -5392,10 +5407,13 @@ impl Editor { cx.notify(); } - pub fn clear_text_highlights(&mut self, cx: &mut ViewContext) { - self.display_map - .update(cx, |map, _| map.clear_text_highlights(TypeId::of::())); + pub fn clear_text_highlights( + &mut self, + cx: &mut ViewContext, + ) -> Option>)>> { cx.notify(); + self.display_map + .update(cx, |map, _| map.clear_text_highlights(TypeId::of::())) } fn next_blink_epoch(&mut self) -> usize {