Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove some todos
Antonio Scandurra0dfa3c60b726
diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex c3aa26cb0cb..4bd1a515386 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -36,8 +36,9 @@ pub use element::{use futures::FutureExt;use fuzzy::{StringMatch, StringMatchCandidate};use gpui::{- AnyElement, AppContext, BackgroundExecutor, Context, Element, EventEmitter, Hsla, Model,- Pixels, Render, Subscription, Task, TextStyle, View, ViewContext, WeakView, WindowContext,+ AnyElement, AppContext, BackgroundExecutor, Context, Element, EventEmitter, FocusHandle, Hsla,+ Model, Pixels, Render, Subscription, Task, TextStyle, View, ViewContext, WeakView,+ WindowContext,};use highlight_matching_bracket::refresh_matching_bracket_highlights;use hover_popover::{hide_hover, HoverState};@@ -606,6 +607,7 @@ type InlayBackgroundHighlight = (fn(&ThemeColors) -> Hsla, Vec<InlayHighlight>);pub struct Editor {handle: WeakView<Self>,+ focus_handle: FocusHandle,buffer: Model<MultiBuffer>,display_map: Model<DisplayMap>,pub selections: SelectionsCollection,@@ -1912,6 +1914,7 @@ impl Editor {let mut this = Self {handle: cx.view().downgrade(),+ focus_handle: cx.focus_handle(),buffer: buffer.clone(),display_map: display_map.clone(),selections,@@ -2066,19 +2069,15 @@ impl Editor {// }pub fn snapshot(&mut self, cx: &mut WindowContext) -> EditorSnapshot {- todo!()- // EditorSnapshot {- // mode: self.mode,- // show_gutter: self.show_gutter,- // display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),- // scroll_anchor: self.scroll_manager.anchor(),- // ongoing_scroll: self.scroll_manager.ongoing_scroll(),- // placeholder_text: self.placeholder_text.clone(),- // is_focused: self- // .handle- // .upgrade(cx)- // .map_or(false, |handle| handle.is_focused(cx)),- // }+ EditorSnapshot {+ mode: self.mode,+ show_gutter: self.show_gutter,+ display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),+ scroll_anchor: self.scroll_manager.anchor(),+ ongoing_scroll: self.scroll_manager.ongoing_scroll(),+ placeholder_text: self.placeholder_text.clone(),+ is_focused: self.focus_handle.is_focused(cx),+ }}// pub fn language_at<'a, T: ToOffset>(diff --git a/crates/editor2/src/highlight_matching_bracket.rs b/crates/editor2/src/highlight_matching_bracket.rsindex 5074ee4eda4..fd8fb6b0970 100644--- a/crates/editor2/src/highlight_matching_bracket.rs+++ b/crates/editor2/src/highlight_matching_bracket.rs@@ -5,30 +5,29 @@ use crate::{Editor, RangeToAnchorExt};enum MatchingBracketHighlight {}pub fn refresh_matching_bracket_highlights(editor: &mut Editor, cx: &mut ViewContext<Editor>) {- todo!()- // // editor.clear_background_highlights::<MatchingBracketHighlight>(cx);+ // editor.clear_background_highlights::<MatchingBracketHighlight>(cx);- // let newest_selection = editor.selections.newest::<usize>(cx);- // // Don't highlight brackets if the selection isn't empty- // if !newest_selection.is_empty() {- // return;- // }+ let newest_selection = editor.selections.newest::<usize>(cx);+ // Don't highlight brackets if the selection isn't empty+ if !newest_selection.is_empty() {+ return;+ }- // let head = newest_selection.head();- // let snapshot = editor.snapshot(cx);- // if let Some((opening_range, closing_range)) = snapshot- // .buffer_snapshot- // .innermost_enclosing_bracket_ranges(head..head)- // {- // editor.highlight_background::<MatchingBracketHighlight>(- // vec![- // opening_range.to_anchors(&snapshot.buffer_snapshot),- // closing_range.to_anchors(&snapshot.buffer_snapshot),- // ],- // |theme| theme.editor.document_highlight_read_background,- // cx,- // )- // }+ let head = newest_selection.head();+ let snapshot = editor.snapshot(cx);+ if let Some((opening_range, closing_range)) = snapshot+ .buffer_snapshot+ .innermost_enclosing_bracket_ranges(head..head)+ {+ editor.highlight_background::<MatchingBracketHighlight>(+ vec![+ opening_range.to_anchors(&snapshot.buffer_snapshot),+ closing_range.to_anchors(&snapshot.buffer_snapshot),+ ],+ |theme| todo!("theme.editor.document_highlight_read_background"),+ cx,+ )+ }}// #[cfg(test)]