Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Show a very basic code actions menu
Antonio Scandurraa30b47aa5f96
diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rsindex 5185df9b2f6..c3a4059e6c2 100644--- a/crates/editor2/src/editor.rs+++ b/crates/editor2/src/editor.rs@@ -39,11 +39,11 @@ use futures::FutureExt;use fuzzy::{StringMatch, StringMatchCandidate};use git::diff_hunk_to_display;use gpui::{- action, actions, point, px, relative, rems, size, AnyElement, AppContext, BackgroundExecutor,- Bounds, ClipboardItem, Component, Context, DispatchContext, EventEmitter, FocusHandle,- FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla, InputHandler, Model, Pixels, Render,- Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext, VisualContext,- WeakView, WindowContext,+ action, actions, div, point, px, relative, rems, size, uniform_list, AnyElement, AppContext,+ BackgroundExecutor, Bounds, ClipboardItem, Component, Context, DispatchContext, EventEmitter,+ FocusHandle, FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla, InputHandler, Model,+ ParentElement, Pixels, Render, Styled, Subscription, Task, TextStyle, UniformListScrollHandle,+ View, ViewContext, VisualContext, WeakView, WindowContext,};use highlight_matching_bracket::refresh_matching_bracket_highlights;use hover_popover::{hide_hover, HoverState};@@ -1559,7 +1559,30 @@ impl CodeActionsMenu {style: &EditorStyle,cx: &mut ViewContext<Editor>,) -> (DisplayPoint, AnyElement<Editor>) {- todo!("old version below")+ let actions = self.actions.clone();+ let selected_item = self.selected_item;+ let element = uniform_list(+ "code_actions_menu",+ self.actions.len(),+ move |editor, range, cx| {+ actions[range.clone()]+ .iter()+ .enumerate()+ .map(|(ix, action)| {+ let item_ix = range.start + ix;+ div().child(action.lsp_action.title.clone())+ })+ .collect()+ },+ )+ .bg(gpui::red())+ .render();++ if self.deployed_from_indicator {+ *cursor_position.column_mut() = 0;+ }++ (cursor_position, element)}// enum ActionTag {}@@ -4383,7 +4406,7 @@ impl Editor {) -> Option<AnyElement<Self>> {if self.available_code_actions.is_some() {Some(- IconButton::new("code_actions", ui2::Icon::Bolt)+ IconButton::new("code_actions_indicator", ui2::Icon::Bolt).on_click(|editor: &mut Editor, cx| {editor.toggle_code_actions(&ToggleCodeActions {diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rsindex c444da718cb..ed38bb8a797 100644--- a/crates/editor2/src/element.rs+++ b/crates/editor2/src/element.rs@@ -804,7 +804,7 @@ impl EditorElement {cx.with_z_index(1, |cx| {let line_height = self.style.text.line_height_in_pixels(cx.rem_size());let available_space = size(- AvailableSpace::Definite(cx.viewport_size().width * 0.7),+ AvailableSpace::MinContent,AvailableSpace::Definite((12. * line_height).min((bounds.size.height - line_height) / 2.),),